pry 0.12.2-java → 0.13.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +110 -1
  3. data/LICENSE +1 -1
  4. data/README.md +331 -269
  5. data/bin/pry +5 -0
  6. data/lib/pry.rb +133 -119
  7. data/lib/pry/basic_object.rb +8 -4
  8. data/lib/pry/block_command.rb +22 -0
  9. data/lib/pry/class_command.rb +194 -0
  10. data/lib/pry/cli.rb +40 -31
  11. data/lib/pry/code.rb +39 -27
  12. data/lib/pry/code/code_file.rb +28 -24
  13. data/lib/pry/code/code_range.rb +4 -2
  14. data/lib/pry/code/loc.rb +15 -8
  15. data/lib/pry/code_object.rb +40 -38
  16. data/lib/pry/color_printer.rb +47 -46
  17. data/lib/pry/command.rb +166 -369
  18. data/lib/pry/command_set.rb +76 -73
  19. data/lib/pry/command_state.rb +31 -0
  20. data/lib/pry/commands/amend_line.rb +86 -81
  21. data/lib/pry/commands/bang.rb +18 -14
  22. data/lib/pry/commands/bang_pry.rb +15 -11
  23. data/lib/pry/commands/cat.rb +61 -54
  24. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  25. data/lib/pry/commands/cat/exception_formatter.rb +71 -60
  26. data/lib/pry/commands/cat/file_formatter.rb +55 -49
  27. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  28. data/lib/pry/commands/cd.rb +40 -35
  29. data/lib/pry/commands/change_inspector.rb +29 -22
  30. data/lib/pry/commands/change_prompt.rb +44 -39
  31. data/lib/pry/commands/clear_screen.rb +16 -10
  32. data/lib/pry/commands/code_collector.rb +148 -133
  33. data/lib/pry/commands/disable_pry.rb +23 -19
  34. data/lib/pry/commands/easter_eggs.rb +19 -30
  35. data/lib/pry/commands/edit.rb +184 -161
  36. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  37. data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
  38. data/lib/pry/commands/exit.rb +39 -35
  39. data/lib/pry/commands/exit_all.rb +24 -20
  40. data/lib/pry/commands/exit_program.rb +20 -16
  41. data/lib/pry/commands/find_method.rb +168 -160
  42. data/lib/pry/commands/fix_indent.rb +16 -12
  43. data/lib/pry/commands/help.rb +140 -133
  44. data/lib/pry/commands/hist.rb +151 -150
  45. data/lib/pry/commands/import_set.rb +20 -16
  46. data/lib/pry/commands/jump_to.rb +25 -21
  47. data/lib/pry/commands/list_inspectors.rb +35 -28
  48. data/lib/pry/commands/ls.rb +124 -102
  49. data/lib/pry/commands/ls/constants.rb +59 -42
  50. data/lib/pry/commands/ls/formatter.rb +50 -46
  51. data/lib/pry/commands/ls/globals.rb +38 -34
  52. data/lib/pry/commands/ls/grep.rb +17 -13
  53. data/lib/pry/commands/ls/instance_vars.rb +29 -27
  54. data/lib/pry/commands/ls/interrogatable.rb +18 -12
  55. data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
  56. data/lib/pry/commands/ls/local_names.rb +26 -22
  57. data/lib/pry/commands/ls/local_vars.rb +38 -28
  58. data/lib/pry/commands/ls/ls_entity.rb +47 -51
  59. data/lib/pry/commands/ls/methods.rb +44 -43
  60. data/lib/pry/commands/ls/methods_helper.rb +46 -42
  61. data/lib/pry/commands/ls/self_methods.rb +23 -22
  62. data/lib/pry/commands/nesting.rb +21 -17
  63. data/lib/pry/commands/play.rb +93 -82
  64. data/lib/pry/commands/pry_backtrace.rb +24 -17
  65. data/lib/pry/commands/pry_version.rb +15 -11
  66. data/lib/pry/commands/raise_up.rb +27 -22
  67. data/lib/pry/commands/reload_code.rb +60 -48
  68. data/lib/pry/commands/reset.rb +16 -12
  69. data/lib/pry/commands/ri.rb +55 -45
  70. data/lib/pry/commands/save_file.rb +45 -43
  71. data/lib/pry/commands/shell_command.rb +51 -51
  72. data/lib/pry/commands/shell_mode.rb +21 -17
  73. data/lib/pry/commands/show_doc.rb +81 -68
  74. data/lib/pry/commands/show_info.rb +189 -171
  75. data/lib/pry/commands/show_input.rb +16 -11
  76. data/lib/pry/commands/show_source.rb +109 -45
  77. data/lib/pry/commands/stat.rb +35 -31
  78. data/lib/pry/commands/switch_to.rb +21 -15
  79. data/lib/pry/commands/toggle_color.rb +20 -16
  80. data/lib/pry/commands/watch_expression.rb +89 -86
  81. data/lib/pry/commands/watch_expression/expression.rb +32 -27
  82. data/lib/pry/commands/whereami.rb +156 -148
  83. data/lib/pry/commands/wtf.rb +75 -50
  84. data/lib/pry/config.rb +311 -25
  85. data/lib/pry/config/attributable.rb +22 -0
  86. data/lib/pry/config/lazy_value.rb +29 -0
  87. data/lib/pry/config/memoized_value.rb +34 -0
  88. data/lib/pry/config/value.rb +24 -0
  89. data/lib/pry/control_d_handler.rb +28 -0
  90. data/lib/pry/core_extensions.rb +9 -7
  91. data/lib/pry/editor.rb +48 -21
  92. data/lib/pry/env.rb +18 -0
  93. data/lib/pry/exception_handler.rb +43 -0
  94. data/lib/pry/exceptions.rb +13 -16
  95. data/lib/pry/forwardable.rb +5 -1
  96. data/lib/pry/helpers.rb +2 -0
  97. data/lib/pry/helpers/base_helpers.rb +68 -197
  98. data/lib/pry/helpers/command_helpers.rb +50 -61
  99. data/lib/pry/helpers/documentation_helpers.rb +20 -13
  100. data/lib/pry/helpers/options_helpers.rb +14 -7
  101. data/lib/pry/helpers/platform.rb +7 -5
  102. data/lib/pry/helpers/table.rb +33 -26
  103. data/lib/pry/helpers/text.rb +17 -14
  104. data/lib/pry/history.rb +48 -56
  105. data/lib/pry/hooks.rb +21 -12
  106. data/lib/pry/indent.rb +54 -50
  107. data/lib/pry/input_completer.rb +248 -230
  108. data/lib/pry/input_lock.rb +8 -9
  109. data/lib/pry/inspector.rb +36 -24
  110. data/lib/pry/last_exception.rb +45 -45
  111. data/lib/pry/method.rb +141 -94
  112. data/lib/pry/method/disowned.rb +16 -4
  113. data/lib/pry/method/patcher.rb +12 -3
  114. data/lib/pry/method/weird_method_locator.rb +68 -44
  115. data/lib/pry/object_path.rb +33 -25
  116. data/lib/pry/output.rb +121 -35
  117. data/lib/pry/pager.rb +41 -42
  118. data/lib/pry/plugins.rb +25 -8
  119. data/lib/pry/prompt.rb +123 -54
  120. data/lib/pry/pry_class.rb +61 -98
  121. data/lib/pry/pry_instance.rb +217 -215
  122. data/lib/pry/repl.rb +18 -22
  123. data/lib/pry/repl_file_loader.rb +27 -21
  124. data/lib/pry/ring.rb +11 -6
  125. data/lib/pry/slop.rb +574 -563
  126. data/lib/pry/slop/commands.rb +164 -169
  127. data/lib/pry/slop/option.rb +172 -168
  128. data/lib/pry/syntax_highlighter.rb +26 -0
  129. data/lib/pry/system_command_handler.rb +17 -0
  130. data/lib/pry/testable.rb +59 -61
  131. data/lib/pry/testable/evalable.rb +21 -12
  132. data/lib/pry/testable/mockable.rb +18 -10
  133. data/lib/pry/testable/pry_tester.rb +71 -56
  134. data/lib/pry/testable/utility.rb +29 -21
  135. data/lib/pry/testable/variables.rb +49 -43
  136. data/lib/pry/version.rb +3 -1
  137. data/lib/pry/warning.rb +27 -0
  138. data/lib/pry/wrapped_module.rb +51 -42
  139. data/lib/pry/wrapped_module/candidate.rb +21 -14
  140. metadata +31 -30
  141. data/lib/pry/commands.rb +0 -6
  142. data/lib/pry/commands/disabled_commands.rb +0 -2
  143. data/lib/pry/commands/gem_cd.rb +0 -26
  144. data/lib/pry/commands/gem_install.rb +0 -32
  145. data/lib/pry/commands/gem_list.rb +0 -33
  146. data/lib/pry/commands/gem_open.rb +0 -29
  147. data/lib/pry/commands/gem_readme.rb +0 -25
  148. data/lib/pry/commands/gem_search.rb +0 -40
  149. data/lib/pry/commands/gem_stats.rb +0 -83
  150. data/lib/pry/commands/gist.rb +0 -102
  151. data/lib/pry/commands/install_command.rb +0 -54
  152. data/lib/pry/config/behavior.rb +0 -255
  153. data/lib/pry/config/convenience.rb +0 -28
  154. data/lib/pry/config/default.rb +0 -159
  155. data/lib/pry/config/memoization.rb +0 -48
  156. data/lib/pry/platform.rb +0 -91
  157. data/lib/pry/rubygem.rb +0 -84
  158. data/lib/pry/terminal.rb +0 -91
