pry 0.11.3 → 0.12.0
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 +17 -29
- 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
@@ -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)
|
data/lib/pry/commands/ls.rb
CHANGED
@@ -2,31 +2,30 @@ require 'pry/commands/ls/ls_entity'
|
|
2
2
|
class Pry
|
3
3
|
class Command::Ls < Pry::ClassCommand
|
4
4
|
DEFAULT_OPTIONS = {
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
5
|
+
heading_color: :bright_blue,
|
6
|
+
public_method_color: :default,
|
7
|
+
private_method_color: :blue,
|
8
|
+
protected_method_color: :blue,
|
9
|
+
method_missing_color: :bright_red,
|
10
|
+
local_var_color: :yellow,
|
11
|
+
pry_var_color: :default, # e.g. _, _pry_, _file_
|
12
|
+
instance_var_color: :blue, # e.g. @foo
|
13
|
+
class_var_color: :bright_blue, # e.g. @@foo
|
14
|
+
global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
15
|
+
builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
|
16
|
+
pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
17
|
+
constant_color: :default, # e.g. VERSION, ARGF
|
18
|
+
class_constant_color: :blue, # e.g. Object, Kernel
|
19
|
+
exception_constant_color: :magenta, # e.g. Exception, RuntimeError
|
20
|
+
unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
|
21
|
+
separator: " ",
|
22
|
+
ceiling: [Object, Module, Class]
|
23
23
|
}
|
24
24
|
|
25
|
-
|
26
25
|
match 'ls'
|
27
26
|
group 'Context'
|
28
27
|
description 'Show the list of vars and methods in the current scope.'
|
29
|
-
command_options :
|
28
|
+
command_options shellwords: false, interpolate: false
|
30
29
|
|
31
30
|
banner <<-'BANNER'
|
32
31
|
Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
|
@@ -48,9 +47,8 @@ class Pry
|
|
48
47
|
Also check out `find-method` command (run `help find-method`).
|
49
48
|
BANNER
|
50
49
|
|
51
|
-
|
52
50
|
def options(opt)
|
53
|
-
opt.on :m, :methods,
|
51
|
+
opt.on :m, :methods, "Show public methods defined on the Object"
|
54
52
|
opt.on :M, "instance-methods", "Show public methods defined in a Module or Class"
|
55
53
|
opt.on :p, :ppp, "Show public, protected (in yellow) and private (in green) methods"
|
56
54
|
opt.on :q, :quiet, "Show only methods defined on object.singleton_class and object.class"
|
@@ -60,11 +58,11 @@ class Pry
|
|
60
58
|
opt.on :c, :constants, "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" <<
|
61
59
|
" " * 32 << "Constants that are pending autoload? are also shown (in yellow)"
|
62
60
|
opt.on :i, :ivars, "Show instance variables (in blue) and class variables (in bright blue)"
|
63
|
-
opt.on :G, :grep, "Filter output by regular expression", :
|
61
|
+
opt.on :G, :grep, "Filter output by regular expression", argument: true
|
64
62
|
if Object.respond_to?(:deprecate_constant)
|
65
63
|
opt.on :d, :dconstants, "Show deprecated constants"
|
66
64
|
end
|
67
|
-
if jruby?
|
65
|
+
if Helpers::Platform.jruby?
|
68
66
|
opt.on :J, "all-java", "Show all the aliases for methods from java (default is to show only prettiest)"
|
69
67
|
end
|
70
68
|
end
|
@@ -80,11 +78,11 @@ class Pry
|
|
80
78
|
@interrogatee = args.empty? ? target_self : target.eval(args.join(' '))
|
81
79
|
raise_errors_if_arguments_are_weird
|
82
80
|
ls_entity = LsEntity.new({
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
81
|
+
interrogatee: @interrogatee,
|
82
|
+
no_user_opts: no_user_opts?,
|
83
|
+
opts: opts,
|
84
|
+
args: args,
|
85
|
+
_pry_: _pry_
|
88
86
|
})
|
89
87
|
|
90
88
|
_pry_.pager.page ls_entity.entities_table
|
@@ -109,7 +107,6 @@ class Pry
|
|
109
107
|
raise Pry::CommandError, message if opts.present?(option) && invalid_expr
|
110
108
|
end
|
111
109
|
end
|
112
|
-
|
113
110
|
end
|
114
111
|
|
115
112
|
Pry::Commands.add_command(Pry::Command::Ls)
|
@@ -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
|