pry 0.11.3-java → 0.12.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +139 -1
  3. data/LICENSE +1 -1
  4. data/README.md +13 -30
  5. data/bin/pry +0 -4
  6. data/lib/pry.rb +17 -47
  7. data/lib/pry/cli.rb +17 -24
  8. data/lib/pry/code.rb +6 -6
  9. data/lib/pry/code/code_file.rb +5 -4
  10. data/lib/pry/code/code_range.rb +3 -3
  11. data/lib/pry/code/loc.rb +14 -8
  12. data/lib/pry/code_object.rb +4 -4
  13. data/lib/pry/color_printer.rb +1 -0
  14. data/lib/pry/command.rb +36 -29
  15. data/lib/pry/command_set.rb +17 -52
  16. data/lib/pry/commands/amend_line.rb +3 -4
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +7 -6
  19. data/lib/pry/commands/cat/exception_formatter.rb +9 -8
  20. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  21. data/lib/pry/commands/change_prompt.rb +29 -9
  22. data/lib/pry/commands/clear_screen.rb +14 -0
  23. data/lib/pry/commands/code_collector.rb +9 -9
  24. data/lib/pry/commands/easter_eggs.rb +3 -3
  25. data/lib/pry/commands/edit.rb +8 -7
  26. data/lib/pry/commands/exit.rb +2 -1
  27. data/lib/pry/commands/find_method.rb +11 -13
  28. data/lib/pry/commands/gem_cd.rb +1 -1
  29. data/lib/pry/commands/gem_install.rb +2 -2
  30. data/lib/pry/commands/gem_list.rb +2 -2
  31. data/lib/pry/commands/gem_open.rb +1 -1
  32. data/lib/pry/commands/gem_search.rb +2 -2
  33. data/lib/pry/commands/gem_stats.rb +83 -0
  34. data/lib/pry/commands/gist.rb +7 -6
  35. data/lib/pry/commands/help.rb +3 -3
  36. data/lib/pry/commands/hist.rb +9 -8
  37. data/lib/pry/commands/import_set.rb +2 -1
  38. data/lib/pry/commands/install_command.rb +7 -6
  39. data/lib/pry/commands/list_inspectors.rb +2 -2
  40. data/lib/pry/commands/ls.rb +27 -30
  41. data/lib/pry/commands/ls/constants.rb +4 -4
  42. data/lib/pry/commands/ls/formatter.rb +3 -2
  43. data/lib/pry/commands/ls/globals.rb +0 -2
  44. data/lib/pry/commands/ls/grep.rb +0 -2
  45. data/lib/pry/commands/ls/instance_vars.rb +0 -1
  46. data/lib/pry/commands/ls/local_names.rb +0 -2
  47. data/lib/pry/commands/ls/local_vars.rb +0 -2
  48. data/lib/pry/commands/ls/ls_entity.rb +0 -1
  49. data/lib/pry/commands/ls/methods.rb +0 -3
  50. data/lib/pry/commands/ls/methods_helper.rb +1 -1
  51. data/lib/pry/commands/ls/self_methods.rb +0 -1
  52. data/lib/pry/commands/play.rb +1 -2
  53. data/lib/pry/commands/pry_backtrace.rb +1 -1
  54. data/lib/pry/commands/raise_up.rb +2 -1
  55. data/lib/pry/commands/ri.rb +5 -4
  56. data/lib/pry/commands/shell_command.rb +3 -2
  57. data/lib/pry/commands/shell_mode.rb +6 -6
  58. data/lib/pry/commands/show_doc.rb +5 -7
  59. data/lib/pry/commands/show_info.rb +25 -18
  60. data/lib/pry/commands/show_source.rb +5 -2
  61. data/lib/pry/commands/stat.rb +1 -1
  62. data/lib/pry/commands/watch_expression.rb +9 -7
  63. data/lib/pry/commands/whereami.rb +4 -4
  64. data/lib/pry/commands/wtf.rb +15 -2
  65. data/lib/pry/config.rb +33 -9
  66. data/lib/pry/config/behavior.rb +229 -205
  67. data/lib/pry/config/convenience.rb +24 -21
  68. data/lib/pry/config/default.rb +153 -143
  69. data/lib/pry/config/memoization.rb +41 -37
  70. data/lib/pry/core_extensions.rb +4 -3
  71. data/lib/pry/editor.rb +5 -12
  72. data/lib/pry/exceptions.rb +0 -2
  73. data/lib/pry/helpers.rb +1 -0
  74. data/lib/pry/helpers/base_helpers.rb +133 -4
  75. data/lib/pry/helpers/command_helpers.rb +5 -4
  76. data/lib/pry/helpers/documentation_helpers.rb +2 -2
  77. data/lib/pry/helpers/options_helpers.rb +5 -5
  78. data/lib/pry/helpers/platform.rb +58 -0
  79. data/lib/pry/helpers/table.rb +20 -15
  80. data/lib/pry/helpers/text.rb +3 -4
  81. data/lib/pry/history.rb +21 -8
  82. data/lib/pry/hooks.rb +3 -3
  83. data/lib/pry/indent.rb +15 -17
  84. data/lib/pry/input_completer.rb +12 -7
  85. data/lib/pry/input_lock.rb +0 -2
  86. data/lib/pry/last_exception.rb +1 -1
  87. data/lib/pry/method.rb +37 -31
  88. data/lib/pry/method/disowned.rb +2 -1
  89. data/lib/pry/method/patcher.rb +2 -2
  90. data/lib/pry/method/weird_method_locator.rb +7 -8
  91. data/lib/pry/object_path.rb +5 -4
  92. data/lib/pry/output.rb +3 -2
  93. data/lib/pry/pager.rb +4 -3
  94. data/lib/pry/platform.rb +79 -81
  95. data/lib/pry/plugins.rb +7 -3
  96. data/lib/pry/prompt.rb +144 -25
  97. data/lib/pry/pry_class.rb +53 -29
  98. data/lib/pry/pry_instance.rb +88 -55
  99. data/lib/pry/repl.rb +33 -4
  100. data/lib/pry/repl_file_loader.rb +1 -2
  101. data/lib/pry/ring.rb +84 -0
  102. data/lib/pry/rubygem.rb +6 -6
  103. data/lib/pry/slop.rb +17 -17
  104. data/lib/pry/slop/commands.rb +3 -4
  105. data/lib/pry/slop/option.rb +19 -21
  106. data/lib/pry/terminal.rb +2 -1
  107. data/lib/pry/testable/mockable.rb +2 -2
  108. data/lib/pry/testable/pry_tester.rb +1 -1
  109. data/lib/pry/testable/utility.rb +2 -2
  110. data/lib/pry/testable/variables.rb +1 -1
  111. data/lib/pry/version.rb +1 -1
  112. data/lib/pry/wrapped_module.rb +15 -15
  113. data/lib/pry/wrapped_module/candidate.rb +2 -2
  114. metadata +19 -31
  115. data/lib/pry/commands/list_prompts.rb +0 -35
  116. data/lib/pry/commands/simple_prompt.rb +0 -22
  117. data/lib/pry/history_array.rb +0 -121
  118. data/lib/pry/rbx_path.rb +0 -22
