pry 0.9.12.6-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. data/wiki/Home.md +0 -4
@@ -0,0 +1,46 @@
1
+ require 'pry/commands/ls/jruby_hacks'
2
+
3
+ module Pry::Command::Ls::MethodsHelper
4
+
5
+ include Pry::Command::Ls::JRubyHacks
6
+
7
+ private
8
+
9
+ # Get all the methods that we'll want to output.
10
+ def all_methods(instance_methods = false)
11
+ methods = if instance_methods || @instance_methods_switch
12
+ Pry::Method.all_from_class(@interrogatee)
13
+ else
14
+ Pry::Method.all_from_obj(@interrogatee)
15
+ end
16
+
17
+ if Pry::Helpers::BaseHelpers.jruby? && !@jruby_switch
18
+ methods = trim_jruby_aliases(methods)
19
+ end
20
+
21
+ methods.select { |method| @ppp_switch || method.visibility == :public }
22
+ end
23
+
24
+ def resolution_order
25
+ if @instance_methods_switch
26
+ Pry::Method.instance_resolution_order(@interrogatee)
27
+ else
28
+ Pry::Method.resolution_order(@interrogatee)
29
+ end
30
+ end
31
+
32
+ def format(methods)
33
+ methods.sort_by(&:name).map do |method|
34
+ if method.name == 'method_missing'
35
+ color(:method_missing, 'method_missing')
36
+ elsif method.visibility == :private
37
+ color(:private_method, method.name)
38
+ elsif method.visibility == :protected
39
+ color(:protected_method, method.name)
40
+ else
41
+ color(:public_method, method.name)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,32 @@
1
+ require 'pry/commands/ls/interrogatable'
2
+ require 'pry/commands/ls/methods_helper'
3
+
4
+ class Pry
5
+ class Command::Ls < Pry::ClassCommand
6
+ class SelfMethods < Pry::Command::Ls::Formatter
7
+ include Pry::Command::Ls::Interrogatable
8
+ include Pry::Command::Ls::MethodsHelper
9
+
10
+ def initialize(interrogatee, no_user_opts, opts, _pry_)
11
+ super(_pry_)
12
+ @interrogatee = interrogatee
13
+ @no_user_opts = no_user_opts
14
+ end
15
+
16
+ def output_self
17
+ methods = all_methods(true).select do |m|
18
+ m.owner == @interrogatee && grep.regexp[m.name]
19
+ end
20
+ heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
21
+ output_section(heading, format(methods))
22
+ end
23
+
24
+ private
25
+
26
+ def correct_opts?
27
+ @no_user_opts && interrogating_a_module?
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -2,7 +2,7 @@ class Pry
2
2
  class Command::Play < Pry::ClassCommand
3
3
  match 'play'
4
4
  group 'Editing'
5
- description 'Playback a string variable or a method or a file as input.'
5
+ description 'Playback a string variable, method, line, or file as input.'
6
6
 
7
7
  banner <<-'BANNER'
8
8
  Usage: play [OPTIONS] [--help]
@@ -10,10 +10,15 @@ class Pry
10
10
  The play command enables you to replay code from files and methods as if they
11
11
  were entered directly in the Pry REPL.
12
12
 
13
- play --lines 149..153
14
- play -i 20 --lines 1..3
15
- play Pry#repl --lines 1..-1
16
- play Rakefile --lines 5
13
+ play --lines 149..153 # assumes current context
14
+ play -i 20 --lines 1..3 # assumes lines of the input expression at 20
15
+ play -o 4 # the output of of an expression at 4
16
+ play Pry#repl -l 1..-1 # play the contents of Pry#repl method
17
+ play -e 2 # play from specified line until end of valid expression
18
+ play hello.rb # play a file
19
+ play Rakefile -l 5 # play line 5 of a file
20
+ play -d hi # play documentation of hi method
21
+ play hi --open # play hi method and leave it open
17
22
 
18
23
  https://github.com/pry/pry/wiki/User-Input#wiki-Play
19
24
  BANNER
@@ -21,23 +26,52 @@ class Pry
21
26
  def options(opt)
22
27
  CodeCollector.inject_options(opt)
23
28
 
24
- opt.on :open, 'Plays the select content except except' \
25
- ' the last line. Useful for replaying methods and leaving the method definition "open". `amend-line`' \
26
- ' can then be used to modify the method.'
29
+ opt.on :open, 'Plays the selected content except the last line. Useful' \
30
+ ' for replaying methods and leaving the method definition' \
31
+ ' "open". `amend-line` can then be used to' \
32
+ ' modify the method.'
33
+
34
+ opt.on :e, :expression=, 'Executes until end of valid expression', :as => Integer
35
+ opt.on :p, :print, 'Prints executed code'
27
36
  end