@@ -1,36 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Pry
2
- class Command::Ls < Pry::ClassCommand
3
- class LocalVars < Pry::Command::Ls::Formatter
4
- def initialize(opts, _pry_)
5
- super(_pry_)
6
- @default_switch = opts[:locals]
7
- @sticky_locals = _pry_.sticky_locals
8
- end
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
9
12
 
10
- def output_self
11
- name_value_pairs = @target.eval('local_variables').reject { |e|
12
- @sticky_locals.keys.include?(e.to_sym)
13
- }.map { |name|
14
- [name, (@target.eval(name.to_s))]
15
- }
16
- format(name_value_pairs).join('')
17
- end
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
18
22
 
19
- private
23
+ private
20
24
 
21
- def format(name_value_pairs)
22
- name_value_pairs.sort_by { |name, value|
23
- value.to_s.size
24
- }.reverse.map { |name, value|
25
- colorized_assignment_style(name, format_value(value))
26
- }
27
- end
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
28
33
 
29
- def colorized_assignment_style(lhs, rhs, desired_width = 7)
30
- colorized_lhs = color(:local_var, lhs)
31
- color_escape_padding = colorized_lhs.size - lhs.size
32
- pad = desired_width + color_escape_padding
33
- "%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs]
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
34
44
  end
35
45
  end
