pry 0.10.4 → 0.14.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 +408 -16
  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 +83 -96
  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 -32
  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 +80 -70
  73. data/lib/pry/commands/show_info.rb +193 -160
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +110 -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 +155 -146
  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 +313 -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 -18
  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 +21 -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 -45
  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 -177
  117. data/lib/pry/prompt.rb +213 -25
  118. data/lib/pry/pry_class.rb +106 -98
  119. data/lib/pry/pry_instance.rb +261 -224
  120. data/lib/pry/repl.rb +82 -27
  121. data/lib/pry/repl_file_loader.rb +27 -22
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/LICENSE +20 -0
  124. data/lib/pry/slop/commands.rb +190 -0
  125. data/lib/pry/slop/option.rb +210 -0
  126. data/lib/pry/slop.rb +672 -0
  127. data/lib/pry/syntax_highlighter.rb +26 -0
  128. data/lib/pry/system_command_handler.rb +17 -0
  129. data/lib/pry/testable/evalable.rb +24 -0
  130. data/lib/pry/testable/mockable.rb +22 -0
  131. data/lib/pry/testable/pry_tester.rb +88 -0
  132. data/lib/pry/testable/utility.rb +34 -0
  133. data/lib/pry/testable/variables.rb +52 -0
  134. data/lib/pry/testable.rb +68 -0
  135. data/lib/pry/version.rb +3 -1
  136. data/lib/pry/warning.rb +27 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +28 -27
  138. data/lib/pry/wrapped_module.rb +66 -57
  139. data/lib/pry.rb +133 -149
  140. metadata +52 -63
  141. data/lib/pry/commands/disabled_commands.rb +0 -2
  142. data/lib/pry/commands/gem_cd.rb +0 -26
  143. data/lib/pry/commands/gem_install.rb +0 -32
  144. data/lib/pry/commands/gem_list.rb +0 -33
  145. data/lib/pry/commands/gem_open.rb +0 -29
  146. data/lib/pry/commands/gist.rb +0 -101
  147. data/lib/pry/commands/install_command.rb +0 -53
  148. data/lib/pry/commands/list_prompts.rb +0 -35
  149. data/lib/pry/commands/simple_prompt.rb +0 -22
  150. data/lib/pry/commands.rb +0 -6
  151. data/lib/pry/config/behavior.rb +0 -139
  152. data/lib/pry/config/convenience.rb +0 -25
  153. data/lib/pry/config/default.rb +0 -161
  154. data/lib/pry/history_array.rb +0 -121
  155. data/lib/pry/plugins.rb +0 -103
  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,7 +54,11 @@ 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
@@ -82,7 +84,7 @@ class Pry
82
84
  # @return String
83
85
  def method_prefix
84
86
  if singleton_class?
85
- if Module === singleton_instance
87
+ if Module === singleton_instance # rubocop:disable Style/CaseEquality
86
88
  "#{WrappedModule.new(singleton_instance).nonblank_name}."
87
89
  else
88
90
  "self."
@@ -108,10 +110,6 @@ class Pry
108
110
  def singleton_class?
109
111
  if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
110
112
  Pry::Method.safe_send(wrapped, :singleton_class?)
111
- elsif defined?(Rubinius)
112
- # https://github.com/rubinius/rubinius/commit/2e71722dba53d1a92c54d5e3968d64d1042486fe singleton_class? added 30 Jul 2014
113
- # https://github.com/rubinius/rubinius/commit/4310f6b2ef3c8fc88135affe697db4e29e4621c4 has been around since 2011
114
- !!Rubinius::Type.singleton_class_object(wrapped)
115
113
  else
116
114
  wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
117
115
  end
@@ -135,29 +133,36 @@ class Pry
135
133
  #
136
134
  # @return [Object]
137
135
  def singleton_instance
138
- 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
139
139
 
140
- if Helpers::BaseHelpers.jruby?
140
+ if Helpers::Platform.jruby?
141
141
  wrapped.to_java.attached
142
142
  else
