pry 0.11.3 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +157 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry/cli.rb +17 -24
- 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.rb +6 -6
- 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/exception_formatter.rb +9 -8
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cat.rb +7 -6
- 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/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/ls.rb +27 -30
- 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/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/config.rb +33 -9
- 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/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/helpers.rb +1 -0
- 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/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/method.rb +37 -31
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +194 -186
- 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/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- data/lib/pry/slop.rb +17 -17
- 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/candidate.rb +2 -2
- data/lib/pry/wrapped_module.rb +15 -15
- data/lib/pry.rb +17 -47
- metadata +8 -20
- 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
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('/')
|
@@ -21,10 +21,10 @@ class Pry
|
|
21
21
|
end
|
22
22
|
|
23
23
|
versions = specs.each_with_index.map do |spec, index|
|
24
|
-
index == 0 ?
|
24
|
+
index == 0 ? bright_green(spec.version.to_s) : green(spec.version.to_s)
|
25
25
|
end
|
26
26
|
|
27
|
-
output.puts "#{
|
27
|
+
output.puts "#{default gem} (#{versions.join ', '})"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -31,9 +31,9 @@ class Pry::Command::GemSearch < Pry::ClassCommand
|
|
31
31
|
|
32
32
|
private
|
33
33
|
def list_as_string(gems, limit = 10)
|
34
|
-
gems[0..limit-1].map do |gem|
|
34
|
+
gems[0..limit - 1].map do |gem|
|
35
35
|
name, version, info = gem.values_at 'name', 'version', 'info'
|
36
|
-
"#{
|
36
|
+
"#{bold(name)} #{bold('v' + version)} \n#{info}\n\n"
|
37
37
|
end.join
|
38
38
|
end
|
39
39
|
Pry::Commands.add_command(self)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class Pry::Command::GemStat < Pry::ClassCommand
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
STAT_HOST = "rubygems.org"
|
5
|
+
STAT_PORT = 443
|
6
|
+
STAT_PATH = "/api/v1/gems/%s.json"
|
7
|
+
FAIL_WHALE = <<-FAILWHALE
|
8
|
+
W W W
|
9
|
+
W W W W
|
10
|
+
'. W
|
11
|
+
.-""-._ \ \.--|
|
12
|
+
/ "-..__) .-'
|
13
|
+
| _ /
|
14
|
+
\'-.__, .__.,'
|
15
|
+
`'----'._\--'
|
16
|
+
VVVVVVVVVVVVVVVVVVVVV
|
17
|
+
FAILWHALE
|
18
|
+
|
19
|
+
match 'gem-stat'
|
20
|
+
description 'Show the statistics of a gem (requires internet connection)'
|
21
|
+
group 'Gems'
|
22
|
+
command_options argument_required: true
|
23
|
+
banner <<-BANNER
|
24
|
+
gem-stats name
|
25
|
+
|
26
|
+
Show the statistics of a gem.
|
27
|
+
Requires an internet connection.
|
28
|
+
BANNER
|
29
|
+
|
30
|
+
def process(name)
|
31
|
+
client = Net::HTTP.start STAT_HOST, STAT_PORT, use_ssl: true
|
32
|
+
res = client.get STAT_PATH % URI.encode_www_form_component(name)
|
33
|
+
case res
|
34
|
+
when Net::HTTPOK
|
35
|
+
_pry_.pager.page format_gem(JSON.parse(res.body))
|
36
|
+
when Net::HTTPServiceUnavailable
|
37
|
+
_pry_.pager.page <<-FAILURE
|
38
|
+
#{bright_blue(FAIL_WHALE)}
|
39
|
+
#{bright_red('Ruby On Rails')}
|
40
|
+
#{bright_red('Net::HTTPServiceUnavailable')}
|
41
|
+
FAILURE
|
42
|
+
else
|
43
|
+
raise Pry::CommandError, "Bad response (#{res.class})"
|
44
|
+
end
|
45
|
+
ensure
|
46
|
+
client.finish if client
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def format_gem(h)
|
51
|
+
h = Pry::Config.from_hash(h, nil)
|
52
|
+
format_str = unindent <<-FORMAT
|
53
|
+
%{name} %{version}
|
54
|
+
--
|
55
|
+
Total Downloads : %{downloads}
|
56
|
+
Version Downloads : %{version_downloads}
|
57
|
+
|
58
|
+
#{red('Dependencies')} (runtime)
|
59
|
+
--
|
60
|
+
%{rdependencies}
|
61
|
+
|
62
|
+
#{red('Dependencies')} (development)
|
63
|
+
%{ddependencies}
|
64
|
+
FORMAT
|
65
|
+
format_str % {name: green(h.name),
|
66
|
+
version: bold("v#{h.version}"),
|
67
|
+
downloads: h.downloads,
|
68
|
+
version_downloads: h.version_downloads,
|
69
|
+
rdependencies: format_dependencies(h.dependencies.runtime),
|
70
|
+
ddependencies: format_dependencies(h.dependencies.development)}
|
71
|
+
end
|
72
|
+
|
73
|
+
def format_dependencies(rdeps)
|
74
|
+
return bold('None') if rdeps.empty?
|
75
|
+
|
76
|
+
with_line_numbers(
|
77
|
+
rdeps.map { |h| "#{h['name']} (#{h['requirements']})" }.join("\n"),
|
78
|
+
1,
|
79
|
+
:bold
|
80
|
+
)
|
81
|
+
end
|
82
|
+
Pry::Commands.add_command(self)
|
83
|
+
end
|
data/lib/pry/commands/gist.rb
CHANGED
@@ -3,7 +3,7 @@ class Pry
|
|
3
3
|
match 'gist'
|
4
4
|
group 'Misc'
|
5
5
|
description 'Upload code, docs, history to https://gist.github.com/.'
|
6
|
-
command_options :
|
6
|
+
command_options requires_gem: "gist"
|
7
7
|
|
8
8
|
banner <<-'BANNER'
|
9
9
|
Usage: gist [OPTIONS] [--help]
|
@@ -22,12 +22,13 @@ class Pry
|
|
22
22
|
def options(opt)
|
23
23
|
CodeCollector.inject_options(opt)
|
24
24
|
opt.on :login, "Authenticate the gist gem with GitHub"
|
25
|
-
opt.on :p, :public, "Create a public gist (default: false)", :
|
26
|
-
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :
|
25
|
+
opt.on :p, :public, "Create a public gist (default: false)", default: false
|
26
|
+
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", default: false
|
27
27
|
end
|
28
28
|
|
29
29
|
def process
|
30
30
|
return ::Gist.login! if opts.present?(:login)
|
31
|
+
|
31
32
|
cc = CodeCollector.new(args, opts, _pry_)
|
32
33
|
|
33
34
|
if cc.content =~ /\A\s*\z/
|
@@ -52,13 +53,13 @@ class Pry
|
|
52
53
|
def input_content
|
53
54
|
content = ""
|
54
55
|
CodeCollector.input_expression_ranges.each do |range|
|
55
|
-
input_expressions = _pry_.
|
56
|
+
input_expressions = _pry_.input_ring[range] || []
|
56
57
|
Array(input_expressions).each_with_index do |code, index|
|
57
58
|
corrected_index = index + range.first
|
58
59
|
if code && code != ""
|
59
60
|
content << code
|
60
61
|
if code !~ /;\Z/
|
61
|
-
content << "#{comment_expression_result_for_gist(_pry_.config.gist.inspecter.call(_pry_.
|
62
|
+
content << "#{comment_expression_result_for_gist(_pry_.config.gist.inspecter.call(_pry_.output_ring[corrected_index]))}"
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
@@ -81,7 +82,7 @@ class Pry
|
|
81
82
|
end
|
82
83
|
|
83
84
|
def gist_content(content, filename)
|
84
|
-
response = ::Gist.gist(content, :
|
85
|
+
response = ::Gist.gist(content, filename: filename || "pry_gist.rb", public: !!opts[:p])
|
85
86
|
if response
|
86
87
|
url = response['html_url']
|
87
88
|
message = "Gist created at URL #{url}"
|
data/lib/pry/commands/help.rb
CHANGED
@@ -59,7 +59,7 @@ class Pry
|
|
59
59
|
# @param [Array<Pry::Command>] commands
|
60
60
|
# @return [String] The generated help string.
|
61
61
|
def help_text_for_commands(name, commands)
|
62
|
-
"#{
|
62
|
+
"#{bold(name.capitalize)}\n" << commands.map do |command|
|
63
63
|
" #{command.options[:listing].to_s.ljust(18)} #{command.description.capitalize}"
|
64
64
|
end.join("\n")
|
65
65
|
end
|
@@ -75,14 +75,14 @@ class Pry
|
|
75
75
|
# @param [Array<Pry::Command>] commands The commands to sort
|
76
76
|
# @return [Array<Pry::Command>] commands sorted by listing name.
|
77
77
|
def sorted_commands(commands)
|
78
|
-
commands.sort_by{ |command| command.options[:listing].to_s }
|
78
|
+
commands.sort_by { |command| command.options[:listing].to_s }
|
79
79
|
end
|
80
80
|
|
81
81
|
# Display help for an individual command or group.
|
82
82
|
#
|
83
83
|
# @param [String] search The string to search for.
|
84
84
|
def display_search(search)
|
85
|
-
if command = command_set.find_command_for_help(search)
|
85
|
+
if (command = command_set.find_command_for_help(search))
|
86
86
|
display_command(command)
|
87
87
|
else
|
88
88
|
display_filtered_search_results(search)
|
data/lib/pry/commands/hist.rb
CHANGED
@@ -21,13 +21,13 @@ class Pry
|
|
21
21
|
|
22
22
|
def options(opt)
|
23
23
|
opt.on :a, :all, "Display all history"
|
24
|
-
opt.on :H, :head, "Display the first N items", :
|
25
|
-
opt.on :T, :tail, "Display the last N items", :
|
26
|
-
opt.on :s, :show, "Show the given range of lines", :
|
27
|
-
opt.on :G, :grep, "Show lines matching the given pattern", :
|
24
|
+
opt.on :H, :head, "Display the first N items", optional_argument: true, as: Integer
|
25
|
+
opt.on :T, :tail, "Display the last N items", optional_argument: true, as: Integer
|
26
|
+
opt.on :s, :show, "Show the given range of lines", optional_argument: true, as: Range
|
27
|
+
opt.on :G, :grep, "Show lines matching the given pattern", argument: true, as: String
|
28
28
|
opt.on :c, :clear , "Clear the current session's history"
|
29
|
-
opt.on :r, :replay, "Replay a line or range of lines", :
|
30
|
-
opt.on :save, "Save history to a file", :
|
29
|
+
opt.on :r, :replay, "Replay a line or range of lines", argument: true, as: Range
|
30
|
+
opt.on :save, "Save history to a file", argument: true, as: Range
|
31
31
|
opt.on :e, :'exclude-pry', "Exclude Pry commands from the history"
|
32
32
|
opt.on :n, :'no-numbers', "Omit line numbers"
|
33
33
|
end
|
@@ -43,7 +43,8 @@ class Pry
|
|
43
43
|
@history = @history.grep(opts[:grep])
|
44
44
|
end
|
45
45
|
|
46
|
-
@history =
|
46
|
+
@history =
|
47
|
+
case
|
47
48
|
when opts.present?(:head)
|
48
49
|
@history.take_lines(1, opts[:head] || 10)
|
49
50
|
when opts.present?(:tail)
|
@@ -119,7 +120,7 @@ class Pry
|
|
119
120
|
check_for_juxtaposed_replay(replay_sequence)
|
120
121
|
|
121
122
|
replay_sequence.lines.each do |line|
|
122
|
-
_pry_.eval line, :
|
123
|
+
_pry_.eval line, generated: true
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
@@ -10,7 +10,8 @@ class Pry
|
|
10
10
|
Import a Pry command set.
|
11
11
|
BANNER
|
12
12
|
|
13
|
-
|
13
|
+
# TODO: resolve unused parameter.
|
14
|
+
def process(_command_set_name)
|
14
15
|
raise CommandError, "Provide a command set name" if command_set.nil?
|
15
16
|
|
16
17
|
set = target.eval(arg_string)
|
@@ -16,21 +16,22 @@ class Pry
|
|
16
16
|
command = find_command(name)
|
17
17
|
|
18
18
|
unless command
|
19
|
-
output.puts "Command #{
|
19
|
+
output.puts "Command #{ green(name) } is not found"
|
20
20
|
return
|
21
21
|
end
|
22
22
|
|
23
23
|
if command_dependencies_met?(command.options)
|
24
|
-
output.puts "Dependencies for #{
|
24
|
+
output.puts "Dependencies for #{ green(name) } are met. Nothing to do"
|
25
25
|
return
|
26
26
|
end
|
27
27
|
|
28
|
-
output.puts "Attempting to install #{
|
28
|
+
output.puts "Attempting to install #{ green(name) } command..."
|
29
29
|
gems_to_install = Array(command.options[:requires_gem])
|
30
30
|
|
31
31
|
gems_to_install.each do |g|
|
32
32
|
next if Rubygem.installed?(g)
|
33
|
-
|
33
|
+
|
34
|
+
output.puts "Installing #{ green(g) } gem..."
|
34
35
|
Rubygem.install(g)
|
35
36
|
end
|
36
37
|
|
@@ -38,14 +39,14 @@ class Pry
|
|
38
39
|
begin
|
39
40
|
require g
|
40
41
|
rescue LoadError
|
41
|
-
fail_msg = "Required gem #{
|
42
|
+
fail_msg = "Required gem #{ green(g) } installed but not found."
|
42
43
|
fail_msg += " Aborting command installation\n"
|
43
44
|
fail_msg += 'Tips: 1. Check your PATH; 2. Run `bundle update`'
|
44
45
|
raise CommandError, fail_msg
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
output.puts "Installation of #{
|
49
|
+
output.puts "Installation of #{ green(name) } successful! Type `help #{name}` for information"
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -12,7 +12,7 @@ class Pry::Command::ListInspectors < Pry::ClassCommand
|
|
12
12
|
def process
|
13
13
|
output.puts heading("Available inspectors") + "\n"
|
14
14
|
inspector_map.each do |name, inspector|
|
15
|
-
output.write "Name: #{
|
15
|
+
output.write "Name: #{bold(name)}"
|
16
16
|
output.puts selected_inspector?(inspector) ? selected_text : ""
|
17
17
|
output.puts inspector[:description]
|
18
18
|
output.puts
|
@@ -25,7 +25,7 @@ private
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def selected_text
|
28
|
-
|
28
|
+
red " (selected) "
|
29
29
|
end
|
30
30
|
|
31
31
|
def selected_inspector?(inspector)
|
@@ -3,8 +3,8 @@ require 'pry/commands/ls/interrogatable'
|
|
3
3
|
class Pry
|
4
4
|
class Command::Ls < Pry::ClassCommand
|
5
5
|
class Constants < Pry::Command::Ls::Formatter
|
6
|
-
DEPRECATED_CONSTANTS = [:Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE]
|
7
|
-
DEPRECATED_CONSTANTS << :JavaPackageModuleTemplate if
|
6
|
+
DEPRECATED_CONSTANTS = [:Data, :Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE]
|
7
|
+
DEPRECATED_CONSTANTS << :JavaPackageModuleTemplate if Helpers::Platform.jruby?
|
8
8
|
include Pry::Command::Ls::Interrogatable
|
9
9
|
|
10
10
|
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
@@ -39,7 +39,8 @@ class Pry
|
|
39
39
|
!show_deprecated_constants?
|
40
40
|
next
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
|
+
if (const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil))
|
43
44
|
if (const < Exception rescue false)
|
44
45
|
color(:exception_constant, name)
|
45
46
|
elsif (Module === mod.const_get(name) rescue false)
|
@@ -52,7 +53,6 @@ class Pry
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
55
|
-
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -12,6 +12,7 @@ class Pry
|
|
12
12
|
|
13
13
|
def write_out
|
14
14
|
return false unless correct_opts?
|
15
|
+
|
15
16
|
output_self
|
16
17
|
end
|
17
18
|
|
@@ -25,8 +26,9 @@ class Pry
|
|
25
26
|
# Outputs nothing if the section would be empty.
|
26
27
|
def output_section(heading, body)
|
27
28
|
return '' if body.compact.empty?
|
29
|
+
|
28
30
|
fancy_heading = Pry::Helpers::Text.bold(color(:heading, heading))
|
29
|
-
Pry::Helpers.tablify_or_one_line(fancy_heading, body)
|
31
|
+
Pry::Helpers.tablify_or_one_line(fancy_heading, body, @_pry_.config)
|
30
32
|
end
|
31
33
|
|
32
34
|
def format_value(value)
|
@@ -44,7 +46,6 @@ class Pry
|
|
44
46
|
def grep
|
45
47
|
@grep || proc { |x| x }
|
46
48
|
end
|
47
|
-
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class Pry
|
2
2
|
class Command::Ls < Pry::ClassCommand
|
3
3
|
class Globals < Pry::Command::Ls::Formatter
|
4
|
-
|
5
4
|
# Taken from "puts global_variables.inspect".
|
6
5
|
BUILTIN_GLOBALS =
|
7
6
|
%w($" $$ $* $, $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w $. $/ $\\
|
@@ -42,7 +41,6 @@ class Pry
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
45
|
-
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
data/lib/pry/commands/ls/grep.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
class Pry
|
2
2
|
class Command::Ls < Pry::ClassCommand
|
3
3
|
class LocalNames < Pry::Command::Ls::Formatter
|
4
|
-
|
5
4
|
def initialize(no_user_opts, args, _pry_)
|
6
5
|
super(_pry_)
|
7
6
|
@no_user_opts = no_user_opts
|
@@ -29,7 +28,6 @@ class Pry
|
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class Pry
|
2
2
|
class Command::Ls < Pry::ClassCommand
|
3
3
|
class LocalVars < Pry::Command::Ls::Formatter
|
4
|
-
|
5
4
|
def initialize(opts, _pry_)
|
6
5
|
super(_pry_)
|
7
6
|
@default_switch = opts[:locals]
|
@@ -33,7 +32,6 @@ class Pry
|
|
33
32
|
pad = desired_width + color_escape_padding
|
34
33
|
"%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs]
|
35
34
|
end
|
36
|
-
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -4,7 +4,6 @@ require 'pry/commands/ls/interrogatable'
|
|
4
4
|
class Pry
|
5
5
|
class Command::Ls < Pry::ClassCommand
|
6
6
|
class Methods < Pry::Command::Ls::Formatter
|
7
|
-
|
8
7
|
include Pry::Command::Ls::Interrogatable
|
9
8
|
include Pry::Command::Ls::MethodsHelper
|
10
9
|
|
@@ -37,7 +36,6 @@ class Pry
|
|
37
36
|
super || @instance_methods_switch || @ppp_switch || @no_user_opts
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
39
|
# Get a lambda that can be used with `take_while` to prevent over-eager
|
42
40
|
# traversal of the Object's ancestry graph.
|
43
41
|
def below_ceiling
|
@@ -51,7 +49,6 @@ class Pry
|
|
51
49
|
end
|
52
50
|
lambda { |klass| !ceiling.include?(klass) }
|
53
51
|
end
|
54
|
-
|
55
52
|
end
|
56
53
|
end
|
57
54
|
end
|