pry 0.11.3-java → 0.12.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 (118) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +139 -1
  3. data/LICENSE +1 -1
  4. data/README.md +13 -30
  5. data/bin/pry +0 -4
  6. data/lib/pry.rb +17 -47
  7. data/lib/pry/cli.rb +17 -24
  8. data/lib/pry/code.rb +6 -6
  9. data/lib/pry/code/code_file.rb +5 -4
  10. data/lib/pry/code/code_range.rb +3 -3
  11. data/lib/pry/code/loc.rb +14 -8
  12. data/lib/pry/code_object.rb +4 -4
  13. data/lib/pry/color_printer.rb +1 -0
  14. data/lib/pry/command.rb +36 -29
  15. data/lib/pry/command_set.rb +17 -52
  16. data/lib/pry/commands/amend_line.rb +3 -4
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +7 -6
  19. data/lib/pry/commands/cat/exception_formatter.rb +9 -8
  20. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  21. data/lib/pry/commands/change_prompt.rb +29 -9
  22. data/lib/pry/commands/clear_screen.rb +14 -0
  23. data/lib/pry/commands/code_collector.rb +9 -9
  24. data/lib/pry/commands/easter_eggs.rb +3 -3
  25. data/lib/pry/commands/edit.rb +8 -7
  26. data/lib/pry/commands/exit.rb +2 -1
  27. data/lib/pry/commands/find_method.rb +11 -13
  28. data/lib/pry/commands/gem_cd.rb +1 -1
  29. data/lib/pry/commands/gem_install.rb +2 -2
  30. data/lib/pry/commands/gem_list.rb +2 -2
  31. data/lib/pry/commands/gem_open.rb +1 -1
  32. data/lib/pry/commands/gem_search.rb +2 -2
  33. data/lib/pry/commands/gem_stats.rb +83 -0
  34. data/lib/pry/commands/gist.rb +7 -6
  35. data/lib/pry/commands/help.rb +3 -3
  36. data/lib/pry/commands/hist.rb +9 -8
  37. data/lib/pry/commands/import_set.rb +2 -1
  38. data/lib/pry/commands/install_command.rb +7 -6
  39. data/lib/pry/commands/list_inspectors.rb +2 -2
  40. data/lib/pry/commands/ls.rb +27 -30
  41. data/lib/pry/commands/ls/constants.rb +4 -4
  42. data/lib/pry/commands/ls/formatter.rb +3 -2
  43. data/lib/pry/commands/ls/globals.rb +0 -2
  44. data/lib/pry/commands/ls/grep.rb +0 -2
  45. data/lib/pry/commands/ls/instance_vars.rb +0 -1
  46. data/lib/pry/commands/ls/local_names.rb +0 -2
  47. data/lib/pry/commands/ls/local_vars.rb +0 -2
  48. data/lib/pry/commands/ls/ls_entity.rb +0 -1
  49. data/lib/pry/commands/ls/methods.rb +0 -3
  50. data/lib/pry/commands/ls/methods_helper.rb +1 -1
  51. data/lib/pry/commands/ls/self_methods.rb +0 -1
  52. data/lib/pry/commands/play.rb +1 -2
  53. data/lib/pry/commands/pry_backtrace.rb +1 -1
  54. data/lib/pry/commands/raise_up.rb +2 -1
  55. data/lib/pry/commands/ri.rb +5 -4
  56. data/lib/pry/commands/shell_command.rb +3 -2
  57. data/lib/pry/commands/shell_mode.rb +6 -6
  58. data/lib/pry/commands/show_doc.rb +5 -7
  59. data/lib/pry/commands/show_info.rb +25 -18
  60. data/lib/pry/commands/show_source.rb +5 -2
  61. data/lib/pry/commands/stat.rb +1 -1
  62. data/lib/pry/commands/watch_expression.rb +9 -7
  63. data/lib/pry/commands/whereami.rb +4 -4
  64. data/lib/pry/commands/wtf.rb +15 -2
  65. data/lib/pry/config.rb +33 -9
  66. data/lib/pry/config/behavior.rb +229 -205
  67. data/lib/pry/config/convenience.rb +24 -21
  68. data/lib/pry/config/default.rb +153 -143
  69. data/lib/pry/config/memoization.rb +41 -37
  70. data/lib/pry/core_extensions.rb +4 -3
  71. data/lib/pry/editor.rb +5 -12
  72. data/lib/pry/exceptions.rb +0 -2
  73. data/lib/pry/helpers.rb +1 -0
  74. data/lib/pry/helpers/base_helpers.rb +133 -4
  75. data/lib/pry/helpers/command_helpers.rb +5 -4
  76. data/lib/pry/helpers/documentation_helpers.rb +2 -2
  77. data/lib/pry/helpers/options_helpers.rb +5 -5
  78. data/lib/pry/helpers/platform.rb +58 -0
  79. data/lib/pry/helpers/table.rb +20 -15
  80. data/lib/pry/helpers/text.rb +3 -4
  81. data/lib/pry/history.rb +21 -8
  82. data/lib/pry/hooks.rb +3 -3
  83. data/lib/pry/indent.rb +15 -17
  84. data/lib/pry/input_completer.rb +12 -7
  85. data/lib/pry/input_lock.rb +0 -2
  86. data/lib/pry/last_exception.rb +1 -1
  87. data/lib/pry/method.rb +37 -31
  88. data/lib/pry/method/disowned.rb +2 -1
  89. data/lib/pry/method/patcher.rb +2 -2
  90. data/lib/pry/method/weird_method_locator.rb +7 -8
  91. data/lib/pry/object_path.rb +5 -4
  92. data/lib/pry/output.rb +3 -2
  93. data/lib/pry/pager.rb +4 -3
  94. data/lib/pry/platform.rb +79 -81
  95. data/lib/pry/plugins.rb +7 -3
  96. data/lib/pry/prompt.rb +144 -25
  97. data/lib/pry/pry_class.rb +53 -29
  98. data/lib/pry/pry_instance.rb +88 -55
  99. data/lib/pry/repl.rb +33 -4
  100. data/lib/pry/repl_file_loader.rb +1 -2
  101. data/lib/pry/ring.rb +84 -0
  102. data/lib/pry/rubygem.rb +6 -6
  103. data/lib/pry/slop.rb +17 -17
  104. data/lib/pry/slop/commands.rb +3 -4
  105. data/lib/pry/slop/option.rb +19 -21
  106. data/lib/pry/terminal.rb +2 -1
  107. data/lib/pry/testable/mockable.rb +2 -2
  108. data/lib/pry/testable/pry_tester.rb +1 -1
  109. data/lib/pry/testable/utility.rb +2 -2
  110. data/lib/pry/testable/variables.rb +1 -1
  111. data/lib/pry/version.rb +1 -1
  112. data/lib/pry/wrapped_module.rb +15 -15
  113. data/lib/pry/wrapped_module/candidate.rb +2 -2
  114. metadata +19 -31
  115. data/lib/pry/commands/list_prompts.rb +0 -35
  116. data/lib/pry/commands/simple_prompt.rb +0 -22
  117. data/lib/pry/history_array.rb +0 -121
  118. data/lib/pry/rbx_path.rb +0 -22
