https://github.com/banister/method_source
return the sourcecode for a method
https://github.com/banister/method_source
Keywords from Contributors
rubygems activerecord mvc activejob feature-flag debugger reflection irb introspection pry
Last synced: about 3 hours ago
JSON representation
Repository metadata
return the sourcecode for a method
- Host: GitHub
- URL: https://github.com/banister/method_source
- Owner: banister
- License: mit
- Created: 2010-12-16T13:43:39.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2024-04-15T14:21:28.000Z (almost 2 years ago)
- Last Synced: 2026-02-18T10:29:55.508Z (14 days ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 369
- Watchers: 8
- Forks: 44
- Open Issues: 31
- Releases: 0
-
Metadata Files:
- Readme: README.markdown
- Changelog: CHANGELOG.md
- License: LICENSE
README.markdown
method_source
(C) John Mair (banisterfiend) 2011
retrieve the sourcecode for a method
NOTE: This simply utilizes Method#source_location; it
does not access the live AST.
method_source is a utility to return a method's sourcecode as a
Ruby string. Also returns Proc and Lambda sourcecode.
Method comments can also be extracted using the comment method.
It is written in pure Ruby (no C).
- Some Ruby 1.8 support now available.
- Support for MRI, RBX, JRuby, REE
method_source provides the source and comment methods to the Method and
UnboundMethod and Proc classes.
- Install the gem:
gem install method_source - Read the documentation
- See the source code
Example: display method source
Set.instance_method(:merge).source.display
# =>
def merge(enum)
if enum.instance_of?(self.class)
@hash.update(enum.instance_variable_get(:@hash))
else
do_with_enum(enum) { |o| add(o) }
end
self
end
Example: display method comments
Set.instance_method(:merge).comment.display
# =>
# Merges the elements of the given enumerable object to the set and
# returns self.
Example: display module/class comments
MethodSource::MethodExtensions.method(:included).module_comment
# =>
# This module is to be included by `Method` and `UnboundMethod` and
# provides the `#source` functionality
Limitations:
- Occasional strange behaviour in Ruby 1.8
- Cannot return source for C methods.
- Cannot return source for dynamically defined methods.
Special Thanks
Adam Sanderson for comment functionality.
Dmitry Elastic for the brilliant Ruby 1.8 source_location hack.
Samuel Kadolph for the JRuby 1.8 source_location.
License
(The MIT License)
Copyright (c) 2011 John Mair (banisterfiend)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Owner metadata
- Name: John Mair
- Login: banister
- Email:
- Kind: user
- Description: I created Pry, binding_of_caller, method_source, debug_inspector, and so on
- Website: http://twitter.com/banisterfiend
- Location: The Hague, Netherlands
- Twitter:
- Company: Secret
- Icon url: https://avatars.githubusercontent.com/u/17518?u=67690ef926a5f4bee3fcc01091b6b2ece18fe9ee&v=4
- Repositories: 76
- Last ynced at: 2023-04-09T03:40:22.037Z
- Profile URL: https://github.com/banister
GitHub Events
Total
- Fork event: 2
- Watch event: 7
Last Year
- Fork event: 1
- Watch event: 2
Committers metadata
Last synced: about 15 hours ago
Total Commits: 99
Total Committers: 22
Avg Commits per committer: 4.5
Development Distribution Score (DDS): 0.576
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| John Mair | j****r@g****m | 42 |
| Conrad Irwin | c****n@g****m | 14 |
| Kyrylo Silin | s****n@k****g | 7 |
| Jean Boussier | j****r@g****m | 6 |
| Ryan Fitzgerald | r****e@g****m | 6 |
| Rob Gleeson | r****b@f****o | 3 |
| Koichi ITO | k****o@g****m | 3 |
| Jun Aruga | j****a@r****m | 2 |
| Maciej Mensfeld | m****j@m****l | 2 |
| Reginald Tan | r****n@g****m | 2 |
| Nicolas Leger | n****r@n****m | 1 |
| Adam Sanderson | n****t@g****m | 1 |
| Jack Nagel | j****l@g****m | 1 |
| Jason Karns | j****s@g****m | 1 |
| Matt Larraz | m****z | 1 |
| Peter M. Goldstein | p****n@g****m | 1 |
| Peter Souter | p****s | 1 |
| Rafael Masson | r****n@g****m | 1 |
| Stas SUȘCOV | s****s@n****o | 1 |
| Vít Ondruch | v****h@t****z | 1 |
| Yoshiyuki Hirano | y****o@m****m | 1 |
| nisusam | n****l@g****m | 1 |
Committer domains:
- me.com: 1
- tiscali.cz: 1
- nerd.ro: 1
- nleger.com: 1
- mensfeld.pl: 1
- redhat.com: 1
- flowof.info: 1
- kyrylo.org: 1
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 32
Total pull requests: 56
Average time to close issues: about 2 months
Average time to close pull requests: 4 months
Total issue authors: 25
Total pull request authors: 32
Average comments per issue: 1.66
Average comments per pull request: 1.13
Merged pull request: 35
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 1
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 0.0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- banister (4)
- egwspiti (3)
- kyrylo (2)
- searls (2)
- hkdnet (1)
- twk3 (1)
- bryanp (1)
- graaff (1)
- dmlary (1)
- sanemat (1)
- junaruga (1)
- eregon (1)
- gogainda (1)
- benlieb (1)
- voxik (1)
Top Pull Request Authors
- kyrylo (8)
- ConradIrwin (4)
- redgetan (4)
- casperisfine (4)
- ccutrer (3)
- pat (2)
- ghost (2)
- zheng-yongping (2)
- koic (2)
- junaruga (2)
- symwell (2)
- gogainda (1)
- yhirano55 (1)
- mlarraz (1)
- rafbm (1)
Top Issue Labels
- feature (3)
Top Pull Request Labels
Package metadata
- Total packages: 14
-
Total downloads:
- rubygems: 1,430,715,270 total
- Total docker downloads: 2,949,696,884
- Total dependent packages: 134 (may contain duplicates)
- Total dependent repositories: 558,379 (may contain duplicates)
- Total versions: 84
- Total maintainers: 4
gem.coop: method_source
retrieve the sourcecode for a method
- Homepage: http://banisterfiend.wordpress.com
- Documentation: http://www.rubydoc.info/gems/method_source/
- Licenses: MIT
- Latest release: 1.1.0 (published almost 2 years ago)
- Last Synced: 2026-03-02T20:30:44.673Z (1 day ago)
- Versions: 29
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 715,382,401 Total
- Docker Downloads: 1,474,848,442
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Downloads: 0.021%
- Average: 0.022%
- Docker downloads count: 0.065%
- Maintainers (4)
rubygems.org: method_source
retrieve the sourcecode for a method
- Homepage: http://banisterfiend.wordpress.com
- Documentation: http://www.rubydoc.info/gems/method_source/
- Licenses: MIT
- Latest release: 1.1.0 (published almost 2 years ago)
- Last Synced: 2026-03-02T18:03:54.663Z (1 day ago)
- Versions: 29
- Dependent Packages: 134
- Dependent Repositories: 558,379
- Downloads: 715,332,869 Total
- Docker Downloads: 1,474,848,442
-
Rankings:
- Downloads: 0.022%
- Dependent repos count: 0.026%
- Docker downloads count: 0.106%
- Dependent packages count: 0.269%
- Average: 1.256%
- Stargazers count: 3.058%
- Forks count: 4.054%
- Maintainers (4)
proxy.golang.org: github.com/banister/method_source
- Homepage:
- Documentation: https://pkg.go.dev/github.com/banister/method_source#section-documentation
- Licenses: mit
- Latest release: v1.1.0 (published almost 2 years ago)
- Last Synced: 2026-03-01T20:02:08.089Z (2 days ago)
- Versions: 15
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.025%
- Forks count: 3.625%
- Average: 6.757%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
debian-10: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Documentation: https://packages.debian.org/buster/ruby-method-source
- Licenses:
- Latest release: 0.9.2-1 (published 21 days ago)
- Last Synced: 2026-02-13T04:22:53.944Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.10: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Licenses:
- Latest release: 1.0.0-2 (published 18 days ago)
- Last Synced: 2026-02-13T18:25:31.042Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-11: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Documentation: https://packages.debian.org/bullseye/ruby-method-source
- Licenses:
- Latest release: 1.0.0-2 (published 21 days ago)
- Last Synced: 2026-02-13T08:22:06.602Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-20.04: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Licenses: mit
- Latest release: 0.9.2-1 (published 19 days ago)
- Last Synced: 2026-02-13T07:17:36.961Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
guix: ruby-method-source
Retrieve the source code for Ruby methods
- Homepage: https://github.com/banister/method_source
- Documentation: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/ruby-xyz.scm#n6303
- Licenses: expat
- Latest release: 1.0.0 (published 1 day ago)
- Last Synced: 2026-03-02T18:52:07.009Z (1 day ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Licenses:
- Latest release: 1.0.0-2 (published 18 days ago)
- Last Synced: 2026-02-13T13:20:22.407Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Licenses:
- Latest release: 1.0.0-2 (published 21 days ago)
- Last Synced: 2026-02-11T06:43:14.596Z (21 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Documentation: https://packages.debian.org/bookworm/ruby-method-source
- Licenses:
- Latest release: 1.0.0-2 (published 19 days ago)
- Last Synced: 2026-02-12T23:34:56.952Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
debian-13: ruby-method-source
- Homepage: https://github.com/banister/method_source
- Documentation: https://packages.debian.org/trixie/ruby-method-source
- Licenses:
- Latest release: 1.1.0-1 (published 19 days ago)
- Last Synced: 2026-02-13T13:17:27.605Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- actions/checkout v4 composite
- ruby/setup-ruby v1 composite
- rake >= 0
- rspec >= 0
Score: 31.283044241344033