pry 0.10.1 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +378 -11
  3. data/LICENSE +1 -1
  4. data/README.md +352 -306
  5. data/bin/pry +4 -7
  6. data/lib/pry/basic_object.rb +10 -0
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +81 -74
  10. data/lib/pry/code/code_file.rb +37 -26
  11. data/lib/pry/code/code_range.rb +7 -5
  12. data/lib/pry/code/loc.rb +26 -13
  13. data/lib/pry/code.rb +49 -30
  14. data/lib/pry/code_object.rb +53 -28
  15. data/lib/pry/color_printer.rb +46 -35
  16. data/lib/pry/command.rb +197 -369
  17. data/lib/pry/command_set.rb +89 -114
  18. data/lib/pry/command_state.rb +31 -0
  19. data/lib/pry/commands/amend_line.rb +86 -82
  20. data/lib/pry/commands/bang.rb +18 -14
  21. data/lib/pry/commands/bang_pry.rb +15 -11
  22. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  23. data/lib/pry/commands/cat/exception_formatter.rb +85 -72
  24. data/lib/pry/commands/cat/file_formatter.rb +56 -46
  25. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  26. data/lib/pry/commands/cat.rb +62 -54
  27. data/lib/pry/commands/cd.rb +40 -35
  28. data/lib/pry/commands/change_inspector.rb +29 -22
  29. data/lib/pry/commands/change_prompt.rb +48 -23
  30. data/lib/pry/commands/clear_screen.rb +20 -0
  31. data/lib/pry/commands/code_collector.rb +148 -131
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +23 -34
  34. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  35. data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
  36. data/lib/pry/commands/edit.rb +185 -157
  37. data/lib/pry/commands/exit.rb +40 -35
  38. data/lib/pry/commands/exit_all.rb +24 -20
  39. data/lib/pry/commands/exit_program.rb +20 -16
  40. data/lib/pry/commands/find_method.rb +168 -162
  41. data/lib/pry/commands/fix_indent.rb +16 -12
  42. data/lib/pry/commands/help.rb +140 -133
  43. data/lib/pry/commands/hist.rb +151 -149
  44. data/lib/pry/commands/import_set.rb +20 -15
  45. data/lib/pry/commands/jump_to.rb +25 -21
  46. data/lib/pry/commands/list_inspectors.rb +35 -28
  47. data/lib/pry/commands/ls/constants.rb +59 -31
  48. data/lib/pry/commands/ls/formatter.rb +42 -36
  49. data/lib/pry/commands/ls/globals.rb +38 -36
  50. data/lib/pry/commands/ls/grep.rb +17 -15
  51. data/lib/pry/commands/ls/instance_vars.rb +29 -28
  52. data/lib/pry/commands/ls/interrogatable.rb +18 -12
  53. data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
  54. data/lib/pry/commands/ls/local_names.rb +26 -24
  55. data/lib/pry/commands/ls/local_vars.rb +38 -30
  56. data/lib/pry/commands/ls/ls_entity.rb +47 -52
  57. data/lib/pry/commands/ls/methods.rb +49 -51
  58. data/lib/pry/commands/ls/methods_helper.rb +46 -42
  59. data/lib/pry/commands/ls/self_methods.rb +23 -21
  60. data/lib/pry/commands/ls.rb +124 -103
  61. data/lib/pry/commands/nesting.rb +21 -17
  62. data/lib/pry/commands/play.rb +92 -82
  63. data/lib/pry/commands/pry_backtrace.rb +22 -17
  64. data/lib/pry/commands/pry_version.rb +15 -11
  65. data/lib/pry/commands/raise_up.rb +33 -27
  66. data/lib/pry/commands/reload_code.rb +60 -48
  67. data/lib/pry/commands/reset.rb +16 -12
  68. data/lib/pry/commands/ri.rb +57 -42
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +56 -29
  71. data/lib/pry/commands/shell_mode.rb +22 -18
  72. data/lib/pry/commands/show_doc.rb +81 -70
  73. data/lib/pry/commands/show_info.rb +194 -155
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +109 -42
  76. data/lib/pry/commands/stat.rb +35 -31
  77. data/lib/pry/commands/switch_to.rb +21 -15
  78. data/lib/pry/commands/toggle_color.rb +20 -16
  79. data/lib/pry/commands/watch_expression/expression.rb +32 -27
  80. data/lib/pry/commands/watch_expression.rb +89 -84
  81. data/lib/pry/commands/whereami.rb +156 -141
  82. data/lib/pry/commands/wtf.rb +78 -40
  83. data/lib/pry/config/attributable.rb +22 -0
  84. data/lib/pry/config/lazy_value.rb +29 -0
  85. data/lib/pry/config/memoized_value.rb +34 -0
  86. data/lib/pry/config/value.rb +24 -0
  87. data/lib/pry/config.rb +317 -20
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +22 -9
  90. data/lib/pry/editor.rb +53 -33
  91. data/lib/pry/env.rb +18 -0
  92. data/lib/pry/exception_handler.rb +43 -0
  93. data/lib/pry/exceptions.rb +13 -17
  94. data/lib/pry/forwardable.rb +27 -0
  95. data/lib/pry/helpers/base_helpers.rb +20 -62
  96. data/lib/pry/helpers/command_helpers.rb +52 -62
  97. data/lib/pry/helpers/documentation_helpers.rb +20 -12
  98. data/lib/pry/helpers/options_helpers.rb +15 -8
  99. data/lib/pry/helpers/platform.rb +60 -0
  100. data/lib/pry/helpers/table.rb +44 -32
  101. data/lib/pry/helpers/text.rb +96 -85
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +81 -55
  104. data/lib/pry/hooks.rb +60 -110
  105. data/lib/pry/indent.rb +72 -66
  106. data/lib/pry/input_completer.rb +199 -158
  107. data/lib/pry/input_lock.rb +7 -10
  108. data/lib/pry/inspector.rb +36 -24
  109. data/lib/pry/last_exception.rb +45 -45
  110. data/lib/pry/method/disowned.rb +19 -5
  111. data/lib/pry/method/patcher.rb +14 -8
  112. data/lib/pry/method/weird_method_locator.rb +79 -43
  113. data/lib/pry/method.rb +177 -124
  114. data/lib/pry/object_path.rb +37 -28
  115. data/lib/pry/output.rb +102 -16
  116. data/lib/pry/pager.rb +187 -174
  117. data/lib/pry/plugins.rb +49 -13
  118. data/lib/pry/prompt.rb +213 -25
  119. data/lib/pry/pry_class.rb +106 -93
  120. data/lib/pry/pry_instance.rb +261 -224
  121. data/lib/pry/repl.rb +82 -27
  122. data/lib/pry/repl_file_loader.rb +27 -22
  123. data/lib/pry/ring.rb +89 -0
  124. data/lib/pry/slop/LICENSE +20 -0
  125. data/lib/pry/slop/commands.rb +190 -0
  126. data/lib/pry/slop/option.rb +210 -0
  127. data/lib/pry/slop.rb +672 -0
  128. data/lib/pry/syntax_highlighter.rb +26 -0
  129. data/lib/pry/system_command_handler.rb +17 -0
  130. data/lib/pry/testable/evalable.rb +24 -0
  131. data/lib/pry/testable/mockable.rb +22 -0
  132. data/lib/pry/testable/pry_tester.rb +88 -0
  133. data/lib/pry/testable/utility.rb +34 -0
  134. data/lib/pry/testable/variables.rb +52 -0
  135. data/lib/pry/testable.rb +68 -0
  136. data/lib/pry/version.rb +3 -1
  137. data/lib/pry/warning.rb +27 -0
  138. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +29 -27
  139. data/lib/pry/wrapped_module.rb +67 -57
  140. data/lib/pry.rb +134 -149
  141. metadata +49 -59
  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/gist.rb +0 -101
  148. data/lib/pry/commands/install_command.rb +0 -53
  149. data/lib/pry/commands/list_prompts.rb +0 -35
  150. data/lib/pry/commands/simple_prompt.rb +0 -22
  151. data/lib/pry/commands.rb +0 -6
  152. data/lib/pry/config/behavior.rb +0 -139
  153. data/lib/pry/config/convenience.rb +0 -25
  154. data/lib/pry/config/default.rb +0 -161
  155. data/lib/pry/history_array.rb +0 -121
  156. data/lib/pry/rbx_path.rb +0 -22
  157. data/lib/pry/rubygem.rb +0 -82
  158. data/lib/pry/terminal.rb +0 -79
  159. data/lib/pry/test/helper.rb +0 -170