@@ -1,7 +1,16 @@
1
- require 'pry/config'
2
1
  class Pry
3
-
4
- HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
2
+ HOME_RC_FILE =
3
+ if ENV.key?('PRYRC')
4
+ ENV['PRYRC']
5
+ elsif File.exist?(File.expand_path('~/.pryrc'))
6
+ '~/.pryrc'
7
+ elsif ENV.key?('XDG_CONFIG_HOME') && ENV['XDG_CONFIG_HOME'] != ''
8
+ # See XDG Base Directory Specification at
9
+ # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
10
+ ENV['XDG_CONFIG_HOME'] + '/pry/pryrc'
11
+ else
12
+ '~/.config/pry/pryrc'
13
+ end
5
14
  LOCAL_RC_FILE = "./.pryrc"
6
15
 
7
16
  class << self
@@ -93,9 +102,7 @@ class Pry
93
102
 
94
103
  # Expand a file to its canonical name (following symlinks as appropriate)
95
104
  def self.real_path_to(file)
96
- expanded = Pathname.new(File.expand_path(file)).realpath.to_s
97
- # For rbx 1.9 mode [see rubinius issue #2165]
98
- File.exist?(expanded) ? expanded : nil
105
+ Pathname.new(File.expand_path(file)).realpath.to_s
99
106
  rescue Errno::ENOENT, Errno::EACCES
100
107
  nil
101
108
  end
@@ -110,7 +117,7 @@ class Pry
110
117
  # Trap interrupts on jruby, and make them behave like MRI so we can
111
118
  # catch them.
112
119
  def self.load_traps
113
- trap('INT'){ raise Interrupt }
120
+ trap('INT') { raise Interrupt }
114
121
  end
115
122
 
116
123
  def self.load_win32console