@@ -3,7 +3,7 @@ class Pry
3
3
  match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
4
4
  group 'Editing'
5
5
  description 'Amend a line of input in multi-line mode.'
6
- command_options :interpolate => false, :listing => 'amend-line'
6
+ command_options interpolate: false, listing: 'amend-line'
7
7
 
8
8
  banner <<-'BANNER'
9
9
  Amend a line of input in multi-line mode. `amend-line N`, where the N represents
@@ -19,16 +19,15 @@ class Pry
19
19
  def process
20
20
  raise CommandError, "No input to amend." if eval_string.empty?
21
21
 
22
- eval_string.replace amended_input(eval_string)
22
+ eval_string.replace(amend_input)
23
23
  run "fix-indent"
24
24
  run "show-input"
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- # @param [String] string The string to amend.
30
29
  # @return [String] A new string with the amendments applied to it.
31
- def amended_input(string)
30
+ def amend_input
32
31
  input_array = eval_string.each_line.to_a
33
32
 
34
33
  if arg_string == "!"
@@ -3,7 +3,7 @@ class Pry
3
3
  match(/^\s*!\s*$/)
4
4
  group 'Editing'
5
5
  description 'Clear the input buffer.'
6
- command_options :use_prefix => false
6
+ command_options use_prefix: false
7
7
 
8
8
  banner <<-'BANNER'
9
9
  Clear the input buffer. Useful if the parsing process goes wrong and you get
@@ -23,12 +23,12 @@ class Pry
23
23
  BANNER
24
24
 
25
25
  def options(opt)
