Show Code

show_code provides an easy way to show your ruby method source codes in terminal.

show_code_example

NOTE: show_code current version require Ruby v1.9.0 or later.

Installation

# Installing as Ruby gem
$ gem install show_code

# Or in gemfile
$ gem show_code

Usage

You will be able use show_code in rails c or irb.

require "show_code" # just when use irb
ShowCode method_object
# or
ShowCode 'YourClassOrModule.your_method'

Examples

show code

ShowCode 'ShowCode::Code.new.greet'

#     def greet
#       puts 'Hello ShowCode!'
#     end
# => #<UnboundMethod: ShowCode::Code#greet>

# also you can use this way, it does the same thing
ShowCode ShowCode::Code.instance_method(:greet)

open resource file

Sometimes, we wanna open the resource file to edit, as default gedit will open the file.

ShowCode.open 'ShowCode::Code.new.greet'
# or ShowCode.open ShowCode::Code.instance_method(:greet)

TODO

  • Add more statistic analysis for output

License

Released under the MIT license. See LICENSE file for details.