@@ -124,16 +131,16 @@ class Pry
124
131
  For a better Pry experience on Windows, please use ansicon:
125
132
  https://github.com/adoxa/ansicon
126
133
  If you use an alternative to ansicon and don't want to see this warning again,
127
- you can add "Pry.config.windows_console_warning = false" to your .pryrc.
134
+ you can add "Pry.config.windows_console_warning = false" to your pryrc.
128
135
  WARNING
129
136
  end
130
137
  end
131
138
 
132
- # Do basic setup for initial session.
133
- # Including: loading .pryrc, loading plugins, loading requires, and
134
- # loading history.
139
+ # Do basic setup for initial session including: loading pryrc, plugins,
140
+ # requires, and history.
135
141
  def self.initial_session_setup
136
142
  return unless initial_session?
143
+
137
144
  @initial_session = false
138
145
 
139
146
  # note these have to be loaded here rather than in pry_instance as
@@ -143,27 +150,28 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
143
150
 
144
151
  def self.final_session_setup
145
152
  return if @session_finalized
153
+
146
154
  @session_finalized = true
147
155
  load_plugins if Pry.config.should_load_plugins
148
156
  load_requires if Pry.config.should_load_requires
149
157
  load_history if Pry.config.history.should_load
150
158
  load_traps if Pry.config.should_trap_interrupts
151
- load_win32console if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi?
159
+ load_win32console if Helpers::Platform.windows? && !Helpers::Platform.windows_ansi?
152
160
  end
153
161
 
154
162
  # Start a Pry REPL.
155
- # This method also loads `~/.pryrc` and `./.pryrc` as necessary the
156
- # first time it is invoked.
163
+ # This method also loads `pryrc` as necessary the first time it is invoked.
157
164
  # @param [Object, Binding] target The receiver of the Pry session
158
165
  # @param [Hash] options
159
166
  # @option options (see Pry#initialize)
160
167
  # @example
161
168
  # Pry.start(Object.new, :input => MyInput.new)
162
- def self.start(target=nil, options={})
169
+ def self.start(target = nil, options = {})
163
170
  return if ENV['DISABLE_PRY']
164
171
  if ENV['FAIL_PRY']
165
172
  raise 'You have FAIL_PRY set to true, which results in Pry calls failing'
166
173
  end
174
+
167
175
  options = options.to_hash
168
176
 
169
177
  if in_critical_section?
@@ -231,7 +239,7 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
231
239
  # fixed as of https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039
232
240
  # we can drop in the future.
233
241
  obj.to_s
234
- elsif Pry.config.prompt_safe_objects.any? { |v| v === obj } && obj.inspect.length <= max
242
+ elsif Pry.config.prompt_safe_contexts.any? { |v| v === obj } && obj.inspect.length <= max
235
243
  obj.inspect
236
244
  else
237
245
  id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>"
@@ -267,19 +275,19 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
267
275
  # Pry.run_command "ls -m", :target => Pry
268
276
  # @example Display command output.
269
277
  # Pry.run_command "ls -av", :show_output => true
270
- def self.run_command(command_string, options={})
278
+ def self.run_command(command_string, options = {})
271
279
  options = {
272
- :target => TOPLEVEL_BINDING,
273
- :show_output => true,
274
- :output => Pry.config.output,
275
- :commands => Pry.config.commands
280
+ target: TOPLEVEL_BINDING,
281
+ show_output: true,
282
+ output: Pry.config.output,
283
+ commands: Pry.config.commands
276
284
  }.merge!(options)
277
285
 
278
286
  # :context for compatibility with <= 0.9.11.4
279
287
  target = options[:context] || options[:target]
280
288
  output = options[:show_output] ? options[:output] : StringIO.new
281
289
 
282
- pry = Pry.new(:output => output, :target => target, :commands => options[:commands])
290
+ pry = Pry.new(output: output, target: target, commands: options[:commands])
283
291
  pry.eval command_string
284
292
  nil
285
293
  end
@@ -287,12 +295,10 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
287
295
  def self.default_editor_for_platform
288
296
  return ENV['VISUAL'] if ENV['VISUAL'] and not ENV['VISUAL'].empty?
289
297
  return ENV['EDITOR'] if ENV['EDITOR'] and not ENV['EDITOR'].empty?
290
- if Helpers::BaseHelpers.windows?
291
- 'notepad'
292
- else
293
- %w(editor nano vi).detect do |editor|
294
- system("which #{editor} > /dev/null 2>&1")
295
- end
298
+ return 'notepad' if Helpers::Platform.windows?
299
+
300
+ %w(editor nano vi).detect do |editor|
301
+ system("which #{editor} > /dev/null 2>&1")
296
302
  end