26
- opt.on :ex, "Show the context of the last exception", :optional_argument => true, :as => Integer
27
- opt.on :i, :in, "Show one or more entries from Pry's expression history", :optional_argument => true, :as => Range, :default => -5..-1
28
- opt.on :s, :start, "Starting line (defaults to the first line)", :optional_argument => true, :as => Integer
29
- opt.on :e, :end, "Ending line (defaults to the last line)", :optional_argument => true, :as => Integer
26
+ opt.on :ex, "Show the context of the last exception", optional_argument: true, as: Integer
27
+ opt.on :i, :in, "Show one or more entries from Pry's expression history", optional_argument: true, as: Range, default: -5..-1
28
+ opt.on :s, :start, "Starting line (defaults to the first line)", optional_argument: true, as: Integer
29
+ opt.on :e, :end, "Ending line (defaults to the last line)", optional_argument: true, as: Integer
30
30
  opt.on :l, :'line-numbers', "Show line numbers"
31
- opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", :argument => true, :as => Symbol
31
+ opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", argument: true, as: Symbol
32
32
  end
33
33
 
34
34
  def process
@@ -36,7 +36,7 @@ class Pry
36
36
  when opts.present?(:ex)
37
37
  ExceptionFormatter.new(_pry_.last_exception, _pry_, opts).format
38
38
  when opts.present?(:in)
39
- InputExpressionFormatter.new(_pry_.input_array, opts).format
39
+ InputExpressionFormatter.new(_pry_.input_ring, opts).format
40
40
  else
41
41
  FileFormatter.new(args.first, _pry_, opts).format
42
42
  end
@@ -52,6 +52,7 @@ class Pry
52
52
  $LOAD_PATH.flat_map do |path|
53
53
  Dir[path + '/**/*'].map { |f|
54
54
  next if File.directory?(f)
55
+
55
56
  f.sub!(path + '/', '')
56
57
  }
57
58
  end
@@ -4,6 +4,7 @@ class Pry
4
4
  attr_reader :ex
5
5
  attr_reader :opts
6
6
  attr_reader :_pry_
7
+ include Pry::Helpers::Text
7
8
 
8
9
  def initialize(exception, _pry_, opts)
9
10
  @ex = exception
@@ -29,11 +30,12 @@ class Pry
29
30
  def backtrace_level
30
31
  @backtrace_level ||=
31
32
  begin
32
- bl = if opts[:ex].nil?
33
- ex.bt_index
34
- else
35
- ex.bt_index = absolute_index_number(opts[:ex], ex.backtrace.size)
36
- end
33
+ bl =
34
+ if opts[:ex].nil?
35
+ ex.bt_index
36
+ else
37
+ ex.bt_index = absolute_index_number(opts[:ex], ex.backtrace.size)
38
+ end
37
39
 
38
40
  increment_backtrace_level
39
41
  bl
@@ -66,13 +68,12 @@ class Pry
66
68
 
67
69
  def header
68
70
  unindent %{
69
- #{Helpers::Text.bold 'Exception:'} #{ex.class}: #{ex.message}
71
+ #{bold 'Exception:'} #{ex.class}: #{ex.message}
70
72
  --
71
- #{Helpers::Text.bold('From:')} #{backtrace_file} @ line #{backtrace_line} @ #{Helpers::Text.bold("level: #{backtrace_level}")} of backtrace (of #{ex.backtrace.size - 1}).
73
+ #{bold('From:')} #{backtrace_file} @ line #{backtrace_line} @ #{bold("level: #{backtrace_level}")} of backtrace (of #{ex.backtrace.size - 1}).
72
74
 
73
75
  }
74
76
  end
75
-
76
77
  end
77
78
  end
78
79
  end
@@ -36,7 +36,7 @@ class Pry
36
36
  end
37
37
 
38
38
  def normalized_expression_range
39
- absolute_index_range(opts[:i], input_expressions.length)
39
+ absolute_index_range(opts[:i], input_expressions.count)
40
40
  end
41
41
  end
42
42
  end
@@ -4,23 +4,43 @@ class Pry::Command::ChangePrompt < Pry::ClassCommand
4
4
  description 'Change the current prompt.'
5
5
  command_options argument_required: true
6
6
  banner <<-BANNER
7
- Usage: change-prompt NAME
7
+ Usage: change-prompt [OPTIONS] [NAME]
8
8
 
9
- Change the current prompt. See list-prompts for a list of available
10
- prompts.
9
+ Change the current prompt.
11
10
  BANNER
12
11
 
12
+ def options(opt)
13
+ opt.on(:l, :list, 'List the available prompts')
14
+ end
15
+
13
16
  def process(prompt)
