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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +139 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry.rb +17 -47
- data/lib/pry/cli.rb +17 -24
- data/lib/pry/code.rb +6 -6
- data/lib/pry/code/code_file.rb +5 -4
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code_object.rb +4 -4
- data/lib/pry/color_printer.rb +1 -0
- data/lib/pry/command.rb +36 -29
- data/lib/pry/command_set.rb +17 -52
- data/lib/pry/commands/amend_line.rb +3 -4
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +7 -6
- data/lib/pry/commands/cat/exception_formatter.rb +9 -8
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/change_prompt.rb +29 -9
- data/lib/pry/commands/clear_screen.rb +14 -0
- data/lib/pry/commands/code_collector.rb +9 -9
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +8 -7
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +11 -13
- data/lib/pry/commands/gem_cd.rb +1 -1
- data/lib/pry/commands/gem_install.rb +2 -2
- data/lib/pry/commands/gem_list.rb +2 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gem_search.rb +2 -2
- data/lib/pry/commands/gem_stats.rb +83 -0
- data/lib/pry/commands/gist.rb +7 -6
- data/lib/pry/commands/help.rb +3 -3
- data/lib/pry/commands/hist.rb +9 -8
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls.rb +27 -30
- data/lib/pry/commands/ls/constants.rb +4 -4
- data/lib/pry/commands/ls/formatter.rb +3 -2
- data/lib/pry/commands/ls/globals.rb +0 -2
- data/lib/pry/commands/ls/grep.rb +0 -2
- data/lib/pry/commands/ls/instance_vars.rb +0 -1
- data/lib/pry/commands/ls/local_names.rb +0 -2
- data/lib/pry/commands/ls/local_vars.rb +0 -2
- data/lib/pry/commands/ls/ls_entity.rb +0 -1
- data/lib/pry/commands/ls/methods.rb +0 -3
- data/lib/pry/commands/ls/methods_helper.rb +1 -1
- data/lib/pry/commands/ls/self_methods.rb +0 -1
- data/lib/pry/commands/play.rb +1 -2
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/ri.rb +5 -4
- data/lib/pry/commands/shell_command.rb +3 -2
- data/lib/pry/commands/shell_mode.rb +6 -6
- data/lib/pry/commands/show_doc.rb +5 -7
- data/lib/pry/commands/show_info.rb +25 -18
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +4 -4
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config.rb +33 -9
- data/lib/pry/config/behavior.rb +229 -205
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +153 -143
- data/lib/pry/config/memoization.rb +41 -37
- data/lib/pry/core_extensions.rb +4 -3
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +0 -2
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +133 -4
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +2 -2
- data/lib/pry/helpers/options_helpers.rb +5 -5
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +3 -4
- data/lib/pry/history.rb +21 -8
- data/lib/pry/hooks.rb +3 -3
- data/lib/pry/indent.rb +15 -17
- data/lib/pry/input_completer.rb +12 -7
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +1 -1
- data/lib/pry/method.rb +37 -31
- data/lib/pry/method/disowned.rb +2 -1
- data/lib/pry/method/patcher.rb +2 -2
- data/lib/pry/method/weird_method_locator.rb +7 -8
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +4 -3
- data/lib/pry/platform.rb +79 -81
- data/lib/pry/plugins.rb +7 -3
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +53 -29
- data/lib/pry/pry_instance.rb +88 -55
- data/lib/pry/repl.rb +33 -4
- data/lib/pry/repl_file_loader.rb +1 -2
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +6 -6
- data/lib/pry/slop.rb +17 -17
- data/lib/pry/slop/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/testable/mockable.rb +2 -2
- data/lib/pry/testable/pry_tester.rb +1 -1
- data/lib/pry/testable/utility.rb +2 -2
- data/lib/pry/testable/variables.rb +1 -1
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +15 -15
- data/lib/pry/wrapped_module/candidate.rb +2 -2
- metadata +19 -31
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/history_array.rb +0 -121
- 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 :
|
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
|
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
|
30
|
+
def amend_input
|
32
31
|
input_array = eval_string.each_line.to_a
|
33
32
|
|
34
33
|
if arg_string == "!"
|
data/lib/pry/commands/bang.rb
CHANGED
data/lib/pry/commands/cat.rb
CHANGED
@@ -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", :
|
27
|
-
opt.on :i, :in, "Show one or more entries from Pry's expression history", :
|
28
|
-
opt.on :s, :start, "Starting line (defaults to the first line)", :
|
29
|
-
opt.on :e, :end, "Ending line (defaults to the last line)", :
|
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,
|
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_.
|
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 =
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
#{
|
71
|
+
#{bold 'Exception:'} #{ex.class}: #{ex.message}
|
70
72
|
--
|
71
|
-
#{
|
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
|
@@ -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.
|
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
|
15
|
-
|
17
|
+
if opts.present?(:l)
|
18
|
+
list_prompts
|
16
19
|
else
|
17
|
-
|
20
|
+
change_prompt(prompt)
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
|
-
private
|
22
|
-
|
23
|
-
|
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
|
-
:
|
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
|
-
:
|
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
|
-
:
|
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
|
-
:
|
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_,
|
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_.
|
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_.
|
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_.
|
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_.
|
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", "", :
|
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|
|
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" }
|
data/lib/pry/commands/edit.rb
CHANGED
@@ -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
|
-
:
|
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
|
-
:
|
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
|
-
:
|
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_.
|
160
|
+
(_pry_.input_ring[opts[:i]] || []).join
|
160
161
|
when Integer
|
161
|
-
_pry_.
|
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_.
|
189
|
+
_pry_.input_ring.to_a.reverse_each.find { |x| x && x.strip != "" } || ""
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
data/lib/pry/commands/exit.rb
CHANGED
@@ -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 :
|
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 :
|
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
|
-
|
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
|
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
|
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
|
data/lib/pry/commands/gem_cd.rb
CHANGED
@@ -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 :
|
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 `#{
|
23
|
+
output.puts "Gem `#{ green(gem) }` installed."
|
24
24
|
require gem
|
25
25
|
rescue LoadError
|
26
26
|
require_path = gem.split('-').join('/')
|