28
37
 
29
38
  def process
30
39
  @cc = CodeCollector.new(args, opts, _pry_)
31
40
 
32
41
  perform_play
33
- run "show-input" unless Pry::Code.complete_expression?(eval_string)
42
+ show_input
34
43
  end
35
44
 
36
45
  def perform_play
37
- eval_string << (opts.present?(:open) ? restrict_to_lines(content, (0..-2)) : content)
46
+ eval_string << content_after_options
38
47
  run "fix-indent"
39
48
  end
40
49
 
50
+ def show_input
51
+ if opts.present?(:print) or !Pry::Code.complete_expression?(eval_string)
52
+ run "show-input"
53
+ end
54
+ end
55
+
56
+
57
+ def content_after_options
58
+ if opts.present?(:open)
59
+ restrict_to_lines(content, (0..-2))
60
+ elsif opts.present?(:expression)
61
+ content_at_expression
62
+ else
63
+ content
64
+ end
65
+ end
66
+
67
+ def content_at_expression
68
+ code_object.expression_at(opts[:expression])
69
+ end
70
+
71
+ def code_object
72
+ Pry::Code.new(content)
73
+ end
74
+
41
75
  def should_use_default_file?
42
76
  !args.first && !opts.present?(:in) && !opts.present?(:out)
43
77
  end
@@ -17,8 +17,7 @@ class Pry
17
17
  BANNER
18
18
 
19
19
  def process
20
- stagger_output text.bold('Backtrace:') +
21
- "\n--\n" + _pry_.backtrace.join("\n")
20
+ _pry_.pager.page text.bold('Backtrace:') << "\n--\n" << _pry_.backtrace.join("\n")
22
21
  end
23
22
  end
24
23
 
@@ -1,7 +1,7 @@
1
1
  class Pry
2
2
  # N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
3
3
  class Command::RaiseUp < Pry::ClassCommand
4
- match /raise-up(!?\b.*)/
4
+ match(/raise-up(!?\b.*)/)
5
5
  group 'Context'
6
6
  description 'Raise an exception out of the current pry instance.'
7
7
  command_options :listing => 'raise-up'
@@ -22,7 +22,7 @@ class Pry
22
22
  BANNER
23
23
 
24
24
  def process
25
- return stagger_output help if captures[0] =~ /(-h|--help)\b/
25
+ return _pry.pager.page help if captures[0] =~ /(-h|--help)\b/
26
26
  # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
27
27
  target.eval("_pry_.raise_up#{captures[0]}")
28
28
  end
@@ -10,19 +10,17 @@ class Pry
10
10
  e.g reload-code MyClass#my_method #=> reload a method
11
11
  reload-code MyClass #=> reload a class
12
12
  reload-code my-command #=> reload a pry command
13
- reload-code self #=> reload the 'current' object
14
- reload-code #=> identical to reload-code self
13
+ reload-code self #=> reload the current object
14
+ reload-code #=> reload the current file or object
15
15
  BANNER
16
16
 
17
17
  def process
18
-
19
- if obj_name.empty?
20
- # if no parameters were provided then try to reload the
21
- # current file (i.e target.eval("__FILE__"))
22
- reload_current_file
18
+ if !args.empty?
19
+ reload_object(args.join(" "))
20
+ elsif internal_binding?(target)
21
+ reload_object("self")
23
22
  else
24
- code_object = Pry::CodeObject.lookup(obj_name, _pry_)
25
- reload_code_object(code_object)
23
+ reload_current_file
26
24
  end
27
25
  end
28
26
 
@@ -41,21 +39,20 @@ class Pry
41
39
  output.puts "The current file: #{current_file} was reloaded!"
42
40
  end
43
41
 
44
- def reload_code_object(code_object)
45
- check_for_reloadability(code_object)
42
+ def reload_object(identifier)
43
+ code_object = Pry::CodeObject.lookup(identifier, _pry_)
44
+ check_for_reloadability(code_object, identifier)
46
45
  load code_object.source_file
47
- output.puts "#{obj_name} was reloaded!"
48
- end
49
-
50
- def obj_name
51
- @obj_name ||= args.join(" ")
46
+ output.puts "#{identifier} was reloaded!"
52
47
  end
53
48
 
54
- def check_for_reloadability(code_object)
49
+ def check_for_reloadability(code_object, identifier)
55
50
  if !code_object || !code_object.source_file
56
- raise CommandError, "Cannot locate #{obj_name}!"
51
+ raise CommandError, "Cannot locate #{identifier}!"
57
52
  elsif !File.exists?(code_object.source_file)