14
- if prompt_map.key?(prompt)
15
- _pry_.prompt = prompt_map[prompt][:value]
17
+ if opts.present?(:l)
18
+ list_prompts
16
19
  else
17
- raise Pry::CommandError, "'#{prompt}' isn't a known prompt!"
20
+ change_prompt(prompt)
18
21
  end
19
22
  end
20
23
 
21
- private
22
- def prompt_map
23
- Pry::Prompt::MAP
24
+ private
25
+
26
+ def list_prompts
27
+ prompts = Pry::Prompt.all.map do |name, prompt|
28
+ "#{bold(name)}#{red(' (selected)') if _pry_.prompt == prompt[:value]}\n" +
29
+ prompt[:description]
30
+ end
31
+ output.puts(prompts.join("\n"))
24
32
  end
33
+
34
+ def change_prompt(prompt)
35
+ if Pry::Prompt.all.key?(prompt)
36
+ _pry_.prompt = Pry::Prompt.all[prompt][:value]
37
+ else
38
+ raise(Pry::CommandError, <<MSG)
39
+ '#{prompt}' isn't a known prompt. Run `change-prompt --list` to see
40
+ the list of known prompts.
41
+ MSG
42
+ end
43
+ end
44
+
25
45
  Pry::Commands.add_command(self)
26
46
  end
@@ -0,0 +1,14 @@
1
+ class Pry::Command::ClearScreen < Pry::ClassCommand
2
+ match 'clear-screen'
3
+ group 'Input and Output'
4
+ description 'Clear the contents of the screen/window Pry is running in.'
5
+
6
+ def process
7
+ if Helpers::Platform.windows?
8
+ _pry_.config.system.call(_pry_.output, 'cls', _pry_)
9
+ else
10
+ _pry_.config.system.call(_pry_.output, 'clear', _pry_)
11
+ end
12
+ end
13
+ Pry::Commands.add_command(self)
14
+ end
@@ -29,17 +29,17 @@ class Pry
29
29
  @output_result_ranges = []
30
30
 
31
31
  opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range",
32
- :optional_argument => true, :as => Range, :default => 1..-1
32
+ optional_argument: true, as: Range, default: 1..-1
33
33
  opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
34
- :optional_argument => true, :as => Range, :default => -5..-1 do |r|
34
+ optional_argument: true, as: Range, default: -5..-1 do |r|
35
35
  output_result_ranges << (r || (-5..-1))
36
36
  end
37
37
  opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
38
- :optional_argument => true, :as => Range, :default => -5..-1 do |r|
38
+ optional_argument: true, as: Range, default: -5..-1 do |r|
39
39
  input_expression_ranges << (r || (-5..-1))
40
40
  end
41
41
  opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
42
- :as => :count
42
+ as: :count
43
43
  opt.on :d, :doc, "Select lines from the code object's documentation"
44
44
  end
45
45
 
@@ -74,7 +74,7 @@ class Pry
74
74
  #
75
75
  # @return [Pry::WrappedModule, Pry::Method, Pry::Command]
76
76
  def code_object
77
- Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super])
77
+ Pry::CodeObject.lookup(obj_name, _pry_, super: opts[:super])
78
78
  end
79
79
 
80
80
  # Given a string and a range, return the `range` lines of that
@@ -87,22 +87,22 @@ class Pry
87
87
  Array(content.lines.to_a[range]).join
88
88
  end
89
89
 
90
- # The selected `_pry_.output_array` as a string, as specified by
90
+ # The selected `_pry_.output_ring` as a string, as specified by
91
91
  # the `-o` switch.
92
92
  #
93
93
  # @return [String]
94
94
  def pry_output_content
95
- pry_array_content_as_string(_pry_.output_array, self.class.output_result_ranges) do |v|
95
+ pry_array_content_as_string(_pry_.output_ring, self.class.output_result_ranges) do |v|
96
96
  _pry_.config.gist.inspecter.call(v)
97
97
  end
98
98
  end
99
99
 
100
- # The selected `_pry_.input_array` as a string, as specified by
100
+ # The selected `_pry_.input_ring` as a string, as specified by
101
101
  # the `-i` switch.
102
102
  #
103
103
  # @return [String]
104
104
  def pry_input_content
105
- pry_array_content_as_string(_pry_.input_array, self.class.input_expression_ranges) { |v| v }
105
+ pry_array_content_as_string(_pry_.input_ring, self.class.input_expression_ranges) { |v| v }
106
106
  end
