pry 0.9.12.6-i386-mingw32 → 0.10.0-i386-mingw32

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
@@ -1,31 +1,32 @@
1
1
  class Pry
2
2
  class Command::Cat
3
3
  class FileFormatter < AbstractFormatter
4
- attr_accessor :file_with_embedded_line
5
- attr_accessor :opts
6
- attr_accessor :_pry_
4
+ attr_reader :file_with_embedded_line
5
+ attr_reader :opts
6
+ attr_reader :_pry_
7
7
 
8
8
  def initialize(file_with_embedded_line, _pry_, opts)
9
9
  @file_with_embedded_line = file_with_embedded_line
10
10
  @opts = opts
11
11
  @_pry_ = _pry_
12
+ @code_from_file = Pry::Code.from_file(file_name)
12
13
  end
13
14
 
14
15
  def format
15
16
  raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line
16
17
 
17
18
  set_file_and_dir_locals(file_name, _pry_, _pry_.current_context)
18
- decorate(Pry::Code.from_file(file_name))
19
+ decorate(@code_from_file)
19
20
  end
20
21
 
21
- private
22
-
23
22
  def file_and_line
24
- file_name, line_num = file_with_embedded_line.split(':')
23
+ file_name, line_num = file_with_embedded_line.split(/:(?!\/|\\)/)
25
24
 
26
- [File.expand_path(file_name), line_num ? line_num.to_i : nil]
25
+ [file_name, line_num ? line_num.to_i : nil]
27
26
  end
28
27
 
28
+ private
29
+
29
30
  def file_name
30
31
  file_and_line.first
31
32
  end
@@ -35,7 +36,7 @@ class Pry
35
36
  end
36
37
 
37
38
  def code_window_size
38
- Pry.config.default_window_size || 7
39
+ _pry_.config.default_window_size || 7
39
40
  end
40
41
 
41
42
  def decorate(content)
@@ -47,36 +48,18 @@ class Pry
47
48
  end
48
49
 
49
50
  def detect_code_type_from_file(file_name)
50
- name, ext = File.basename(file_name).split('.', 2)
51
+ code_type = @code_from_file.code_type
51
52
 
52
- if ext
53
- case ext
54
- when "py"
55
- :python
56
- when "rb", "gemspec", "rakefile", "ru", "pryrc", "irbrc"
57
- :ruby
58
- when "js"
59
- return :javascript
60
- when "yml", "prytheme"
61
- :yaml
62
- when "groovy"
63
- :groovy
64
- when "c"
65
- :c
66
- when "cpp"
67
- :cpp
68
- when "java"
69
- :java
70
- else
71
- :text
72
- end
73
- else
53
+ if code_type == :unknown
54
+ name, ext = File.basename(file_name).split('.', 2)
74
55
  case name
75
56
  when "Rakefile", "Gemfile"
76
57
  :ruby
77
58
  else
78
59
  :text
79
60
  end
61
+ else
62
+ code_type
80
63
  end
81
64
  end
82
65
  end
@@ -20,7 +20,7 @@ class Pry
20
20
 
21
21
  content
22
22
  else
23
- decorate(Pry::Code(selected_input_items.first)).to_s
23
+ decorate(Pry::Code(selected_input_items.first))
24
24
  end
25
25
  end
26
26
 
@@ -9,7 +9,7 @@ class Pry
9
9
 
10
10
  Move into new context (object or scope). As in UNIX shells use `cd ..` to go
11
11
  back, `cd /` to return to Pry top-level and `cd -` to toggle between last two
12
- scopes. Complex syntax (e.g `cd ../@x/y`) also supported.
12
+ scopes. Complex syntax (e.g `cd ../@x/@y`) also supported.
13
13
 
14
14
  cd @x
15
15
  cd ..
@@ -21,8 +21,19 @@ class Pry
21
21
 
22
22
  def process
23
23
  state.old_stack ||= []
24
- stack, state.old_stack = context_from_object_path(arg_string, _pry_, state.old_stack)
25
- _pry_.binding_stack = stack if stack
24
+
25
+ if arg_string.strip == "-"
26
+ unless state.old_stack.empty?
27
+ _pry_.binding_stack, state.old_stack = state.old_stack, _pry_.binding_stack
28
+ end
29
+ else
30
+ stack = ObjectPath.new(arg_string, _pry_.binding_stack).resolve
31
+
32
+ if stack && stack != _pry_.binding_stack
33
+ state.old_stack = _pry_.binding_stack
34
+ _pry_.binding_stack = stack
35
+ end
36
+ end
26
37
  end
27
38
  end
28
39
 