@@ -1,4 +1,4 @@
1
- require 'pry/module_candidate'
1
+ # frozen_string_literal: true
2
2
 
3
3
  class Pry
4
4
  class << self
@@ -26,12 +26,8 @@ class Pry
26
26
  # @return [Module, nil] The module or `nil` (if conversion failed).
27
27
  # @example
28
28
  # Pry::WrappedModule.from_str("Pry::Code")
29
- def self.from_str(mod_name, target=TOPLEVEL_BINDING)
30
- if safe_to_evaluate?(mod_name, target)
31
- Pry::WrappedModule.new(target.eval(mod_name))
32
- else
33
- nil
34
- end
29
+ def self.from_str(mod_name, target = TOPLEVEL_BINDING)
30
+ Pry::WrappedModule.new(target.eval(mod_name)) if safe_to_evaluate?(mod_name, target)
35
31
  rescue RescuableException
36
32
  nil
37
33
  end
@@ -48,6 +44,8 @@ class Pry
48
44
  # @return [Boolean]
49
45
  def safe_to_evaluate?(str, target)
50
46
  return true if str.strip == "self"
47
+ return false if str =~ /%/
48
+
51
49
  kind = target.eval("defined?(#{str})")
52
50
  kind =~ /variable|constant/
53
51
  end