107
107
 
108
108
  # The line range passed to `--lines`, converted to a 0-indexed range.
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
  Pry::Commands.instance_eval do
3
- command "nyan-cat", "", :requires_gem => ["nyancat"] do
3
+ command "nyan-cat", "", requires_gem: ["nyancat"] do
4
4
  run ".nyancat"
5
5
  end
6
6
 
@@ -86,7 +86,7 @@ TEXT
86
86
  prev_color = _pry_.config.color
87
87
  _pry_.config.color = true
88
88
 
89
- picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| text.red(s) }
89
+ picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| red(s) }
90
90
  ____ _______________________
91
91
  / \ | A W G |
92
92
  / O O \ | N I O N ! |
@@ -95,7 +95,7 @@ TEXT
95
95
  \____/ \________________________|
96
96
  EOS
97
97
 
98
- if windows_ansi?
98
+ if Helpers::Platform.windows_ansi?
99
99
  move_up = proc { |n| "\e[#{n}F" }
100
100
  else
101
101
  move_up = proc { |n| "\e[#{n}A\e[0G" }
@@ -24,12 +24,12 @@ class Pry
24
24
 
25
25
  def options(opt)
26
26
  opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
27
- :optional_argument => true, :as => Integer
27
+ optional_argument: true, as: Integer
28
28
  opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
29
- :optional_argument => true, :as => Range, :default => -1..-1
29
+ optional_argument: true, as: Range, default: -1..-1
30
30
  opt.on :t, :temp, "Open an empty temporary file"
31
31
  opt.on :l, :line, "Jump to this line in the opened file",
32
- :argument => true, :as => Integer
32
+ argument: true, as: Integer
33
33
  opt.on :n, :"no-reload", "Don't automatically reload the edited file"
34
34
  opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
35
35
  opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
@@ -65,6 +65,7 @@ class Pry
65
65
  silence_warnings do
66
66
  eval_string.replace content
67
67
  end
68
+ Pry.history.push(content)
68
69
  end
69
70
 
70
71
  def file_based_exception?
@@ -156,9 +157,9 @@ class Pry
156
157
  def input_expression
157
158
  case opts[:i]
158
159
  when Range
159
- (_pry_.input_array[opts[:i]] || []).join
160
+ (_pry_.input_ring[opts[:i]] || []).join
160
161
  when Integer
161
- _pry_.input_array[opts[:i]] || ""
162
+ _pry_.input_ring[opts[:i]] || ""
162
163
  else
163
164
  raise Pry::CommandError, "Not a valid range: #{opts[:i]}"
164
165
  end
@@ -172,7 +173,7 @@ class Pry
172
173
  opts.present?(:'no-reload') || _pry_.config.disable_auto_reload
173
174
  end
174
175
 
175
- def reload?(file_name="")
176
+ def reload?(file_name = "")
176
177
  (reloadable? || file_name.end_with?(".rb")) && !never_reload?
177
178
  end
178
179
 
@@ -185,7 +186,7 @@ class Pry
185
186
  when eval_string.strip != ""
186
187
  eval_string
187
188
  else
188
- _pry_.input_array.reverse_each.find { |x| x && x.strip != "" } || ""
189
+ _pry_.input_ring.to_a.reverse_each.find { |x| x && x.strip != "" } || ""
189
190
  end
190
191
  end
191
192
 
@@ -3,7 +3,7 @@ class Pry
3
3
  match 'exit'
4
4
  group 'Navigating Pry'
5
5
  description 'Pop the previous binding.'
6
- command_options :keep_retval => true
6
+ command_options keep_retval: true
7
7
 
8
8
  banner <<-'BANNER'
9
9
  Usage: exit [OPTIONS] [--help]
@@ -33,6 +33,7 @@ class Pry
33
33
 
34
34
  # return a user-specified value if given otherwise return the object
35
35
  return target.eval(arg_string) unless arg_string.empty?
36
+
36
37
  popped_object
37
38
  end
38
39
  end
@@ -5,7 +5,7 @@ class Pry
5
5
  match 'find-method'
6
6
  group 'Context'
7
7
  description 'Recursively search for a method within a Class/Module or the current namespace.'
8
- command_options :shellwords => false
8
+ command_options shellwords: false
9
9
 
10
10
  banner <<-'BANNER'
11
11
  Usage: find-method [-n|-c] METHOD [NAMESPACE]
@@ -31,14 +31,10 @@ class Pry
31
31
 
32
32
  def process
33
33
  return if args.size < 1