58
- raise CommandError, "Cannot reload #{obj_name} as it has no associated file on disk. File found was: #{code_object.source_file}"
53
+ raise CommandError,
54
+ "Cannot reload #{identifier} as it has no associated file on disk. " \
55
+ "File found was: #{code_object.source_file}"
59
56
  end
60
57
  end
61
58
  end
@@ -23,14 +23,18 @@ class Pry
23
23
  subclass = Class.new(RDoc::RI::Driver) # the hard way.
24
24
 
25
25
  subclass.class_eval do
26
+ def initialize(pager, opts)
27
+ @pager = pager
28
+ super opts
29
+ end
26
30
  def page
27
31
  paging_text = StringIO.new
28
32
  yield paging_text
29
- Pry::Pager.page(paging_text.string)
33
+ @pager.page(paging_text.string)
30
34
  end
31
35
 
32
36
  def formatter(io)
33
- if @formatter_klass then
37
+ if @formatter_klass
34
38
  @formatter_klass.new
35
39
  else
36
40
  RDoc::Markup::ToAnsi.new
@@ -42,7 +46,7 @@ class Pry
42
46
  end
43
47
 
44
48
  # Spin-up an RI insance.
45
- ri = RDoc::RI::PryDriver.new :use_stdout => true, :interactive => false
49
+ ri = RDoc::RI::PryDriver.new _pry_.pager, :use_stdout => true, :interactive => false
46
50
 
47
51
  begin
48
52
  ri.display_names [spec] # Get the documentation (finally!)
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
  class Command::ShellCommand < Pry::ClassCommand
3
- match /\.(.*)/
3
+ match(/\.(.*)/)
4
4
  group 'Input and Output'
5
5
  description "All text following a '.' is forwarded to the shell."
6
6
  command_options :listing => '.<shell command>', :use_prefix => false,
@@ -16,27 +16,32 @@ class Pry
16
16
  BANNER
17
17
 
18
18
  def process(cmd)
19
- if cmd =~ /^cd\s+(.+)/i
20
- dest = $1
21
- begin
22
- Dir.chdir File.expand_path(dest)
23
- rescue Errno::ENOENT
24
- raise CommandError, "No such directory: #{dest}"
25
- end
19
+ if cmd =~ /^cd\s*(.*)/i
20
+ process_cd parse_destination($1)
26
21
  else
27
22
  pass_block(cmd)
28
-
29
23
  if command_block
30
24
  command_block.call `#{cmd}`
31
25
  else
32
- Pry.config.system.call(output, cmd, _pry_)
26
+ _pry_.config.system.call(output, cmd, _pry_)
33
27
  end
34
28
  end
35
29
  end
36
30
 
37
- def complete(search)
38
- super + Bond::Rc.files(search.split(" ").last || '')
39
- end
31
+ private
32
+
33
+ def parse_destination(dest)
34
+ return "~" if dest.empty?
35
+ return dest unless dest == "-"
36
+ state.old_pwd || raise(CommandError, "No prior directory available")
37
+ end
38
+
39
+ def process_cd(dest)
40
+ state.old_pwd = Dir.pwd
41
+ Dir.chdir File.expand_path(dest)
42
+ rescue Errno::ENOENT
43
+ raise CommandError, "No such directory: #{dest}"
44
+ end
40
45
  end
41
46
 
42
47
  Pry::Commands.add_command(Pry::Command::ShellCommand)
@@ -12,12 +12,10 @@ class Pry
12
12
  case _pry_.prompt
13
13
  when Pry::SHELL_PROMPT
14
14
  _pry_.pop_prompt
15
- _pry_.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
15
+ _pry_.custom_completions = _pry_.config.file_completions
16
16
  else
17
17
  _pry_.push_prompt Pry::SHELL_PROMPT
18
- _pry_.custom_completions = Pry::FILE_COMPLETIONS
19
- Readline.completion_proc = Pry::InputCompleter.build_completion_proc target,
20
- _pry_.instance_eval(&Pry::FILE_COMPLETIONS)
18
+ _pry_.custom_completions = _pry_.config.command_completions
21
19
  end
22
20
  end
23
21
  end
@@ -35,6 +35,11 @@ class Pry
35
35
  # command '--help' shouldn't use markup highlighting
36
36
  docs
37
37
  else
38
+ if docs.empty?
39
+ raise CommandError, "No docs found for: #{
40
+ obj_name ? obj_name : 'current context'
41
+ }"
42
+ end
38
43
  process_comment_markup(docs)
39
44
  end
40
45
  end
@@ -2,18 +2,13 @@ class Pry
2
2
  class Command::ShowInfo < Pry::ClassCommand