297
303
  end
298
304
 
@@ -389,13 +395,31 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
389
395
  Thread.current[:pry_critical_section] > 0
390
396
  end
391
397
 
392
- def self.critical_section(&block)
398
+ def self.critical_section
393
399
  Thread.current[:pry_critical_section] ||= 0
394
400
  Thread.current[:pry_critical_section] += 1
395
401
  yield
396
402
  ensure
397
403
  Thread.current[:pry_critical_section] -= 1
398
404
  end
405
+
406
+ # Wraps a block in a named block called `Pry::Config::Lazy`. This is used for
407
+ # dynamic config values, which are calculated every time
408
+ # {Pry::Config::Lazy#call} is called.
409
+ #
410
+ # @example
411
+ # # pryrc
412
+ # Pry.config.prompt_name = Pry.lazy { rand(100) }
413
+ #
414
+ # # Session
415
+ # [1] 96(main)>
416
+ # [2] 19(main)>
417
+ # [3] 80(main)>
418
+ #
419
+ # @return [#call]
420
+ def self.lazy(&block)
421
+ Pry::Config::Lazy.new(&block)
422
+ end
399
423
  end
400
424
 
401
425
  Pry.init
@@ -21,6 +21,7 @@
21
21
  # * the IRC channel, which is #pry on the Freenode network
22
22
  #
23
23
 
24
+ # rubocop:disable Metrics/ClassLength
24
25
  class Pry
25
26
  attr_accessor :binding_stack
26
27
  attr_accessor :custom_completions
@@ -34,8 +35,13 @@ class Pry
34
35
  attr_reader :last_exception
35
36
  attr_reader :command_state
36
37
  attr_reader :exit_value
37
- attr_reader :input_array
38
- attr_reader :output_array
38
+
39
+ # @since v0.12.0
40
+ attr_reader :input_ring
41
+
42
+ # @since v0.12.0
43
+ attr_reader :output_ring
44
+
39
45
  attr_reader :config
40
46
 
41
47
  extend Pry::Config::Convenience
@@ -62,7 +68,7 @@ class Pry
62
68
  # The backtrace of the session's `binding.pry` line, if applicable.
63
69
  # @option options [Object] :target
64
70
  # The initial context for this session.
65
- def initialize(options={})
71
+ def initialize(options = {})
66
72
  @binding_stack = []
67
73
  @indent = Pry::Indent.new
68
74
  @command_state = {}
@@ -72,23 +78,47 @@ class Pry
72
78
  @config = Pry::Config.new
73
79
  config.merge!(options)
74
80
  push_prompt(config.prompt)
75
- @input_array = Pry::HistoryArray.new config.memory_size
76
- @output_array = Pry::HistoryArray.new config.memory_size
81
+ @input_ring = Pry::Ring.new(config.memory_size)
82
+ @output_ring = Pry::Ring.new(config.memory_size)
77
83
  @custom_completions = config.command_completions
78
84
  set_last_result nil
79
- @input_array << nil
85
+ @input_ring << nil
80
86
  push_initial_binding(target)
81
87
  exec_hook(:when_started, target, options, self)
82
88
  end
83
89
 
84
- # The current prompt.
90
+ @input_array_warn = false
91
+ # @deprecated Use {#input_ring} instead.
92
+ def input_array
93
+ unless @input_array_warn
94
+ loc = caller_locations(1..1).first
95
+ warn(
96
+ "#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
97
+ "is deprecated. Use #{self.class}#input_ring instead"
98
+ )
99
+ @input_array_warn = true
100
+ end
101
+
102
+ @input_ring
103
+ end
104
+
105
+ @output_array_warn = false
106
+ # @deprecated Use {#output_ring} instead.
107
+ def output_array
108
+ unless @output_array_warn
109
+ loc = caller_locations(1..1).first
110
+ warn(
111
+ "#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
112
+ "is deprecated. Use #{self.class}#output_ring instead"
113
+ )
114
+ @output_array_warn = true
115
+ end
116
+
117
+ @output_ring
118
+ end
119
+
85
120
  # This is the prompt at the top of the prompt stack.
86
- #
87
- # @example
88
- # self.prompt = Pry::SIMPLE_PROMPT
89
- # self.prompt # => Pry::SIMPLE_PROMPT
90
- #
91
- # @return [Array<Proc>] Current prompt.
121
+ # @return [Array<Proc>] the current prompt
92
122
  def prompt
