Sha256: e68ed444ca4ef9a1cab944253f9fbad364561e2ac8a45a3fcc717ff712e1e12b

Contents?: true

Size: 1.22 KB

Versions: 59

Compression:

Stored size: 1.22 KB

Contents

require 'pry/commands/show_info'

class Pry
  class Command::ShowSource < Command::ShowInfo
    match 'show-source'
    group 'Introspection'
    description 'Show the source for a method or class.'

    banner <<-'BANNER'
      Usage:   show-source [OPTIONS] [METH|CLASS]
      Aliases: $, show-method

      Show the source for a method or class. Tries instance methods first and then
      methods by default.

      show-source hi_method
      show-source hi_method
      show-source Pry#rep     # source for Pry#rep method
      show-source Pry         # for Pry class
      show-source Pry -a      # for all Pry class definitions (all monkey patches)
      show-source Pry --super # for superclass of Pry (Object class)

      https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method
    BANNER

    # The source for code_object prepared for display.
    def content_for(code_object)
      cannot_locate_source_error if !code_object.source

      Code.new(code_object.source, start_line_for(code_object)).
        with_line_numbers(use_line_numbers?).to_s
    end
  end

  Pry::Commands.add_command(Pry::Command::ShowSource)
  Pry::Commands.alias_command 'show-method', 'show-source'
  Pry::Commands.alias_command '$', 'show-source'
end

Version data entries

59 entries across 59 versions & 5 rubygems

Version Path
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/pry-0.9.12.6/lib/pry/commands/show_source.rb
pry-0.9.12.6 lib/pry/commands/show_source.rb
pry-0.9.12.6-i386-mswin32 lib/pry/commands/show_source.rb
pry-0.9.12.6-i386-mingw32 lib/pry/commands/show_source.rb
pry-0.9.12.6-java lib/pry/commands/show_source.rb
pry-0.9.12.5 lib/pry/commands/show_source.rb
pry-0.9.12.5-i386-mswin32 lib/pry/commands/show_source.rb
pry-0.9.12.5-i386-mingw32 lib/pry/commands/show_source.rb
pry-0.9.12.5-java lib/pry/commands/show_source.rb
pry-0.9.12.4 lib/pry/commands/show_source.rb
pry-0.9.12.4-i386-mswin32 lib/pry/commands/show_source.rb
pry-0.9.12.4-i386-mingw32 lib/pry/commands/show_source.rb
pry-0.9.12.4-java lib/pry/commands/show_source.rb
pry-0.9.12.3 lib/pry/commands/show_source.rb
pry-0.9.12.3-i386-mswin32 lib/pry/commands/show_source.rb
pry-0.9.12.3-i386-mingw32 lib/pry/commands/show_source.rb
pry-0.9.12.3-java lib/pry/commands/show_source.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/pry-0.9.12-java/lib/pry/commands/show_source.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/pry-0.9.12.2/lib/pry/commands/show_source.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/pry-0.9.12.2/lib/pry/commands/show_source.rb