143
- @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
144
146
  end
145
147
  end
146
148
 
147
149
  # Forward method invocations to the wrapped module
148
150
  def method_missing(method_name, *args, &block)
149
- 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
150
156
  end
151
157
 
152
- def respond_to?(method_name)
153
- 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
154
160
  end
155
161
 
156
162
  # Retrieve the source location of a module. Return value is in same
157
163
  # format as Method#source_location. If the source location
158
164
  # cannot be found this method returns `nil`.
159
165
  #
160
- # @param [Module] mod The module (or class).
161
166
  # @return [Array<String, Fixnum>, nil] The source location of the
162
167
  # module (or class), or `nil` if no source location found.
163
168
  def source_location
@@ -171,14 +176,14 @@ class Pry
171
176
  def file
172
177
  Array(source_location).first
173
178
  end
174
- alias_method :source_file, :file
179
+ alias source_file file
175
180
 
176
181
  # @return [Fixnum, nil] The associated line for the module (i.e
177
182
  # the primary candidate: highest ranked monkeypatch).
178
183
  def line
179
184
  Array(source_location).last
180
185
  end
181
- alias_method :source_line, :line
186
+ alias source_line line
182
187
 
183
188
  # Returns documentation for the module.
184
189
  # This documentation is for the primary candidate, if
@@ -232,7 +237,7 @@ class Pry
232
237
  # @param [Fixnum] rank
233
238
  # @return [Pry::WrappedModule::Candidate]
234
239
  def candidate(rank)
235
- @memoized_candidates[rank] ||= Candidate.new(self, rank)
240
+ @memoized_candidates[rank] ||= WrappedModule::Candidate.new(self, rank)
236
241
  end
237
242
 
238
243
  # @return [Fixnum] The number of candidate definitions for the
@@ -249,11 +254,11 @@ class Pry
249
254
  # other rubies returns Enumerator
250
255
  def candidates
251
256
  enum = Enumerator.new do |y|
252
- (0...number_of_candidates).each do |num|
253
- y.yield candidate(num)
254
- end
255
- end
256
- 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
257
262
  end
258
263
 
259
264
  # @return [Boolean] Whether YARD docs are available for this module.
@@ -267,14 +272,15 @@ class Pry
267
272
  # When `self` is a `Module` then return the
268
273
  # nth ancestor, otherwise (in the case of classes) return the
269
274
  # nth ancestor that is a class.
270
- def super(times=1)
275
+ def super(times = 1)
271
276
  return self if times.zero?
272
277
 
273
- if wrapped.is_a?(Class)
274
- sup = ancestors.select { |v| v.is_a?(Class) }[times]
275
- else
276
- sup = ancestors[times]
277
- 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
278
284
 
279
285
  Pry::WrappedModule(sup) if sup
280
286
  end
@@ -289,9 +295,7 @@ class Pry
289
295
  # candidate of rank 0 will be returned, or a CommandError raised if
290
296
  # there are no candidates at all.
291
297
  def primary_candidate
292
- @primary_candidate ||= candidates.find { |c| c.file } ||
293
- # This will raise an exception if there is no candidate at all.
294
- candidate(0)
298
+ @primary_candidate ||= candidates.find(&:file) || candidate(0)
295
299
  end
296
300
 
297
301
  # @return [Array<Array<Pry::Method>>] The array of `Pry::Method` objects,
@@ -302,7 +306,7 @@ class Pry
302
306
  # speed up source code extraction.
303
307
  def method_candidates
304
308
  @method_candidates ||= all_source_locations_by_popularity.map do |group|
305
- methods_sorted_by_source_line = group.last.sort_by(&:source_line)
309
+ methods_sorted_by_source_line = group.last.sort_by(&:source_line)
306
310
  [methods_sorted_by_source_line.first, methods_sorted_by_source_line.last]
307
311
  end
308
312
  end
@@ -311,33 +315,35 @@ class Pry
311
315
  def all_source_locations_by_popularity