93
123
  prompt_stack.last
94
124
  end
@@ -103,7 +133,7 @@ class Pry
103
133
 
104
134
  # Initialize this instance by pushing its initial context into the binding
105
135
  # stack. If no target is given, start at the top level.
106
- def push_initial_binding(target=nil)
136
+ def push_initial_binding(target = nil)
107
137
  push_binding(target || Pry.toplevel_binding)
108
138
  end
109
139
 
@@ -132,6 +162,7 @@ class Pry
132
162
  #
133
163
  def complete(str)
134
164
  return EMPTY_COMPLETIONS unless config.completer
165
+
135
166
  Pry.critical_section do
136
167
  completer = config.completer.new(config.input, self)
137
168
  completer.call str, target: current_binding, custom_completions: custom_completions.call.push(*sticky_locals.keys)
@@ -171,13 +202,13 @@ class Pry
171
202
  # @return [Integer] The maximum amount of objects remembered by the inp and
172
203
  # out arrays. Defaults to 100.
173
204
  def memory_size
174
- @output_array.max_size
205
+ @output_ring.max_size
175
206
  end
176
207
 
177
208
  undef :memory_size= if method_defined? :memory_size=
178
209
  def memory_size=(size)
179
- @input_array = Pry::HistoryArray.new(size)
180
- @output_array = Pry::HistoryArray.new(size)
210
+ @input_ring = Pry::Ring.new(size)
211
+ @output_ring = Pry::Ring.new(size)
181
212
  end
182
213
 
183
214
  # Inject all the sticky locals into the current binding.
@@ -197,14 +228,14 @@ class Pry
197
228
  end
198
229
 
199
230
  def sticky_locals