@@ -56,13 +54,18 @@ class Pry
56
54
  # @raise [ArgumentError] if the argument is not a `Module`
57
55
  # @param [Module] mod
58
56
  def initialize(mod)
59
- raise ArgumentError, "Tried to initialize a WrappedModule with a non-module #{mod.inspect}" unless ::Module === mod
57
+ unless mod.is_a?(Module)
58
+ raise ArgumentError, "Tried to initialize a WrappedModule with a " \
59
+ "non-module #{mod.inspect}"
60
+ end
61
+
60
62
  @wrapped = mod
61
63
  @memoized_candidates = []
62
64
  @host_file_lines = nil
63
65
  @source = nil
64
66
  @source_location = nil
65
67
  @doc = nil
68
+ @all_source_locations_by_popularity = nil
66
69
  end
67
70
 
68
71
  # Returns an array of the names of the constants accessible in the wrapped
@@ -81,7 +84,7 @@ class Pry
81
84
  # @return String
82
85
  def method_prefix
83
86
  if singleton_class?
84
- if Module === singleton_instance
87
+ if Module === singleton_instance # rubocop:disable Style/CaseEquality
85
88
  "#{WrappedModule.new(singleton_instance).nonblank_name}."
86
89
  else
87
90
  "self."
@@ -107,10 +110,6 @@ class Pry
107
110
  def singleton_class?
108
111
  if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
109
112
  Pry::Method.safe_send(wrapped, :singleton_class?)
110
- elsif defined?(Rubinius)
111
- # https://github.com/rubinius/rubinius/commit/2e71722dba53d1a92c54d5e3968d64d1042486fe singleton_class? added 30 Jul 2014
112
- # https://github.com/rubinius/rubinius/commit/4310f6b2ef3c8fc88135affe697db4e29e4621c4 has been around since 2011
113
- !!Rubinius::Type.singleton_class_object(wrapped)
114
113
  else
115
114
  wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