36
46
  end
@@ -1,68 +1,64 @@
1
- require 'pry/commands/ls/grep'
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::Ls < Pry::ClassCommand
13
- class LsEntity
14
- attr_reader :_pry_
4
+ class Command
5
+ class Ls < Pry::ClassCommand
6
+ class LsEntity
7
+ attr_reader :pry_instance
15
8
 
16
- def initialize(opts)
17
- @interrogatee = opts[:interrogatee]
18
- @no_user_opts = opts[:no_user_opts]
19
- @opts = opts[:opts]
20
- @args = opts[:args]
21
- @grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
22
- @_pry_ = opts.delete(:_pry_)
23
- end
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
24
17
 
25
- def entities_table
26
- entities.map(&:write_out).reject { |o| !o }.join('')
27
- end
18
+ def entities_table
19
+ entities.map(&:write_out).select { |o| o }.join('')
20
+ end
28
21
 
29
- private
22
+ private
30
23
 
31
- def grep(entity)
32
- entity.tap { |o| o.grep = @grep }
33
- end
24
+ def grep(entity)
25
+ entity.tap { |o| o.grep = @grep }
26
+ end
34
27
 
35
- def globals
36
- grep Globals.new(@opts, _pry_)
37
- end
28
+ def globals
29
+ grep Globals.new(@opts, pry_instance)
30
+ end
38
31
 
39
- def constants
40
- grep Constants.new(@interrogatee, @no_user_opts, @opts, _pry_)
41
- end
32
+ def constants
33
+ grep Constants.new(@interrogatee, @no_user_opts, @opts, pry_instance)
34
+ end
42
35
 
43
- def methods
44
- grep(Methods.new(@interrogatee, @no_user_opts, @opts, _pry_))
45
- end
36
+ def methods
37
+ grep(Methods.new(@interrogatee, @no_user_opts, @opts, pry_instance))
38
+ end
46
39
 
47
- def self_methods
48
- grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, _pry_)
49
- end
40
+ def self_methods
41
+ grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, pry_instance)
42
+ end
50
43
 
51
- def instance_vars
52
- grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, _pry_)
53
- end
44
+ def instance_vars
45
+ grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, pry_instance)
46
+ end
54
47
 
55
- def local_names
56
- grep LocalNames.new(@no_user_opts, @args, _pry_)
57
- end
48
+ def local_names
49
+ grep LocalNames.new(@no_user_opts, @args, pry_instance)
50
+ end
58
51
 
59
- def local_vars
60
- LocalVars.new(@opts, _pry_)
61
- end
52
+ def local_vars
53
+ LocalVars.new(@opts, pry_instance)
54
+ end
62
55
 
63
- def entities
64
- [globals, constants, methods, self_methods, instance_vars, local_names,
65
- local_vars]
56
+ def entities
57
+ [
58
+ globals, constants, methods, self_methods, instance_vars, local_names,
59
+ local_vars
60
+ ]
61
+ end
66
62
  end
67
63
  end
68
64
  end
@@ -1,53 +1,54 @@
1
- require 'pry/commands/ls/methods_helper'
2
- require 'pry/commands/ls/interrogatable'
1
+ # frozen_string_literal: true
3
2
 
4
3
  class Pry
5
- class Command::Ls < Pry::ClassCommand
6
- class Methods < Pry::Command::Ls::Formatter
7
- include Pry::Command::Ls::Interrogatable
8
- include Pry::Command::Ls::MethodsHelper
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
9
 