@@ -0,0 +1,27 @@
1
+ class Pry::Command::ChangeInspector < Pry::ClassCommand
2
+ match 'change-inspector'
3
+ group 'Input and Output'
4
+ description 'Change the current inspector proc.'
5
+ command_options argument_required: true
6
+ banner <<-BANNER
7
+ Usage: change-inspector NAME
8
+
9
+ Change the proc used to print return values. See list-inspectors for a list
10
+ of available procs and a short description of what each one does.
11
+ BANNER
12
+
13
+ def process(inspector)
14
+ if inspector_map.key?(inspector)
15
+ _pry_.print = inspector_map[inspector][:value]
16
+ output.puts "Switched to the '#{inspector}' inspector!"
17
+ else
18
+ raise Pry::CommandError, "'#{inspector}' isn't a known inspector!"
19
+ end
20
+ end
21
+
22
+ private
23
+ def inspector_map
24
+ Pry::Inspector::MAP
25
+ end
26
+ Pry::Commands.add_command(self)
27
+ end
@@ -0,0 +1,26 @@
1
+ class Pry::Command::ChangePrompt < Pry::ClassCommand
2
+ match 'change-prompt'
3
+ group 'Input and Output'
4
+ description 'Change the current prompt.'
5
+ command_options argument_required: true
6
+ banner <<-BANNER
7
+ Usage: change-prompt NAME
8
+
9
+ Change the current prompt. See list-prompts for a list of available
10
+ prompts.
11
+ BANNER
12
+
13
+ def process(prompt)
14
+ if prompt_map.key?(prompt)
15
+ _pry_.prompt = prompt_map[prompt][:value]
16
+ else
17
+ raise Pry::CommandError, "'#{prompt}' isn't a known prompt!"
18
+ end
19
+ end
20
+
21
+ private
22
+ def prompt_map
23
+ Pry::Prompt::MAP
24
+ end
25
+ Pry::Commands.add_command(self)
26
+ end
@@ -2,9 +2,9 @@ class Pry
2
2
  class Command::CodeCollector
3
3
  include Helpers::CommandHelpers
4
4
 
5
- attr_accessor :args
6
- attr_accessor :opts
7
- attr_accessor :_pry_
5
+ attr_reader :args
6
+ attr_reader :opts
7
+ attr_reader :_pry_
8
8
 
9
9
  # The name of the explicitly given file (if any).
10
10
  attr_accessor :file
@@ -91,7 +91,7 @@ class Pry
91
91
  # @return [String]
92
92
  def pry_output_content
93
93
  pry_array_content_as_string(_pry_.output_array, self.class.output_result_ranges) do |v|
94
- Pry.config.gist.inspecter.call(v)
94
+ _pry_.config.gist.inspecter.call(v)
95
95
  end
96
96
  end
97
97
 
@@ -83,8 +83,8 @@ TEXT
83
83
  end
84
84
 
85
85
  command "test-ansi", "" do
86
- prev_color = Pry.color
87
- Pry.color = true
86
+ prev_color = _pry_.config.color
87
+ _pry_.config.color = true
88
88
 
89
89
  picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| text.red(s) }
90
90
  ____ _______________________
@@ -106,7 +106,7 @@ TEXT
106
106
  output.puts "\n" * 6
107
107
  output.puts "** ENV['TERM'] is #{ENV['TERM']} **\n\n"
108
108
 
109
- Pry.color = prev_color
109
+ _pry_.config.color = prev_color
110
110
  end
111
111
  end
112
112
  end
@@ -1,6 +1,5 @@
1
1
  class Pry
2
2
  class Command::Edit < Pry::ClassCommand
3
- require 'pry/commands/edit/method_patcher'
4
3
  require 'pry/commands/edit/exception_patcher'
5
4
  require 'pry/commands/edit/file_and_line_locator'
6
5
 
@@ -13,7 +12,7 @@ class Pry
13
12
 
14
13
  Open a text editor. When no FILE is given, edits the pry input buffer.
15
14
  When a method/module/command is given, the code is opened in an editor.
16
- Ensure `Pry.config.editor` is set to your editor of choice.
15
+ Ensure `Pry.config.editor` or `_pry_.config.editor` is set to your editor of choice.
17
16
 
18
17
  edit sample.rb edit -p MyClass#my_method
19
18
  edit sample.rb --line 105 edit MyClass
@@ -31,7 +30,7 @@ class Pry
31
30
  opt.on :t, :temp, "Open an empty temporary file"
32
31
  opt.on :l, :line, "Jump to this line in the opened file",
33
32
  :argument => true, :as => Integer