116
115
  end
@@ -134,29 +133,36 @@ class Pry
134
133
  #
135
134
  # @return [Object]
136
135
  def singleton_instance
137
- raise ArgumentError, "tried to get instance of non singleton class" unless singleton_class?
136
+ unless singleton_class?
137
+ raise ArgumentError, "tried to get instance of non singleton class"
138
+ end
138
139
 
139
- if Helpers::BaseHelpers.jruby?
140
+ if Helpers::Platform.jruby?
140
141
  wrapped.to_java.attached
141
142
  else
142
- @singleton_instance ||= ObjectSpace.each_object(wrapped).detect{ |x| (class << x; self; end) == wrapped }
143
+ @singleton_instance ||= ObjectSpace.each_object(wrapped).detect do |x|
144
+ (class << x; self; end) == wrapped
145
+ end
143
146
  end
144
147
  end
145
148
 
146
149
  # Forward method invocations to the wrapped module
147
150
  def method_missing(method_name, *args, &block)
148
- wrapped.send(method_name, *args, &block)
151
+ if wrapped.respond_to?(method_name)
152
+ wrapped.send(method_name, *args, &block)
153
+ else
154
+ super
155
+ end
149
156
  end
150
157
 
151
- def respond_to?(method_name)
152
- super || wrapped.respond_to?(method_name)
158
+ def respond_to_missing?(method_name, include_private = false)
159
+ wrapped.respond_to?(method_name, include_private) || super
153
160
  end
154
161
 
155
162
  # Retrieve the source location of a module. Return value is in same
156
163
  # format as Method#source_location. If the source location
157
164
  # cannot be found this method returns `nil`.
158
165
  #
159
- # @param [Module] mod The module (or class).
160
166
  # @return [Array<String, Fixnum>, nil] The source location of the
161
167
  # module (or class), or `nil` if no source location found.
162
168
  def source_location
@@ -170,14 +176,14 @@ class Pry
170
176
  def file
171
177
  Array(source_location).first
172
178
  end
173
- alias_method :source_file, :file
179
+ alias source_file file
174
180
 
175
181
  # @return [Fixnum, nil] The associated line for the module (i.e
176
182
  # the primary candidate: highest ranked monkeypatch).
177
183
  def line
178
184
  Array(source_location).last
179
185
  end
180
- alias_method :source_line, :line
186
+ alias source_line line
181
187
 
182
188
  # Returns documentation for the module.
183
189
  # This documentation is for the primary candidate, if
@@ -231,7 +237,7 @@ class Pry
231
237
  # @param [Fixnum] rank
232
238
  # @return [Pry::WrappedModule::Candidate]
233
239
  def candidate(rank)
234
- @memoized_candidates[rank] ||= Candidate.new(self, rank)
240
+ @memoized_candidates[rank] ||= WrappedModule::Candidate.new(self, rank)
235
241
  end
236
242
 
237
243
  # @return [Fixnum] The number of candidate definitions for the
@@ -248,11 +254,11 @@ class Pry
248
254
  # other rubies returns Enumerator
249
255
  def candidates
250
256
  enum = Enumerator.new do |y|
251
- (0...number_of_candidates).each do |num|
252
- y.yield candidate(num)
253
- end
254
- end
255
- Pry::Helpers::BaseHelpers.jruby_19? ? enum.to_a : enum
257
+ (0...number_of_candidates).each do |num|
258
+ y.yield candidate(num)
259
+ end
260
+ end
261
+ Helpers::Platform.jruby_19? ? enum.to_a : enum
256
262
  end
257
263
 
258
264
  # @return [Boolean] Whether YARD docs are available for this module.
@@ -266,14 +272,15 @@ class Pry
266
272
  # When `self` is a `Module` then return the
267
273
  # nth ancestor, otherwise (in the case of classes) return the
268
274
  # nth ancestor that is a class.
269
- def super(times=1)
275
+ def super(times = 1)
270
276
  return self if times.zero?
271
277
 