200
- { _in_: input_array,
201
- _out_: output_array,
231
+ { _in_: input_ring,
232
+ _out_: output_ring,
202
233
  _pry_: self,
203
234
  _ex_: last_exception && last_exception.wrapped_exception,
204
235
  _file_: last_file,
205
236
  _dir_: last_dir,
206
237
  _: proc { last_result },
207
- __: proc { output_array[-2] }
238
+ __: proc { output_ring[-2] }
208
239
  }.merge(config.extra_sticky_locals)
209
240
  end
210
241
 
@@ -234,7 +265,7 @@ class Pry
234
265
  # @return [Boolean] Is Pry ready to accept more input?
235
266
  # @raise [Exception] If the user uses the `raise-up` command, this method
236
267
  # will raise that exception.
237
- def eval(line, options={})
268
+ def eval(line, options = {})
238
269
  return false if @stopped
239
270
 
240
271
  exit_value = nil
@@ -254,6 +285,7 @@ class Pry
254
285
 
255
286
  # TODO: make this configurable?
256
287
  raise exception if exception
288
+
257
289
  return false
258
290
  end
259
291
 
@@ -310,7 +342,7 @@ class Pry
310
342
  # This workaround has a side effect: java exceptions specified
311
343
  # in `Pry.config.exception_whitelist` are ignored.
312
344
  jruby_exceptions = []
313
- if Pry::Helpers::BaseHelpers.jruby?
345
+ if Helpers::Platform.jruby?
314
346
  jruby_exceptions << Java::JavaLang::Exception
315
347
  end
316
348
 
@@ -325,7 +357,7 @@ class Pry
325
357
  # Eliminate following warning:
326
358
  # warning: singleton on non-persistent Java type X
327
359
  # (http://wiki.jruby.org/Persistence)
328
- if Pry::Helpers::BaseHelpers.jruby? && e.class.respond_to?('__persistent__')
360
+ if Helpers::Platform.jruby? && e.class.respond_to?('__persistent__')
329
361
  e.class.__persistent__ = true
330
362
  end
331
363
  self.last_exception = e
@@ -345,7 +377,7 @@ class Pry
345
377
  # (If nested sessions are going to exist, this method is fine, but a goal is
346
378
  # to come up with an alternative to nested sessions altogether.)
347
379
  def repl(target = nil)
348
- Pry::REPL.new(self, :target => target).start
380
+ Pry::REPL.new(self, target: target).start
349
381
  end
350
382
 
351
383
  def evaluate_ruby(code)
@@ -403,11 +435,11 @@ class Pry
403
435
  val = val.lstrip if /^\s\S/ !~ val
404
436
  val = val.chomp
405
437
  result = commands.process_line(val,
406
- :target => current_binding,
407
- :output => output,
408
- :eval_string => @eval_string,
409
- :pry_instance => self,
410
- :hooks => hooks
438
+ target: current_binding,
439
+ output: output,
440
+ eval_string: @eval_string,
441
+ pry_instance: self,
442
+ hooks: hooks
411
443
  )
412
444
 
413
445
  # set a temporary (just so we can inject the value we want into eval_string)
@@ -448,10 +480,10 @@ class Pry
448
480
  # pry_instance.run_command("ls -m")
449
481
  def run_command(val)
450
482
  commands.process_line(val,
451
- :eval_string => @eval_string,
452
- :target => current_binding,
453
- :pry_instance => self,
454
- :output => output
483
+ eval_string: @eval_string,
484
+ target: current_binding,
485
+ pry_instance: self,
486
+ output: output
455
487
  )
456
488
  Pry::Command::VOID_VALUE
457
489
  end
@@ -479,9 +511,9 @@ class Pry
479
511
  # This method should not need to be invoked directly.
480
512
  # @param [Object] result The result.
481
513
  # @param [String] code The code that was run.
482
- def set_last_result(result, code="")
514
+ def set_last_result(result, code = "")
483
515
  @last_result_is_exception = false
484
- @output_array << result
516
+ @output_ring << result
485
517
 
486
518
  self.last_result = result unless code =~ /\A\s*\z/
487
519
  end
@@ -495,7 +527,7 @@ class Pry
495
527
  def last_exception=(e)
496
528
  last_exception = Pry::LastException.new(e)
497
529
  @last_result_is_exception = true
498
- @output_array << last_exception
530
+ @output_ring << last_exception
499
531
  @last_exception = last_exception
500
532
  end
501
533
 
@@ -503,8 +535,8 @@ class Pry
503
535
  # This method should not need to be invoked directly.
504
536
  # @param [String] code The code we just eval'd
505
537
  def update_input_history(code)
506
- # Always push to the @input_array as the @output_array is always pushed to.
507
- @input_array << code
538
+ # Always push to the @input_ring as the @output_ring is always pushed to.
539
+ @input_ring << code
508
540
  if code
509
541
  Pry.line_buffer.push(*code.each_line)
510
542
  Pry.current_line += code.lines.count
@@ -529,28 +561,26 @@ class Pry
529
561
  # @return [String] The prompt.
530
562
  def select_prompt
531
563
  object = current_binding.eval('self')
532
-
533
- open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last :
534
- @indent.stack.last
535
-
536
- c = Pry::Config.from_hash({
537
- :object => object,
538
- :nesting_level => binding_stack.size - 1,
539
- :open_token => open_token,
540
- :session_line => Pry.history.session_line_count + 1,
541
- :history_line => Pry.history.history_line_count + 1,
542
- :expr_number => input_array.count,
543
- :_pry_ => self,
544
- :binding_stack => binding_stack,
545
- :input_array => input_array,
546
- :eval_string => @eval_string,
547
- :cont => !@eval_string.empty?})
564
+ open_token = @indent.open_delimiters.last || @indent.stack.last
565
+
566
+ c = Pry::Config.assign({
567
+ object: object,
568
+ nesting_level: binding_stack.size - 1,
569
+ open_token: open_token,
570
+ session_line: Pry.history.session_line_count + 1,
571
+ history_line: Pry.history.history_line_count + 1,
572
+ expr_number: input_ring.count,
573
+ _pry_: self,
574
+ binding_stack: binding_stack,
575
+ input_ring: input_ring,
576
+ eval_string: @eval_string,
577
+ cont: !@eval_string.empty?
578
+ })
548
579
 
549
580
  Pry.critical_section do
550
581
  # If input buffer is empty then use normal prompt
551
582
  if eval_string.empty?
552
583
  generate_prompt(Array(prompt).first, c)
553
-
554
584
  # Otherwise use the wait prompt (indicating multi-line expression)
555
585
  else
556
586
  generate_prompt(Array(prompt).last, c)
@@ -655,7 +685,9 @@ class Pry
655
685
  raise exception
656
686
  end
657
687
  end
688
+
658
689
  def raise_up(*args); raise_up_common(false, *args); end
690
+
659
691
  def raise_up!(*args); raise_up_common(true, *args); end
660
692
 
661
693
  # Convenience accessor for the `quiet` config key.
@@ -664,3 +696,4 @@ class Pry
664
696
  config.quiet
665
697
  end
666
698
  end
699
+ # rubocop:enable Metrics/ClassLength