pry 0.10.3 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +439 -16
- data/LICENSE +1 -1
- data/README.md +362 -302
- data/bin/pry +4 -7
- data/lib/pry/basic_object.rb +10 -0
- data/lib/pry/block_command.rb +22 -0
- data/lib/pry/class_command.rb +194 -0
- data/lib/pry/cli.rb +84 -97
- data/lib/pry/code/code_file.rb +37 -26
- data/lib/pry/code/code_range.rb +7 -5
- data/lib/pry/code/loc.rb +26 -13
- data/lib/pry/code.rb +42 -31
- data/lib/pry/code_object.rb +53 -28
- data/lib/pry/color_printer.rb +46 -35
- data/lib/pry/command.rb +197 -369
- data/lib/pry/command_set.rb +89 -114
- data/lib/pry/command_state.rb +31 -0
- data/lib/pry/commands/amend_line.rb +86 -82
- data/lib/pry/commands/bang.rb +18 -14
- data/lib/pry/commands/bang_pry.rb +15 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
- data/lib/pry/commands/cat/exception_formatter.rb +85 -72
- data/lib/pry/commands/cat/file_formatter.rb +56 -46
- data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
- data/lib/pry/commands/cat.rb +62 -54
- data/lib/pry/commands/cd.rb +40 -35
- data/lib/pry/commands/change_inspector.rb +29 -22
- data/lib/pry/commands/change_prompt.rb +48 -23
- data/lib/pry/commands/clear_screen.rb +20 -0
- data/lib/pry/commands/code_collector.rb +148 -131
- data/lib/pry/commands/disable_pry.rb +23 -19
- data/lib/pry/commands/easter_eggs.rb +23 -34
- data/lib/pry/commands/edit/exception_patcher.rb +21 -17
- data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
- data/lib/pry/commands/edit.rb +185 -157
- data/lib/pry/commands/exit.rb +40 -35
- data/lib/pry/commands/exit_all.rb +24 -20
- data/lib/pry/commands/exit_program.rb +20 -16
- data/lib/pry/commands/find_method.rb +168 -162
- data/lib/pry/commands/fix_indent.rb +16 -12
- data/lib/pry/commands/help.rb +140 -133
- data/lib/pry/commands/hist.rb +151 -149
- data/lib/pry/commands/import_set.rb +20 -15
- data/lib/pry/commands/jump_to.rb +25 -21
- data/lib/pry/commands/list_inspectors.rb +35 -28
- data/lib/pry/commands/ls/constants.rb +59 -31
- data/lib/pry/commands/ls/formatter.rb +42 -36
- data/lib/pry/commands/ls/globals.rb +38 -36
- data/lib/pry/commands/ls/grep.rb +17 -15
- data/lib/pry/commands/ls/instance_vars.rb +29 -28
- data/lib/pry/commands/ls/interrogatable.rb +18 -12
- data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
- data/lib/pry/commands/ls/local_names.rb +26 -24
- data/lib/pry/commands/ls/local_vars.rb +38 -30
- data/lib/pry/commands/ls/ls_entity.rb +47 -52
- data/lib/pry/commands/ls/methods.rb +49 -51
- data/lib/pry/commands/ls/methods_helper.rb +46 -42
- data/lib/pry/commands/ls/self_methods.rb +23 -21
- data/lib/pry/commands/ls.rb +124 -103
- data/lib/pry/commands/nesting.rb +21 -17
- data/lib/pry/commands/play.rb +92 -82
- data/lib/pry/commands/pry_backtrace.rb +22 -17
- data/lib/pry/commands/pry_version.rb +15 -11
- data/lib/pry/commands/raise_up.rb +33 -27
- data/lib/pry/commands/reload_code.rb +60 -48
- data/lib/pry/commands/reset.rb +16 -12
- data/lib/pry/commands/ri.rb +57 -42
- data/lib/pry/commands/save_file.rb +45 -43
- data/lib/pry/commands/shell_command.rb +56 -29
- data/lib/pry/commands/shell_mode.rb +22 -18
- data/lib/pry/commands/show_doc.rb +80 -70
- data/lib/pry/commands/show_info.rb +194 -155
- data/lib/pry/commands/show_input.rb +16 -11
- data/lib/pry/commands/show_source.rb +110 -42
- data/lib/pry/commands/stat.rb +35 -31
- data/lib/pry/commands/switch_to.rb +21 -15
- data/lib/pry/commands/toggle_color.rb +20 -16
- data/lib/pry/commands/watch_expression/expression.rb +32 -27
- data/lib/pry/commands/watch_expression.rb +89 -84
- data/lib/pry/commands/whereami.rb +156 -141
- data/lib/pry/commands/wtf.rb +78 -40
- data/lib/pry/config/attributable.rb +22 -0
- data/lib/pry/config/lazy_value.rb +29 -0
- data/lib/pry/config/memoized_value.rb +34 -0
- data/lib/pry/config/value.rb +24 -0
- data/lib/pry/config.rb +310 -20
- data/lib/pry/control_d_handler.rb +28 -0
- data/lib/pry/core_extensions.rb +22 -9
- data/lib/pry/editor.rb +56 -34
- data/lib/pry/env.rb +18 -0
- data/lib/pry/exception_handler.rb +43 -0
- data/lib/pry/exceptions.rb +13 -18
- data/lib/pry/forwardable.rb +27 -0
- data/lib/pry/helpers/base_helpers.rb +20 -62
- data/lib/pry/helpers/command_helpers.rb +52 -62
- data/lib/pry/helpers/documentation_helpers.rb +21 -12
- data/lib/pry/helpers/options_helpers.rb +15 -8
- data/lib/pry/helpers/platform.rb +55 -0
- data/lib/pry/helpers/table.rb +44 -32
- data/lib/pry/helpers/text.rb +96 -85
- data/lib/pry/helpers.rb +3 -0
- data/lib/pry/history.rb +81 -55
- data/lib/pry/hooks.rb +60 -110
- data/lib/pry/indent.rb +74 -68
- data/lib/pry/input_completer.rb +199 -158
- data/lib/pry/input_lock.rb +7 -10
- data/lib/pry/inspector.rb +36 -24
- data/lib/pry/last_exception.rb +45 -45
- data/lib/pry/method/disowned.rb +19 -5
- data/lib/pry/method/patcher.rb +14 -8
- data/lib/pry/method/weird_method_locator.rb +79 -45
- data/lib/pry/method.rb +178 -124
- data/lib/pry/object_path.rb +37 -28
- data/lib/pry/output.rb +102 -16
- data/lib/pry/pager.rb +187 -174
- data/lib/pry/prompt.rb +213 -25
- data/lib/pry/pry_class.rb +119 -98
- data/lib/pry/pry_instance.rb +261 -224
- data/lib/pry/repl.rb +83 -29
- data/lib/pry/repl_file_loader.rb +27 -22
- data/lib/pry/ring.rb +89 -0
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +190 -0
- data/lib/pry/slop/option.rb +210 -0
- data/lib/pry/slop.rb +672 -0
- data/lib/pry/syntax_highlighter.rb +26 -0
- data/lib/pry/system_command_handler.rb +17 -0
- data/lib/pry/testable/evalable.rb +24 -0
- data/lib/pry/testable/mockable.rb +22 -0
- data/lib/pry/testable/pry_tester.rb +88 -0
- data/lib/pry/testable/utility.rb +34 -0
- data/lib/pry/testable/variables.rb +52 -0
- data/lib/pry/testable.rb +68 -0
- data/lib/pry/version.rb +3 -1
- data/lib/pry/warning.rb +20 -0
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +35 -32
- data/lib/pry/wrapped_module.rb +68 -63
- data/lib/pry.rb +133 -149
- metadata +58 -69
- data/lib/pry/commands/disabled_commands.rb +0 -2
- data/lib/pry/commands/gem_cd.rb +0 -26
- data/lib/pry/commands/gem_install.rb +0 -32
- data/lib/pry/commands/gem_list.rb +0 -33
- data/lib/pry/commands/gem_open.rb +0 -29
- data/lib/pry/commands/gist.rb +0 -101
- data/lib/pry/commands/install_command.rb +0 -53
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/commands.rb +0 -6
- data/lib/pry/config/behavior.rb +0 -139
- data/lib/pry/config/convenience.rb +0 -25
- data/lib/pry/config/default.rb +0 -161
- data/lib/pry/history_array.rb +0 -121
- data/lib/pry/plugins.rb +0 -103
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/rubygem.rb +0 -82
- data/lib/pry/terminal.rb +0 -79
- data/lib/pry/test/helper.rb +0 -170
@@ -1,49 +1,55 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
module JRubyHacks
|
7
|
+
private
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
# JRuby creates lots of aliases for methods imported from java in an attempt
|
10
|
+
# to make life easier for ruby programmers. (e.g. getFooBar becomes
|
11
|
+
# get_foo_bar and foo_bar, and maybe foo_bar? if it returns a Boolean). The
|
12
|
+
# full transformations are in the assignAliases method of:
|
13
|
+
# https://github.com/jruby/jruby/blob/master/src/org/jruby/javasupport/JavaClass.java
|
14
|
+
#
|
15
|
+
# This has the unfortunate side-effect of making the output of ls even more
|
16
|
+
# incredibly verbose than it normally would be for these objects; and so we
|
17
|
+
# filter out all but the nicest of these aliases here.
|
18
|
+
#
|
19
|
+
# TODO: This is a little bit vague, better heuristics could be used.
|
20
|
+
# JRuby also has a lot of scala-specific logic, which we don't copy.
|
21
|
+
def trim_jruby_aliases(methods)
|
22
|
+
grouped = methods.group_by do |m|
|
23
|
+
m.name.sub(/\A(is|get|set)(?=[A-Z_])/, '').gsub(/[_?=]/, '').downcase
|
24
|
+
end
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
grouped.flat_map do |_key, values|
|
27
|
+
values = values.sort_by do |m|
|
28
|
+
rubbishness(m.name)
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
found = []
|
32
|
+
values.select do |x|
|
33
|
+
(found.none? { |y| x == y }) && found << x
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
# When removing jruby aliases, we want to keep the alias that is
|
39
|
+
# "least rubbish" according to this metric.
|
40
|
+
def rubbishness(name)
|
41
|
+
name.each_char.map do |x|
|
42
|
+
case x
|
43
|
+
when /[A-Z]/
|
44
|
+
1
|
45
|
+
when '?', '=', '!'
|
46
|
+
-2
|
47
|
+
else
|
48
|
+
0
|
49
|
+
end
|
50
|
+
end.inject(&:+) + (name.size / 100.0)
|
51
|
+
end
|
45
52
|
end
|
46
|
-
|
53
|
+
end
|
47
54
|
end
|
48
|
-
|
49
55
|
end
|
@@ -1,35 +1,37 @@
|
|
1
|
-
|
2
|
-
class Command::Ls < Pry::ClassCommand
|
3
|
-
class LocalNames < Pry::Command::Ls::Formatter
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class LocalNames < Pry::Command::Ls::Formatter
|
7
|
+
def initialize(no_user_opts, args, pry_instance)
|
8
|
+
super(pry_instance)
|
9
|
+
@no_user_opts = no_user_opts
|
10
|
+
@args = args
|
11
|
+
@sticky_locals = pry_instance.sticky_locals
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def correct_opts?
|
15
|
+
super || (@no_user_opts && @args.empty?)
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def output_self
|
19
|
+
local_vars = grep.regexp[@target.eval('local_variables')]
|
20
|
+
output_section('locals', format(local_vars))
|
21
|
+
end
|
20
22
|
|
21
|
-
|
23
|
+
private
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def format(locals)
|
26
|
+
locals.sort_by(&:downcase).map do |name|
|
27
|
+
if @sticky_locals.include?(name.to_sym)
|
28
|
+
color(:pry_var, name)
|
29
|
+
else
|
30
|
+
color(:local_var, name)
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
|
-
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -1,39 +1,47 @@
|
|
1
|
-
|
2
|
-
class Command::Ls < Pry::ClassCommand
|
3
|
-
class LocalVars < Pry::Command::Ls::Formatter
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class LocalVars < Pry::Command::Ls::Formatter
|
7
|
+
def initialize(opts, pry_instance)
|
8
|
+
super(pry_instance)
|
9
|
+
@default_switch = opts[:locals]
|
10
|
+
@sticky_locals = pry_instance.sticky_locals
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def output_self
|
14
|
+
locals = @target.eval('local_variables').reject do |e|
|
15
|
+
@sticky_locals.key?(e.to_sym)
|
16
|
+
end
|
17
|
+
name_value_pairs = locals.map do |name|
|
18
|
+
[name, @target.eval(name.to_s)]
|
19
|
+
end
|
20
|
+
format(name_value_pairs).join('')
|
21
|
+
end
|
19
22
|
|
20
|
-
|
23
|
+
private
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def format(name_value_pairs)
|
26
|
+
sorted = name_value_pairs.sort_by do |_name, value|
|
27
|
+
value.to_s.size
|
28
|
+
end
|
29
|
+
sorted.reverse.map do |name, value|
|
30
|
+
colorized_assignment_style(name, format_value(value))
|
31
|
+
end
|
32
|
+
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
def colorized_assignment_style(lhs, rhs, desired_width = 7)
|
35
|
+
colorized_lhs = color(:local_var, lhs)
|
36
|
+
color_escape_padding = colorized_lhs.size - lhs.size
|
37
|
+
pad = desired_width + color_escape_padding
|
38
|
+
Kernel.format(
|
39
|
+
"%-#{pad}<name>s = %<value>s",
|
40
|
+
name: color(:local_var, colorized_lhs),
|
41
|
+
value: rhs
|
42
|
+
)
|
43
|
+
end
|
35
44
|
end
|
36
|
-
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
@@ -1,69 +1,64 @@
|
|
1
|
-
|
2
|
-
require 'pry/commands/ls/formatter'
|
3
|
-
require 'pry/commands/ls/globals'
|
4
|
-
require 'pry/commands/ls/constants'
|
5
|
-
require 'pry/commands/ls/methods'
|
6
|
-
require 'pry/commands/ls/self_methods'
|
7
|
-
require 'pry/commands/ls/instance_vars'
|
8
|
-
require 'pry/commands/ls/local_names'
|
9
|
-
require 'pry/commands/ls/local_vars'
|
1
|
+
# frozen_string_literal: true
|
10
2
|
|
11
3
|
class Pry
|
12
|
-
class Command
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class LsEntity
|
7
|
+
attr_reader :pry_instance
|
13
8
|
|
14
|
-
|
15
|
-
|
9
|
+
def initialize(opts)
|
10
|
+
@interrogatee = opts[:interrogatee]
|
11
|
+
@no_user_opts = opts[:no_user_opts]
|
12
|
+
@opts = opts[:opts]
|
13
|
+
@args = opts[:args]
|
14
|
+
@grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
|
15
|
+
@pry_instance = opts.delete(:pry_instance)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@opts = opts[:opts]
|
21
|
-
@args = opts[:args]
|
22
|
-
@grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
|
23
|
-
@_pry_ = opts.delete(:_pry_)
|
24
|
-
end
|
18
|
+
def entities_table
|
19
|
+
entities.map(&:write_out).select { |o| o }.join('')
|
20
|
+
end
|
25
21
|
|
26
|
-
|
27
|
-
entities.map(&:write_out).reject { |o| !o }.join('')
|
28
|
-
end
|
22
|
+
private
|
29
23
|
|
30
|
-
|
24
|
+
def grep(entity)
|
25
|
+
entity.tap { |o| o.grep = @grep }
|
26
|
+
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
def globals
|
29
|
+
grep Globals.new(@opts, pry_instance)
|
30
|
+
end
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
def constants
|
33
|
+
grep Constants.new(@interrogatee, @no_user_opts, @opts, pry_instance)
|
34
|
+
end
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
def methods
|
37
|
+
grep(Methods.new(@interrogatee, @no_user_opts, @opts, pry_instance))
|
38
|
+
end
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
def self_methods
|
41
|
+
grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, pry_instance)
|
42
|
+
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
def instance_vars
|
45
|
+
grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, pry_instance)
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
def local_names
|
49
|
+
grep LocalNames.new(@no_user_opts, @args, pry_instance)
|
50
|
+
end
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def local_vars
|
61
|
-
LocalVars.new(@opts, _pry_)
|
62
|
-
end
|
52
|
+
def local_vars
|
53
|
+
LocalVars.new(@opts, pry_instance)
|
54
|
+
end
|
63
55
|
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
def entities
|
57
|
+
[
|
58
|
+
globals, constants, methods, self_methods, instance_vars, local_names,
|
59
|
+
local_vars
|
60
|
+
]
|
61
|
+
end
|
67
62
|
end
|
68
63
|
end
|
69
64
|
end
|
@@ -1,57 +1,55 @@
|
|
1
|
-
|
2
|
-
require 'pry/commands/ls/interrogatable'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
class Pry
|
5
|
-
class Command
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class Methods < Pry::Command::Ls::Formatter
|
7
|
+
include Pry::Command::Ls::Interrogatable
|
8
|
+
include Pry::Command::Ls::MethodsHelper
|
9
|
+
|
10
|
+
def initialize(interrogatee, no_user_opts, opts, pry_instance)
|
11
|
+
super(pry_instance)
|
12
|
+
@interrogatee = interrogatee
|
13
|
+
@no_user_opts = no_user_opts
|
14
|
+
@default_switch = opts[:methods]
|
15
|
+
@instance_methods_switch = opts['instance-methods']
|
16
|
+
@ppp_switch = opts[:ppp]
|
17
|
+
@jruby_switch = opts['all-java']
|
18
|
+
@quiet_switch = opts[:quiet]
|
19
|
+
@verbose_switch = opts[:verbose]
|
20
|
+
end
|
21
|
+
|
22
|
+
def output_self
|
23
|
+
methods = all_methods.group_by(&:owner)
|
24
|
+
# Reverse the resolution order so that the most useful information
|
25
|
+
# appears right by the prompt.
|
26
|
+
resolution_order.take_while(&below_ceiling).reverse.map do |klass|
|
27
|
+
methods_here = (methods[klass] || []).select { |m| grep.regexp[m.name] }
|
28
|
+
heading = "#{Pry::WrappedModule.new(klass).method_prefix}methods"
|
29
|
+
output_section(heading, format(methods_here))
|
30
|
+
end.join('')
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def correct_opts?
|
36
|
+
super || @instance_methods_switch || @ppp_switch || @no_user_opts
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a lambda that can be used with `take_while` to prevent over-eager
|
40
|
+
# traversal of the Object's ancestry graph.
|
41
|
+
def below_ceiling
|
42
|
+
ceiling = if @quiet_switch
|
43
|
+
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
|
44
|
+
pry_instance.config.ls.ceiling
|
45
|
+
elsif @verbose_switch
|
46
|
+
[]
|
47
|
+
else
|
48
|
+
pry_instance.config.ls.ceiling.dup
|
49
|
+
end
|
50
|
+
->(klass) { !ceiling.include?(klass) }
|
51
|
+
end
|
32
52
|
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def correct_opts?
|
37
|
-
super || @instance_methods_switch || @ppp_switch || @no_user_opts
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
# Get a lambda that can be used with `take_while` to prevent over-eager
|
42
|
-
# traversal of the Object's ancestry graph.
|
43
|
-
def below_ceiling
|
44
|
-
ceiling = if @quiet_switch
|
45
|
-
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
|
46
|
-
_pry_.config.ls.ceiling
|
47
|
-
elsif @verbose_switch
|
48
|
-
[]
|
49
|
-
else
|
50
|
-
_pry_.config.ls.ceiling.dup
|
51
|
-
end
|
52
|
-
lambda { |klass| !ceiling.include?(klass) }
|
53
|
-
end
|
54
|
-
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
@@ -1,46 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
module MethodsHelper
|
7
|
+
include Pry::Command::Ls::JRubyHacks
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# Get all the methods that we'll want to output.
|
12
|
+
def all_methods(instance_methods = false)
|
13
|
+
methods = if instance_methods || @instance_methods_switch
|
14
|
+
Pry::Method.all_from_class(@interrogatee)
|
15
|
+
else
|
16
|
+
Pry::Method.all_from_obj(@interrogatee)
|
17
|
+
end
|
18
|
+
|
19
|
+
if Pry::Helpers::Platform.jruby? && !@jruby_switch
|
20
|
+
methods = trim_jruby_aliases(methods)
|
21
|
+
end
|
22
|
+
|
23
|
+
methods.select { |method| @ppp_switch || method.visibility == :public }
|
24
|
+
end
|
25
|
+
|
26
|
+
def resolution_order
|
27
|
+
if @instance_methods_switch
|
28
|
+
Pry::Method.instance_resolution_order(@interrogatee)
|
29
|
+
else
|
30
|
+
Pry::Method.resolution_order(@interrogatee)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def format(methods)
|
35
|
+
methods.sort_by(&:name).map do |method|
|
36
|
+
if method.name == 'method_missing'
|
37
|
+
color(:method_missing, 'method_missing')
|
38
|
+
elsif method.visibility == :private
|
39
|
+
color(:private_method, method.name)
|
40
|
+
elsif method.visibility == :protected
|
41
|
+
color(:protected_method, method.name)
|
42
|
+
else
|
43
|
+
color(:public_method, method.name)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
45
|
-
|
46
50
|
end
|
@@ -1,32 +1,34 @@
|
|
1
|
-
|
2
|
-
require 'pry/commands/ls/methods_helper'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
class Pry
|
5
|
-
class Command
|
6
|
-
class
|
7
|
-
|
8
|
-
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class SelfMethods < Pry::Command::Ls::Formatter
|
7
|
+
include Pry::Command::Ls::Interrogatable
|
8
|
+
include Pry::Command::Ls::MethodsHelper
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def initialize(interrogatee, no_user_opts, opts, pry_instance)
|
11
|
+
super(pry_instance)
|
12
|
+
@interrogatee = interrogatee
|
13
|
+
@no_user_opts = no_user_opts
|
14
|
+
@ppp_switch = opts[:ppp]
|
15
|
+
@jruby_switch = opts['all-java']
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def output_self
|
19
|
+
methods = all_methods(true).select do |m|
|
20
|
+
m.owner == @interrogatee && grep.regexp[m.name]
|
21
|
+
end
|
22
|
+
heading = "#{Pry::WrappedModule.new(@interrogatee).method_prefix}methods"
|
23
|
+
output_section(heading, format(methods))
|
19
24
|
end
|
20
|
-
heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
|
21
|
-
output_section(heading, format(methods))
|
22
|
-
end
|
23
25
|
|
24
|
-
|
26
|
+
private
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
def correct_opts?
|
29
|
+
@no_user_opts && interrogating_a_module?
|
30
|
+
end
|
28
31
|
end
|
29
|
-
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|