272
- if wrapped.is_a?(Class)
273
- sup = ancestors.select { |v| v.is_a?(Class) }[times]
274
- else
275
- sup = ancestors[times]
276
- end
278
+ sup =
279
+ if wrapped.is_a?(Class)
280
+ ancestors.select { |v| v.is_a?(Class) }[times]
281
+ else
282
+ ancestors[times]
283
+ end
277
284
 
278
285
  Pry::WrappedModule(sup) if sup
279
286
  end
@@ -288,9 +295,7 @@ class Pry
288
295
  # candidate of rank 0 will be returned, or a CommandError raised if
289
296
  # there are no candidates at all.
290
297
  def primary_candidate
291
- @primary_candidate ||= candidates.find { |c| c.file } ||
292
- # This will raise an exception if there is no candidate at all.
293
- candidate(0)
298
+ @primary_candidate ||= candidates.find(&:file) || candidate(0)
294
299
  end
295
300
 
296
301
  # @return [Array<Array<Pry::Method>>] The array of `Pry::Method` objects,
@@ -301,7 +306,7 @@ class Pry
301
306
  # speed up source code extraction.
302
307
  def method_candidates
303
308
  @method_candidates ||= all_source_locations_by_popularity.map do |group|
304
- methods_sorted_by_source_line = group.last.sort_by(&:source_line)
309
+ methods_sorted_by_source_line = group.last.sort_by(&:source_line)
305
310
  [methods_sorted_by_source_line.first, methods_sorted_by_source_line.last]
306
311
  end
307
312
  end
@@ -310,33 +315,35 @@ class Pry
310
315
  def all_source_locations_by_popularity
311
316
  return @all_source_locations_by_popularity if @all_source_locations_by_popularity
312
317
 
313
- ims = all_relevant_methods_for(wrapped)
314
- @all_source_locations_by_popularity = ims.group_by { |v| Array(v.source_location).first }.
315
- sort_by do |path, methods|
316
- expanded = File.expand_path(path)
317
- load_order = $LOADED_FEATURES.index{ |file| expanded.end_with?(file) }
318
+ ims = all_relevant_methods_for(wrapped).group_by do |v|
319
+ Array(v.source_location).first
320
+ end
321
+
322
+ @all_source_locations_by_popularity = ims.sort_by do |path, methods|
323
+ expanded = File.expand_path(path)
324
+ load_order = $LOADED_FEATURES.index { |file| expanded.end_with?(file) }
318
325
 
319
- [-methods.size, load_order || (1.0 / 0.0)]
320
- end
326
+ [-methods.size, load_order || (1.0 / 0.0)]
327
+ end
321
328
  end
322
329
 
323
330
  # We only want methods that have a non-nil `source_location`. We also
324
331
  # skip some spooky internal methods.
325
- # (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.)
332
+ #
326
333
  # @return [Array<Pry::Method>]
327
334
  def all_relevant_methods_for(mod)
328
- methods = all_methods_for(mod).select(&:source_location).
329
- reject{ |x| x.name == '__class_init__' || method_defined_by_forwardable_module?(x) }
335
+ methods = all_methods_for(mod).select(&:source_location)
336
+ .reject { |x| method_defined_by_forwardable_module?(x) }
330
337
 
331
338
  return methods unless methods.empty?
332
339
 
333
- safe_send(mod, :constants).map do |const_name|
334
- if const = nested_module?(mod, const_name)
340
+ safe_send(mod, :constants).flat_map do |const_name|
341
+ if (const = nested_module?(mod, const_name))
335
342
  all_relevant_methods_for(const)
336
343
  else
337
344
  []
338
345
  end
339
- end.flatten
346
+ end
340
347
  end
341
348
 
342
349
  # Return all methods (instance methods and class methods) for a
@@ -348,9 +355,11 @@ class Pry
348
355
 
349
356
  def nested_module?(parent, name)
350
357
  return if safe_send(parent, :autoload?, name)
358
+
351
359
  child = safe_send(parent, :const_get, name)