34
- klass = search_class
35
34
 
36
- matches = if opts.content?
37
- content_search(klass)
38
- else
39
- name_search(klass)
40
- end
35
+ klass = search_class
41
36
 
37
+ matches = opts.content? ? content_search(klass) : name_search(klass)
42
38
  show_search_results(matches)
43
39
  end
44
40
 
@@ -54,7 +50,7 @@ class Pry
54
50
  # @param [Array] matches
55
51
  def show_search_results(matches)
56
52
  if matches.empty?
57
- output.puts text.bold("No Methods Matched")
53
+ output.puts bold("No Methods Matched")
58
54
  else
59
55
  print_matches(matches)
60
56
  end
@@ -79,7 +75,7 @@ class Pry
79
75
  # @param [Array<Method>] matches
80
76
  def print_matches(matches)
81
77
  grouped = matches.group_by(&:owner)
82
- order = grouped.keys.sort_by{ |x| x.name || x.to_s }
78
+ order = grouped.keys.sort_by { |x| x.name || x.to_s }
83
79
 
84
80
  order.each do |klass|
85
81
  print_matches_for_class(klass, grouped)
@@ -88,7 +84,7 @@ class Pry
88
84
 
89
85
  # Print matched methods for a class
90
86
  def print_matches_for_class(klass, grouped)
91
- output.puts text.bold(klass.name)
87
+ output.puts bold(klass.name)
92
88
  grouped[klass].each do |method|
93
89
  header = method.name_with_owner
94
90
  output.puts header + additional_info(header, method)
@@ -106,7 +102,7 @@ class Pry
106
102
  end
107
103
 
108
104
  def matched_method_lines(header, method)
109
- method.source.split(/\n/).select {|x| x =~ pattern }.join("\n#{' ' * header.length}")
105
+ method.source.split(/\n/).select { |x| x =~ pattern }.join("\n#{' ' * header.length}")
110
106
  end
111
107
 
112
108
  # Run the given block against every constant in the provided namespace.
@@ -115,7 +111,7 @@ class Pry
115
111
  # @param [Hash<Module,Boolean>] done The namespaces we've already visited (private)
116
112
  # @yieldparam klass Each class/module in the namespace.
117
113
  #
118
- def recurse_namespace(klass, done={}, &block)
114
+ def recurse_namespace(klass, done = {}, &block)
119
115
  return if !(Module === klass) || done[klass]
120
116
 
121
117
  done[klass] = true
@@ -124,6 +120,7 @@ class Pry
124
120
 
125
121
  klass.constants.each do |name|
126
122
  next if klass.autoload?(name)
123
+
127
124
  begin
128
125
  const = klass.const_get(name)
129
126
  rescue RescuableException
@@ -145,12 +142,13 @@ class Pry
145
142
  # @return [Array<Method>]
146
143
  #
147
144
  def search_all_methods(namespace)
148
- done = Hash.new{ |h,k| h[k] = {} }
145
+ done = Hash.new { |h,k| h[k] = {} }
149
146
  matches = []
150
147
 
151
148
  recurse_namespace(namespace) do |klass|
152
149
  (Pry::Method.all_from_class(klass) + Pry::Method.all_from_obj(klass)).each do |method|
153
150
  next if done[method.owner][method.name]
151
+
154
152
  done[method.owner][method.name] = true
155
153
 
156
154
  matches << method if yield method
@@ -3,7 +3,7 @@ class Pry
3
3
  match 'gem-cd'
4
4
  group 'Gems'
5
5
  description "Change working directory to specified gem's directory."
6
- command_options :argument_required => true
6
+ command_options argument_required: true
7
7
 
8
8
  banner <<-'BANNER'
9
9
  Usage: gem-cd GEM_NAME
@@ -3,7 +3,7 @@ class Pry
3
3
  match 'gem-install'
4
4
  group 'Gems'
5
5
  description 'Install a gem and refresh the gem cache.'
6
- command_options :argument_required => true
6
+ command_options argument_required: true
7
7
 
8
8
  banner <<-'BANNER'
9
9
  Usage: gem-install GEM_NAME
@@ -20,7 +20,7 @@ class Pry
20
20
 
21
21
  def process(gem)
22
22
  Rubygem.install(gem)
23
- output.puts "Gem `#{ text.green(gem) }` installed."
23
+ output.puts "Gem `#{ green(gem) }` installed."
24
24
  require gem
25
25
  rescue LoadError
26
26
  require_path = gem.split('-').join('/')