pry 0.10.3 → 0.14.2

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 +439 -16
  3. data/LICENSE +1 -1
  4. data/README.md +362 -302
  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 +84 -97
  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 +42 -31
  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 +194 -155
  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 +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 +310 -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 +56 -34
  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 +55 -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 +74 -68
  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 +178 -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/prompt.rb +213 -25
  118. data/lib/pry/pry_class.rb +119 -98
  119. data/lib/pry/pry_instance.rb +261 -224
  120. data/lib/pry/repl.rb +83 -29
  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 +20 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +35 -32
  138. data/lib/pry/wrapped_module.rb +68 -63
  139. data/lib/pry.rb +133 -149
  140. metadata +58 -69
  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,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
@@ -240,19 +246,14 @@ class Pry
240
246
  method_candidates.count
241
247
  end
242
248
 
243
- # @note On JRuby 1.9 and higher, in certain conditions, this method chucks
244
- # away its ability to be quick (when there are lots of monkey patches,
245
- # like in Rails). However, it should be efficient enough on other rubies.
246
- # @see https://github.com/jruby/jruby/issues/525
247
- # @return [Enumerator, Array] on JRuby 1.9 and higher returns Array, on
248
- # other rubies returns Enumerator
249
+ # @return [Array]
249
250
  def candidates
250
251
  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
252
+ (0...number_of_candidates).each do |num|
253
+ y.yield candidate(num)
254
+ end
255
+ end
256
+ enum
256
257
  end
257
258
 
258
259
  # @return [Boolean] Whether YARD docs are available for this module.
@@ -266,14 +267,15 @@ class Pry
266
267
  # When `self` is a `Module` then return the
267
268
  # nth ancestor, otherwise (in the case of classes) return the
268
269
  # nth ancestor that is a class.
269
- def super(times=1)
270
+ def super(times = 1)
270
271
  return self if times.zero?
271
272
 
272
- if wrapped.is_a?(Class)
273
- sup = ancestors.select { |v| v.is_a?(Class) }[times]
274
- else
275
- sup = ancestors[times]
276
- end
273
+ sup =
274
+ if wrapped.is_a?(Class)
275
+ ancestors.select { |v| v.is_a?(Class) }[times]
276
+ else
277
+ ancestors[times]
278
+ end
277
279
 
278
280
  Pry::WrappedModule(sup) if sup
279
281
  end
@@ -288,9 +290,7 @@ class Pry
288
290
  # candidate of rank 0 will be returned, or a CommandError raised if
289
291
  # there are no candidates at all.
290
292
  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)
293
+ @primary_candidate ||= candidates.find(&:file) || candidate(0)
294
294
  end
295
295
 
296
296
  # @return [Array<Array<Pry::Method>>] The array of `Pry::Method` objects,
@@ -301,7 +301,7 @@ class Pry
301
301
  # speed up source code extraction.
302
302
  def method_candidates
303
303
  @method_candidates ||= all_source_locations_by_popularity.map do |group|
304
- methods_sorted_by_source_line = group.last.sort_by(&:source_line)
304
+ methods_sorted_by_source_line = group.last.sort_by(&:source_line)
305
305
  [methods_sorted_by_source_line.first, methods_sorted_by_source_line.last]
306
306
  end
307
307
  end
@@ -310,33 +310,35 @@ class Pry
310
310
  def all_source_locations_by_popularity
311
311
  return @all_source_locations_by_popularity if @all_source_locations_by_popularity
312
312
 
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) }
313
+ ims = all_relevant_methods_for(wrapped).group_by do |v|
314
+ Array(v.source_location).first
315
+ end
316
+
317
+ @all_source_locations_by_popularity = ims.sort_by do |path, methods|
318
+ expanded = File.expand_path(path)
319
+ load_order = $LOADED_FEATURES.index { |file| expanded.end_with?(file) }
318
320
 
319
- [-methods.size, load_order || (1.0 / 0.0)]
320
- end
321
+ [-methods.size, load_order || (1.0 / 0.0)]
322
+ end
321
323
  end
322
324
 
323
325
  # We only want methods that have a non-nil `source_location`. We also
324
326
  # 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.)
327
+ #
326
328
  # @return [Array<Pry::Method>]
327
329
  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) }
330
+ methods = all_methods_for(mod).select(&:source_location)
331
+ .reject { |x| method_defined_by_forwardable_module?(x) }
330
332
 
331
333
  return methods unless methods.empty?
332
334
 
333
- safe_send(mod, :constants).map do |const_name|
334
- if const = nested_module?(mod, const_name)
335
+ safe_send(mod, :constants).flat_map do |const_name|
336
+ if (const = nested_module?(mod, const_name))
335
337
  all_relevant_methods_for(const)
336
338
  else
337
339
  []
338
340
  end
339
- end.flatten
341
+ end
340
342
  end
341
343
 
342
344
  # Return all methods (instance methods and class methods) for a
@@ -348,9 +350,11 @@ class Pry
348
350
 
349
351
  def nested_module?(parent, name)
350
352
  return if safe_send(parent, :autoload?, name)
353
+
351
354
  child = safe_send(parent, :const_get, name)
352
- return unless Module === child
355
+ return unless child.is_a?(Module)
353
356
  return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}"
357
+
354
358
  child
355
359
  end
356
360
 
@@ -367,11 +371,12 @@ class Pry
367
371
  def lines_for_file(file)
368
372
  @lines_for_file ||= {}
369
373
 
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
374
+ @lines_for_file[file] ||=
375
+ if file == Pry.eval_path
376
+ Pry.line_buffer.drop(1)
377
+ else
378
+ File.readlines(file)
379
+ end
375
380
  end
376
381
  end
377
382
  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'