352
- return unless Module === child
360
+ return unless child.is_a?(Module)
353
361
  return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}"
362
+
354
363
  child
355
364
  end
356
365
 
@@ -367,11 +376,12 @@ class Pry
367
376
  def lines_for_file(file)
368
377
  @lines_for_file ||= {}
369
378
 
370
- if file == Pry.eval_path
371
- @lines_for_file[file] ||= Pry.line_buffer.drop(1)
372
- else
373
- @lines_for_file[file] ||= File.readlines(file)
374
- end
379
+ @lines_for_file[file] ||=
380
+ if file == Pry.eval_path
381
+ Pry.line_buffer.drop(1)
382
+ else
383
+ File.readlines(file)
384
+ end
375
385
  end
376
386
  end
377
387
  end
data/lib/pry.rb CHANGED
@@ -1,161 +1,146 @@
1
- # (C) John Mair (banisterfiend) 2013
2
- # MIT License
3
- #
4
- require 'pp'
1
+ # frozen_string_literal: true
5
2
 
6
- require 'pry/input_lock'
7
- require 'pry/exceptions'
8
- require 'pry/helpers/base_helpers'
9
- require 'pry/hooks'
10
- require 'forwardable'
11
-
12
- class Pry
13
- # The default hooks - display messages when beginning and ending Pry sessions.
14
- DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_|
15
- next if _pry_.quiet?
16
- _pry_.run_command("whereami --quiet")
17
- end
18
-
19
- # The default print
20
- DEFAULT_PRINT = proc do |output, value, _pry_|
21
- _pry_.pager.open do |pager|
22
- pager.print _pry_.config.output_prefix
23
- Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
24
- end
25
- end
26
-
27
- # may be convenient when working with enormous objects and
28
- # pretty_print is too slow
29
- SIMPLE_PRINT = proc do |output, value|
30
- begin
31
- output.puts value.inspect
32
- rescue RescuableException
33
- output.puts "unknown"
34
- end
35
- end
36
-
37
- # useful when playing with truly enormous objects
38
- CLIPPED_PRINT = proc do |output, value|
39
- output.puts Pry.view_clip(value, id: true)
40
- end
41
-
42
- # Will only show the first line of the backtrace
43
- DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _|
44
- if UserError === exception && SyntaxError === exception
45
- output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}"
46
- else
47
- output.puts "#{exception.class}: #{exception.message}"
48
- output.puts "from #{exception.backtrace.first}"
49
- end
50
- end
51
-
52
- DEFAULT_PROMPT_NAME = 'pry'
53
-
54
- # The default prompt; includes the target and nesting level
55
- DEFAULT_PROMPT = [
56
- proc { |target_self, nest_level, pry|
57
- "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
58
- },
59
-
60
- proc { |target_self, nest_level, pry|
61
- "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
62
- }
63
- ]
64
-
65
- DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false]
66
-
67
- # A simple prompt - doesn't display target or nesting level
68
- SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
69
-
70
- NO_PROMPT = [proc { '' }, proc { '' }]
71
-
72
- SHELL_PROMPT = [
73
- proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
74
- proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
75
- ]
76
-
77
- # A prompt that includes the full object path as well as
78
- # input/output (_in_ and _out_) information. Good for navigation.
79
- NAV_PROMPT = [
80
- proc do |_, _, _pry_|
81
- tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
82
- "[#{_pry_.input_array.count}] (#{_pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}> "
83
- end,
84
- proc do |_, _, _pry_|
85
- tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
86
- "[#{_pry_.input_array.count}] (#{ _pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}* "
87
- end,
88
- ]
89
-
90
- # Deal with the ^D key being pressed. Different behaviour in different cases:
91
- # 1. In an expression behave like `!` command.
92
- # 2. At top-level session behave like `exit` command.
93
- # 3. In a nested session behave like `cd ..`.
94
- DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
95
- if !eval_string.empty?
96
- eval_string.replace('') # Clear input buffer.
97
- elsif _pry_.binding_stack.one?
98
- _pry_.binding_stack.clear
99
- throw(:breakout)
100
- else
101
- # Otherwise, saves current binding stack as old stack and pops last
102
- # binding out of binding stack (the old stack still has that binding).
103
- _pry_.command_state["cd"] ||= Pry::Config.from_hash({}) # FIXME
104
- _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup
105
- _pry_.binding_stack.pop
106
- end
107
- end
108
-
109
- DEFAULT_SYSTEM = proc do |output, cmd, _|
110
- if !system(cmd)
111
- output.puts "Error: there was a problem executing system command: #{cmd}"
112
- end
113
- end
114
-
115
- # Store the current working directory. This allows show-source etc. to work if
116
- # your process has changed directory since boot. [Issue #675]
117
- INITIAL_PWD = Dir.pwd
118
-
119
- # This is to keep from breaking under Rails 3.2 for people who are doing that
120
- # IRB = Pry thing.
121
- module ExtendCommandBundle; end
122
- end
123
-
124
- require 'method_source'
125
- require 'shellwords'
126
- require 'stringio'
127
- require 'coderay'
128
- require 'slop'
129
- require 'rbconfig'
130
- require 'tempfile'
131
- require 'pathname'
3
+ # (C) John Mair (banisterfiend) 2016
4
+ # MIT License
132
5
 