312
316
  return @all_source_locations_by_popularity if @all_source_locations_by_popularity
313
317
 
314
- ims = all_relevant_methods_for(wrapped)
315
- @all_source_locations_by_popularity = ims.group_by { |v| Array(v.source_location).first }.
316
- sort_by do |path, methods|
317
- expanded = File.expand_path(path)
318
- 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) }
319
325
 
320
- [-methods.size, load_order || (1.0 / 0.0)]
321
- end
326
+ [-methods.size, load_order || (1.0 / 0.0)]
327
+ end
322
328
  end
323
329
 
324
330
  # We only want methods that have a non-nil `source_location`. We also
325
331
  # skip some spooky internal methods.
326
- # (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.)
332
+ #
327
333
  # @return [Array<Pry::Method>]
328
334
  def all_relevant_methods_for(mod)
329
- methods = all_methods_for(mod).select(&:source_location).
330
- 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) }
331
337
 
332
338
  return methods unless methods.empty?
333
339
 
334
- safe_send(mod, :constants).map do |const_name|
335
- 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))
336
342
  all_relevant_methods_for(const)
337
343
  else
338
344
  []
339
345
  end
340
- end.flatten
346
+ end
341
347
  end
342
348
 
343
349
  # Return all methods (instance methods and class methods) for a
@@ -349,9 +355,11 @@ class Pry
349
355
 
350
356
  def nested_module?(parent, name)
351
357
  return if safe_send(parent, :autoload?, name)
358
+
352
359
  child = safe_send(parent, :const_get, name)
353
- return unless Module === child
360
+ return unless child.is_a?(Module)
354
361
  return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}"
362
+
355
363
  child
356
364
  end
357
365
 
@@ -368,11 +376,12 @@ class Pry
368
376
  def lines_for_file(file)
369
377
  @lines_for_file ||= {}
370
378
 
371
- if file == Pry.eval_path
372
- @lines_for_file[file] ||= Pry.line_buffer.drop(1)
373
- else
374
- @lines_for_file[file] ||= File.readlines(file)
375
- 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
376
385
  end
377
386
  end
378
387
  end
data/lib/pry.rb CHANGED
@@ -1,161 +1,145 @@
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'
139
16
  require 'pry/code_object'
140
- require 'pry/method'
141
- require 'pry/wrapped_module'
142
- require 'pry/history'
17
+ require 'pry/exceptions'
18
+ require 'pry/hooks'
19
+ require 'pry/input_completer'
143
20
  require 'pry/command'
21
+ require 'pry/class_command'
22
+ require 'pry/block_command'
144
23
  require 'pry/command_set'
145
- require 'pry/commands'
146
- require 'pry/plugins'
147
- require 'pry/core_extensions'
24
+ require 'pry/syntax_highlighter'
25
+ require 'pry/editor'
26
+ require 'pry/history'
27
+ require 'pry/color_printer'
28
+ require 'pry/exception_handler'
29
+ require 'pry/system_command_handler'
30
+ require 'pry/control_d_handler'
31
+ require 'pry/command_state'
32
+ require 'pry/warning'
33
+ require 'pry/env'
34
+
35
+ Pry::Commands = Pry::CommandSet.new unless defined?(Pry::Commands)
36
+
37
+ require 'pry/commands/ls/jruby_hacks'
38
+ require 'pry/commands/ls/methods_helper'
39
+ require 'pry/commands/ls/interrogatable'
40
+ require 'pry/commands/ls/grep'
41
+ require 'pry/commands/ls/formatter'
42
+ require 'pry/commands/ls/globals'
43
+ require 'pry/commands/ls/constants'
44
+ require 'pry/commands/ls/methods'
45
+ require 'pry/commands/ls/self_methods'
46
+ require 'pry/commands/ls/instance_vars'
47
+ require 'pry/commands/ls/local_names'
48
+ require 'pry/commands/ls/local_vars'
49
+ require 'pry/commands/ls/interrogatable'
50
+ require 'pry/commands/ls/ls_entity'
51
+ require 'pry/commands/ls/methods_helper'
52
+ require 'pry/commands/ls'
53
+
54
+ require 'pry/config/attributable'
55
+ require 'pry/config/value'
56
+ require 'pry/config/memoized_value'
57
+ require 'pry/config/lazy_value'
58
+ require 'pry/config'
59
+
148
60
  require 'pry/pry_class'