10
- def initialize(interrogatee, no_user_opts, opts, _pry_)
11
- super(_pry_)
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
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
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
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
32
 
33
- private
33
+ private
34
34
 
35
- def correct_opts?
36
- super || @instance_methods_switch || @ppp_switch || @no_user_opts
37
- end
35
+ def correct_opts?
36
+ super || @instance_methods_switch || @ppp_switch || @no_user_opts
37
+ end
38
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_.config.ls.ceiling
45
- elsif @verbose_switch
46
- []
47
- else
48
- _pry_.config.ls.ceiling.dup
49
- end
50
- lambda { |klass| !ceiling.include?(klass) }
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
51
52
  end
52
53
  end
53
54
  end
@@ -1,46 +1,50 @@
1
- require 'pry/commands/ls/jruby_hacks'
2
-
3
- module Pry::Command::Ls::MethodsHelper
4
-
5
- include Pry::Command::Ls::JRubyHacks
6
-
7
- private
8
-
9
- # Get all the methods that we'll want to output.
10
- def all_methods(instance_methods = false)
11
- methods = if instance_methods || @instance_methods_switch
12
- Pry::Method.all_from_class(@interrogatee)
13
- else
14
- Pry::Method.all_from_obj(@interrogatee)
15
- end
16
-
17
- if Pry::Helpers::Platform.jruby? && !@jruby_switch
18
- methods = trim_jruby_aliases(methods)
19
- end
20
-
21
- methods.select { |method| @ppp_switch || method.visibility == :public }
22
- end
23
-
24
- def resolution_order
25
- if @instance_methods_switch
26
- Pry::Method.instance_resolution_order(@interrogatee)
27
- else
28
- Pry::Method.resolution_order(@interrogatee)
29
- end
30
- end
31
-
32
- def format(methods)
33
- methods.sort_by(&:name).map do |method|
34
- if method.name == 'method_missing'
35
- color(:method_missing, 'method_missing')
36
- elsif method.visibility == :private
37
- color(:private_method, method.name)
38
- elsif method.visibility == :protected
39
- color(:protected_method, method.name)
40
- else
41
- color(:public_method, method.name)
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,33 @@
1
- require 'pry/commands/ls/interrogatable'
2
- require 'pry/commands/ls/methods_helper'
1
+ # frozen_string_literal: true
3
2
 
4
3
  class Pry
5
- class Command::Ls < Pry::ClassCommand
6
- class SelfMethods < Pry::Command::Ls::Formatter
7
- include Pry::Command::Ls::Interrogatable
8
- include Pry::Command::Ls::MethodsHelper
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
- def initialize(interrogatee, no_user_opts, opts, _pry_)
11
- super(_pry_)
12
- @interrogatee = interrogatee
13
- @no_user_opts = no_user_opts
14
- @ppp_switch = opts[:ppp]
15
- @jruby_switch = opts['all-java']
16
- end
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
17
17
 
18
- def output_self
19
- methods = all_methods(true).select do |m|
20
- m.owner == @interrogatee && grep.regexp[m.name]
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))
21
24
  end
22
- heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
23
- output_section(heading, format(methods))
24
- end
25
25
 
26
- private
26
+ private
27
27
 
28
- def correct_opts?
29
- @no_user_opts && interrogating_a_module?
28
+ def correct_opts?
29
+ @no_user_opts && interrogating_a_module?
30
+ end
30
31
  end
31
32
  end
32
33
  end
@@ -1,25 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Pry
2
- class Command::Nesting < Pry::ClassCommand
3
- match 'nesting'
4
- group 'Navigating Pry'
5
- description 'Show nesting information.'
4
+ class Command
5
+ class Nesting < Pry::ClassCommand
6
+ match 'nesting'
7
+ group 'Navigating Pry'
8
+ description 'Show nesting information.'
6
9
 
7
- banner <<-'BANNER'
8
- Show nesting information.
9
- BANNER
10
+ banner <<-'BANNER'
11
+ Show nesting information.
12
+ BANNER
10
13
 
11
- def process
12
- output.puts 'Nesting status:'
13
- output.puts '--'
14
- _pry_.binding_stack.each_with_index do |obj, level|
15
- if level == 0
16
- output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
17
- else
18
- output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}"
14
+ def process
15
+ output.puts 'Nesting status:'
16
+ output.puts '--'
17
+ pry_instance.binding_stack.each_with_index do |obj, level|
18
+ if level == 0
19
+ output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
20
+ else
21
+ output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}"
22
+ end
19
23
  end
20
24
  end
21
25
  end
22
- end
23
26
 
24
- Pry::Commands.add_command(Pry::Command::Nesting)
27
+ Pry::Commands.add_command(Pry::Command::Nesting)
28
+ end
25
29
  end