133
6
  require 'pry/version'
134
- require 'pry/repl'
135
- require 'pry/rbx_path'
136
- require 'pry/code'
137
- require 'pry/history_array'
7
+ require 'pry/last_exception'
8
+ require 'pry/forwardable'
9
+
10
+ require 'pry/helpers/base_helpers'
11
+ require 'pry/helpers/documentation_helpers'
138
12
  require 'pry/helpers'
13
+
14
+ require 'pry/basic_object'
15
+ require 'pry/prompt'
16
+ require 'pry/plugins'
139
17
  require 'pry/code_object'
140
- require 'pry/method'
141
- require 'pry/wrapped_module'
142
- require 'pry/history'
18
+ require 'pry/exceptions'
19
+ require 'pry/hooks'
20
+ require 'pry/input_completer'
143
21
  require 'pry/command'
22
+ require 'pry/class_command'
23
+ require 'pry/block_command'
144
24
  require 'pry/command_set'
145
- require 'pry/commands'
146
- require 'pry/plugins'
147
- require 'pry/core_extensions'
25
+ require 'pry/syntax_highlighter'
26
+ require 'pry/editor'
27
+ require 'pry/history'
28
+ require 'pry/color_printer'
29
+ require 'pry/exception_handler'
30
+ require 'pry/system_command_handler'
31
+ require 'pry/control_d_handler'
32
+ require 'pry/command_state'
33
+ require 'pry/warning'
34
+ require 'pry/env'
35
+
36
+ Pry::Commands = Pry::CommandSet.new unless defined?(Pry::Commands)
37
+
38
+ require 'pry/commands/ls/jruby_hacks'
39
+ require 'pry/commands/ls/methods_helper'
40
+ require 'pry/commands/ls/interrogatable'
41
+ require 'pry/commands/ls/grep'
42
+ require 'pry/commands/ls/formatter'
43
+ require 'pry/commands/ls/globals'
44
+ require 'pry/commands/ls/constants'
45
+ require 'pry/commands/ls/methods'
46
+ require 'pry/commands/ls/self_methods'
47
+ require 'pry/commands/ls/instance_vars'
48
+ require 'pry/commands/ls/local_names'
49
+ require 'pry/commands/ls/local_vars'
50
+ require 'pry/commands/ls/interrogatable'
51
+ require 'pry/commands/ls/ls_entity'
52
+ require 'pry/commands/ls/methods_helper'
53
+ require 'pry/commands/ls'
54
+
55
+ require 'pry/config/attributable'
56
+ require 'pry/config/value'
57
+ require 'pry/config/memoized_value'
58
+ require 'pry/config/lazy_value'
59
+ require 'pry/config'
60
+
148
61
  require 'pry/pry_class'