149
61
  require 'pry/pry_instance'
150
- require 'pry/cli'
151
- require 'pry/color_printer'
62
+ require 'pry/inspector'
152
63
  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"
64
+ require 'pry/indent'
160
65
  require 'pry/object_path'
161
66
  require 'pry/output'
67
+ require 'pry/input_lock'
68
+ require 'pry/repl'
69
+ require 'pry/code'
70
+ require 'pry/ring'
71
+ require 'pry/method'
72
+
73
+ require 'pry/wrapped_module'
74
+ require 'pry/wrapped_module/candidate'
75
+
76
+ require 'pry/slop'
77
+ require 'pry/cli'
78
+ require 'pry/core_extensions'
79
+ require 'pry/repl_file_loader'
80
+
81
+ require 'pry/code/loc'
82
+ require 'pry/code/code_range'
83
+ require 'pry/code/code_file'
84
+
85
+ require 'pry/method/weird_method_locator'
86
+ require 'pry/method/disowned'
87
+ require 'pry/method/patcher'
88
+
89
+ require 'pry/commands/amend_line'
90
+ require 'pry/commands/bang'
91
+ require 'pry/commands/bang_pry'
92
+
93
+ require 'pry/commands/cat'
94
+ require 'pry/commands/cat/abstract_formatter.rb'
95
+ require 'pry/commands/cat/input_expression_formatter.rb'
96
+ require 'pry/commands/cat/exception_formatter.rb'
97
+ require 'pry/commands/cat/file_formatter.rb'
98
+
99
+ require 'pry/commands/cd'
100
+ require 'pry/commands/change_inspector'
101
+ require 'pry/commands/change_prompt'
102
+ require 'pry/commands/clear_screen'
103
+ require 'pry/commands/code_collector'
104
+ require 'pry/commands/disable_pry'
105
+ require 'pry/commands/easter_eggs'
106
+
107
+ require 'pry/commands/edit'
108
+ require 'pry/commands/edit/exception_patcher'
109
+ require 'pry/commands/edit/file_and_line_locator'
110
+
111
+ require 'pry/commands/exit'
112
+ require 'pry/commands/exit_all'
113
+ require 'pry/commands/exit_program'
114
+ require 'pry/commands/find_method'
115
+ require 'pry/commands/fix_indent'
116
+ require 'pry/commands/help'
117
+ require 'pry/commands/hist'
118
+ require 'pry/commands/import_set'
119
+ require 'pry/commands/jump_to'
120
+ require 'pry/commands/list_inspectors'
121
+
122
+ require 'pry/commands/nesting'
123
+ require 'pry/commands/play'
124
+ require 'pry/commands/pry_backtrace'
125
+ require 'pry/commands/pry_version'
126
+ require 'pry/commands/raise_up'
127
+ require 'pry/commands/reload_code'
128
+ require 'pry/commands/reset'
129
+ require 'pry/commands/ri'
130
+ require 'pry/commands/save_file'
131
+ require 'pry/commands/shell_command'
132
+ require 'pry/commands/shell_mode'
133
+ require 'pry/commands/show_info'
134
+ require 'pry/commands/show_doc'
135
+ require 'pry/commands/show_input'
136
+ require 'pry/commands/show_source'
137
+ require 'pry/commands/stat'
138
+ require 'pry/commands/switch_to'
139
+ require 'pry/commands/toggle_color'
140
+
141
+ require 'pry/commands/watch_expression'
142
+ require 'pry/commands/watch_expression/expression.rb'
143
+
144
+ require 'pry/commands/whereami'
145
+ require 'pry/commands/wtf'