3
3
  extend Pry::Helpers::BaseHelpers
4
4
 
5
- command_options :shellwords => false
6
- command_options :requires_gem => "ruby18_source_location" if mri_18?
7
-
8
- def setup
9
- require 'ruby18_source_location' if mri_18?
10
- end
5
+ command_options :shellwords => false, :interpolate => false
11
6
 
12
7
  def options(opt)
13
8
  opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", :as => :count
14
9
  opt.on :l, "line-numbers", "Show line numbers"
15
10
  opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)"
16
- opt.on :a, :all, "Show all definitions and monkeypatches of the module/class"
11
+ opt.on :a, :all, "Show all definitions and monkeypatches of the module/class"
17
12
  end
18
13
 
19
14
  def process
@@ -32,7 +27,7 @@ class Pry
32
27
  end
33
28
 
34
29
  set_file_and_dir_locals(code_object.source_file)
35
- stagger_output result
30
+ _pry_.pager.page result
36
31
  end
37
32
 
38
33
  # This method checks whether the `code_object` is a WrappedModule,
@@ -63,7 +58,7 @@ class Pry
63
58
  end
64
59
 
65
60
  def content_and_header_for_code_object(code_object)
66
- header(code_object) + content_for(code_object)
61
+ header(code_object) << content_for(code_object)
67
62
  end
68
63
 
69
64
  def content_and_headers_for_all_module_candidates(mod)
@@ -95,7 +90,7 @@ class Pry
95
90
  h << code_object_header(code_object, line_num)
96
91
  h << "\n#{Pry::Helpers::Text.bold('Number of lines:')} " <<
97
92
  "#{content_for(code_object).lines.count}\n\n"
98
- h << Helpers::Text.bold('** Warning:') + " Cannot find code for #{@original_code_object.nonblank_name}. Showing superclass #{code_object.nonblank_name} instead. **\n\n" if @used_super
93
+ h << Helpers::Text.bold('** Warning:') << " Cannot find code for #{@original_code_object.nonblank_name}. Showing superclass #{code_object.nonblank_name} instead. **\n\n" if @used_super
99
94
  h
100
95
  end
101
96
 
@@ -128,7 +123,7 @@ class Pry
128
123
  h << " #{text.bold('name:')} #{code_object.nonblank_name}"
129
124
 
130
125
  if code_object.number_of_candidates > 1
131
- h << (text.bold("\nNumber of monkeypatches: ") + code_object.number_of_candidates.to_s)
126
+ h << (text.bold("\nNumber of monkeypatches: ") << code_object.number_of_candidates.to_s)
132
127
  h << ". Use the `-a` option to display all available monkeypatches"
133
128
  end
134
129
  h
@@ -155,7 +150,7 @@ class Pry
155
150
  end
156
151
 
157
152
  def obj_name
158
- @obj_name ||= args.empty? ? nil : args.join(" ")
153
+ @obj_name ||= args.empty? ? nil : args.join(' ')
159
154
  end
160
155
 
161
156
  def use_line_numbers?
@@ -186,7 +181,7 @@ class Pry
186
181
  prefix, search = [$1, $2]
187
182
  methods = begin
188
183
  Pry::Method.all_from_class(binding.eval(prefix))
189
- rescue RescuableException => e
184
+ rescue RescuableException
190
185
  return super
191
186
  end
192
187
  methods.map do |method|
@@ -18,17 +18,29 @@ class Pry
18
18
  show-source Pry#rep # source for Pry#rep method
19
19
  show-source Pry # for Pry class
20
20
  show-source Pry -a # for all Pry class definitions (all monkey patches)
21
+ show-source Pry.foo -e # for class of the return value of expression `Pry.foo`
21
22
  show-source Pry --super # for superclass of Pry (Object class)
22
23
 
23
24
  https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method
24
25
  BANNER
25
26
 
27
+ def options(opt)
28
+ opt.on :e, :eval, "evaluate the command's argument as a ruby expression and show the class its return value"
29
+ super(opt)
30
+ end
31
+
32
+ def process
33
+ if opts.present?(:e)
34
+ obj = target.eval(args.first)
35
+ self.args = Array.new(1) { Module === obj ? obj.name : obj.class.name }
36
+ end
37
+ super
38
+ end
39
+
26
40
  # The source for code_object prepared for display.
27
41
  def content_for(code_object)
28
- cannot_locate_source_error if !code_object.source
29
-
30
42
  Code.new(code_object.source, start_line_for(code_object)).
31
- with_line_numbers(use_line_numbers?).to_s
43
+ with_line_numbers(use_line_numbers?)
32
44
  end
33
45
  end
34
46