149
62
  require 'pry/pry_instance'
150
- require 'pry/cli'
151
- require 'pry/color_printer'
63
+ require 'pry/inspector'
152
64
  require 'pry/pager'
153
- require 'pry/terminal'
154
- require 'pry/editor'
155
- require 'pry/rubygem'
156
- require "pry/indent"
157
- require "pry/last_exception"
158
- require "pry/prompt"
159
- require "pry/inspector"
65
+ require 'pry/indent'
160
66
  require 'pry/object_path'
161
67
  require 'pry/output'
68
+ require 'pry/input_lock'
69
+ require 'pry/repl'
70
+ require 'pry/code'
71
+ require 'pry/ring'
72
+ require 'pry/method'
73
+
74
+ require 'pry/wrapped_module'
75
+ require 'pry/wrapped_module/candidate'
76
+
77
+ require 'pry/slop'
78
+ require 'pry/cli'
79
+ require 'pry/core_extensions'
80
+ require 'pry/repl_file_loader'
81
+
82
+ require 'pry/code/loc'
83
+ require 'pry/code/code_range'
84
+ require 'pry/code/code_file'
85
+
86
+ require 'pry/method/weird_method_locator'
87
+ require 'pry/method/disowned'
88
+ require 'pry/method/patcher'
89
+
90
+ require 'pry/commands/amend_line'
91
+ require 'pry/commands/bang'
92
+ require 'pry/commands/bang_pry'
93
+
94
+ require 'pry/commands/cat'
95
+ require 'pry/commands/cat/abstract_formatter.rb'
96
+ require 'pry/commands/cat/input_expression_formatter.rb'
97
+ require 'pry/commands/cat/exception_formatter.rb'
98
+ require 'pry/commands/cat/file_formatter.rb'
99
+
100
+ require 'pry/commands/cd'
101
+ require 'pry/commands/change_inspector'
102
+ require 'pry/commands/change_prompt'
103
+ require 'pry/commands/clear_screen'
104
+ require 'pry/commands/code_collector'
105
+ require 'pry/commands/disable_pry'
106
+ require 'pry/commands/easter_eggs'
107
+
108
+ require 'pry/commands/edit'
109
+ require 'pry/commands/edit/exception_patcher'
110
+ require 'pry/commands/edit/file_and_line_locator'
111
+
112
+ require 'pry/commands/exit'
113
+ require 'pry/commands/exit_all'
114
+ require 'pry/commands/exit_program'
115
+ require 'pry/commands/find_method'
116
+ require 'pry/commands/fix_indent'
117
+ require 'pry/commands/help'
118
+ require 'pry/commands/hist'
119
+ require 'pry/commands/import_set'
120
+ require 'pry/commands/jump_to'
121
+ require 'pry/commands/list_inspectors'
122
+
123
+ require 'pry/commands/nesting'
124
+ require 'pry/commands/play'
125
+ require 'pry/commands/pry_backtrace'
126
+ require 'pry/commands/pry_version'
127
+ require 'pry/commands/raise_up'
128
+ require 'pry/commands/reload_code'
129
+ require 'pry/commands/reset'
130
+ require 'pry/commands/ri'
131
+ require 'pry/commands/save_file'
132
+ require 'pry/commands/shell_command'
133
+ require 'pry/commands/shell_mode'
134
+ require 'pry/commands/show_info'
135
+ require 'pry/commands/show_doc'
136
+ require 'pry/commands/show_input'
137
+ require 'pry/commands/show_source'
138
+ require 'pry/commands/stat'
139
+ require 'pry/commands/switch_to'
140
+ require 'pry/commands/toggle_color'
141
+
142
+ require 'pry/commands/watch_expression'
143
+ require 'pry/commands/watch_expression/expression.rb'
144
+
145
+ require 'pry/commands/whereami'
146
+ require 'pry/commands/wtf'