34
- opt.on :n, :"no-reload", "Don't automatically reload the edited code"
33
+ opt.on :n, :"no-reload", "Don't automatically reload the edited file"
35
34
  opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
36
35
  opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
37
36
  opt.on :p, :patch, "Instead of editing the object's file, try to edit in a tempfile and apply as a monkey patch"
@@ -61,12 +60,10 @@ class Pry
61
60
  end
62
61
 
63
62
  def repl_edit
64
- content = Pry::Editor.edit_tempfile_with_content(initial_temp_file_content,
63
+ content = Pry::Editor.new(_pry_).edit_tempfile_with_content(initial_temp_file_content,
65
64
  initial_temp_file_content.lines.count)
66
- if repl_reload?
67
- silence_warnings do
68
- eval_string.replace content
69
- end
65
+ silence_warnings do
66
+ eval_string.replace content
70
67
  end
71
68
  end
72
69
 
@@ -83,7 +80,7 @@ class Pry
83
80
  ExceptionPatcher.new(_pry_, state, file_and_line_for_current_exception).perform_patch
84
81
  else
85
82
  if code_object.is_a?(Pry::Method)
86
- MethodPatcher.new(_pry_, code_object).perform_patch
83
+ code_object.redefine Pry::Editor.new(_pry_).edit_tempfile_with_content(code_object.source)
87
84
  else
88
85
  raise NotImplementedError, "Cannot yet patch #{code_object} objects!"
89
86
  end
@@ -119,12 +116,12 @@ class Pry
119
116
 
120
117
  ensure_file_name_is_valid(file_name)
121
118
 
122
- Pry::Editor.invoke_editor(file_name, line, reload?(file_name))
119
+ Pry::Editor.new(_pry_).invoke_editor(file_name, line, reload?(file_name))
123
120
  set_file_and_dir_locals(file_name)
124
121
 
125
122
  if reload?(file_name)
126
123
  silence_warnings do
127
- TOPLEVEL_BINDING.eval(File.read(file_name), file_name)
124
+ load file_name
128
125
  end
129
126
  end
130
127
  end
@@ -168,12 +165,7 @@ class Pry
168
165
  end
169
166
 
170
167
  def never_reload?
171
- opts.present?(:'no-reload') || Pry.config.disable_auto_reload
172
- end
173
-
174
- # conditions much less strict than for reload? (which is for file-based reloads)
175
- def repl_reload?
176
- !never_reload?
168
+ opts.present?(:'no-reload') || _pry_.config.disable_auto_reload
177
169
  end
178
170
 
179
171
  def reload?(file_name="")
@@ -194,13 +186,9 @@ class Pry
194
186
  end
195
187
 
196
188
  def probably_a_file?(str)
197
- [".rb", ".c", ".py", ".yml", ".gemspec"].include? File.extname(str) ||
189
+ [".rb", ".c", ".py", ".yml", ".gemspec"].include?(File.extname(str)) ||
198
190
  str =~ /\/|\\/
199
191
  end
200
-
201
- def complete(search)
202
- super + Bond::Rc.files(search.split(" ").last || '')
203
- end
204
192
  end
205
193
 
206
194
  Pry::Commands.add_command(Pry::Command::Edit)
@@ -13,10 +13,10 @@ class Pry
13
13
 
14
14
  # perform the patch
15
15
  def perform_patch
16
- file_name, line = file_and_line
16
+ file_name, _ = file_and_line
17
17
  lines = state.dynamical_ex_file || File.read(file_name)
18
18
 
19
- source = Pry::Editor.edit_tempfile_with_content(lines)
19
+ source = Pry::Editor.new(_pry_).edit_tempfile_with_content(lines)
20
20
  _pry_.evaluate_ruby source
21
21
  state.dynamical_ex_file = source.split("\n")
22
22
  end
@@ -21,8 +21,6 @@ class Pry
21
21
  raise CommandError, "Exception has no associated file." if file_name.nil?
22
22
  raise CommandError, "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
23
23
 
24
- file_name = RbxPath.convert_path_to_full(file_name) if RbxPath.is_core_path?(file_name)
25
-
26
24
  [file_name, line]
27
25
  end
28
26
 
@@ -13,7 +13,6 @@ class Pry
13
13
  BANNER
14
14
 
15
15
  def process
16
- Pry.save_history if Pry.config.history.should_save
17
16
  Kernel.exit target.eval(arg_string).to_i
18
17
  end
19
18
  end
@@ -6,8 +6,6 @@ class Pry
6
6
  group 'Context'
7
7
  description 'Recursively search for a method within a Class/Module or the current namespace.'
8
8
  command_options :shellwords => false
9
- command_options :requires_gem => 'ruby18_source_location' if mri_18?
10
-
11
9
 
12
10
  banner <<-'BANNER'
13
11
  Usage: find-method [-n|-c] METHOD [NAMESPACE]
@@ -26,13 +24,9 @@ class Pry
26
24
  find-method -c 'output.puts' Pry
27
25
  BANNER
28
26
 
29
- def setup
30
- require 'ruby18_source_location' if mri_18?
31
- end
32
-
33
- def options(opti)
34
- opti.on :n, :name, "Search for a method by name"
35
- opti.on :c, :content, "Search for a method based on content in Regex form"
27
+ def options(opt)
28
+ opt.on :n, :name, "Search for a method by name"
29
+ opt.on :c, :content, "Search for a method based on content in Regex form"
36
30
  end
37
31
 
38
32
  def process
@@ -82,7 +76,7 @@ class Pry
82
76
 
83
77
  # pretty-print a list of matching methods.
84
78
  #
85
- # @param Array[Method]
79
+ # @param [Array<Method>] matches
86
80
  def print_matches(matches)
87
81
  grouped = matches.group_by(&:owner)
88
82
  order = grouped.keys.sort_by{ |x| x.name || x.to_s }
@@ -105,7 +99,7 @@ class Pry
105
99
  # if `-c` was not given
106
100
  def additional_info(header, method)
107
101
  if opts.content?
108
- ": " + colorize_code(matched_method_lines(header, method))
102
+ ": " << colorize_code(matched_method_lines(header, method))
109
103
  else
110
104
  ""
111
105
  end
@@ -117,9 +111,9 @@ class Pry
117
111
 
118
112
  # Run the given block against every constant in the provided namespace.
119
113
  #
120
- # @param Module The namespace in which to start the search.
121
- # @param Hash[Module,Boolean] The namespaces we've already visited (private)
122
- # @yieldparam klazz Each class/module in the namespace.
114
+ # @param [Module] klass The namespace in which to start the search.
115
+ # @param [Hash<Module,Boolean>] done The namespaces we've already visited (private)
116
+ # @yieldparam klass Each class/module in the namespace.
123
117
  #
124
118
  def recurse_namespace(klass, done={}, &block)
125
119
  return if !(Module === klass) || done[klass]
@@ -145,10 +139,10 @@ class Pry
145
139
 
146
140
  # Gather all the methods in a namespace that pass the given block.
147
141
  #
148
- # @param Module The namespace in which to search.
149
- # @yieldparam Method The method to test
150
- # @yieldreturn Boolean
151
- # @return Array[Method]
142
+ # @param [Module] namespace The namespace in which to search.
143
+ # @yieldparam [Method] method The method to test
144
+ # @yieldreturn [Boolean]
145
+ # @return [Array<Method>]
152
146
  #
153
147
  def search_all_methods(namespace)
154
148
  done = Hash.new{ |h,k| h[k] = {} }
@@ -169,8 +163,8 @@ class Pry
169
163
  # Search for all methods with a name that matches the given regex
170
164
  # within a namespace.
171
165
  #
172
- # @param Module The namespace to search
173
- # @return Array[Method]
166
+ # @param [Module] namespace The namespace to search
167
+ # @return [Array<Method>]
174
168
  #
175
169
  def name_search(namespace)
176
170
  search_all_methods(namespace) do |meth|
@@ -181,8 +175,8 @@ class Pry
181
175
  # Search for all methods who's implementation matches the given regex
182
176
  # within a namespace.
183
177
  #
184
- # @param Module The namespace to search
185
- # @return Array[Method]
178
+ # @param [Module] namespace The namespace to search
179
+ # @return [Array<Method>]
186
180
  #
187
181
  def content_search(namespace)
188
182
  search_all_methods(namespace) do |meth|
@@ -8,8 +8,8 @@ class Pry
8
8
  banner <<-'BANNER'
9
9
  Usage: gem-install GEM_NAME
10
10
 
11
- Installs the given gem and refreshes the gem cache so that you can immediately
12
- 'require GEM_FILE'.
11
+ Installs the given gem, refreshes the gem cache, and requires the gem for you
12
+ based on a best guess from the gem name.
13
13
 
14
14
  gem-install pry-stack_explorer
15
15
  BANNER
@@ -22,6 +22,9 @@ class Pry
22
22
  Rubygem.install(gem)
23
23
  output.puts "Gem `#{ text.green(gem) }` installed."
24
24
  require gem
25
+ rescue LoadError
26
+ require_path = gem.split('-').join('/')
27
+ require require_path
25
28
  end
26
29
  end
27
30