pry 0.9.12.6-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. data/wiki/Home.md +0 -4
@@ -0,0 +1,55 @@
1
+ # PP subclass for streaming inspect output in color.
2
+ class Pry
3
+ class ColorPrinter < ::PP
4
+ OBJ_COLOR = begin
5
+ code = CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword]
6
+ if code.start_with? "\e"
7
+ code
8
+ else
9
+ "\e[0m\e[0;#{code}m"
10
+ end
11
+ end
12
+
13
+ CodeRay::Encoders::Terminal::TOKEN_COLORS[:comment][:self] = "\e[1;34m"
14
+
15
+ def self.pp(obj, out = $>, width = 79)
16
+ q = ColorPrinter.new(out, width)
17
+ q.guard_inspect_key { q.pp obj }
18
+ q.flush
19
+ out << "\n"
20
+ end
21
+
22
+ def text(str, width = str.length)
23
+ # Don't recolorize output with color [Issue #751]
24
+ if str.include?("\e[")
25
+ super "#{str}\e[0m", width
26
+ elsif str.start_with?('#<') || str == '=' || str == '>'
27
+ super highlight_object_literal(str), width
28
+ else
29
+ super CodeRay.scan(str, :ruby).term, width
30
+ end
31
+ end
32
+
33
+ def pp(obj)
34
+ super
35
+ rescue => e
36
+ raise if e.is_a? Pry::Pager::StopPaging
37
+
38
+ # Read the class name off of the singleton class to provide a default
39
+ # inspect.
40
+ singleton = class << obj; self; end
41
+ ancestors = Pry::Method.safe_send(singleton, :ancestors)
42
+ klass = ancestors.reject { |k| k == singleton }.first
43
+ obj_id = obj.__id__.to_s(16) rescue 0
44
+ str = "#<#{klass}:0x#{obj_id}>"
45
+
46
+ text highlight_object_literal(str)
47
+ end
48
+
49
+ private
50
+
51
+ def highlight_object_literal(object_literal)
52
+ "#{OBJ_COLOR}#{object_literal}\e[0m"
53
+ end
54
+ end
55
+ end
@@ -30,13 +30,13 @@ class Pry
30
30
  @command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect
31
31
  @match = arg
32
32
  end
33
- @match
33
+ @match ||= nil
34
34
  end
35
35
 
36
36
  # Define or get the command's description
37
37
  def description(arg=nil)
38
38
  @description = arg if arg
39
- @description
39
+ @description ||= nil
40
40
  end
41
41
 
42
42
  # Define or get the command's options
@@ -175,7 +175,7 @@ class Pry
175
175
  end
176
176
 
177
177
  def command_regex
178
- pr = defined?(Pry.config.command_prefix) ? Pry.config.command_prefix : ""
178
+ pr = Pry.respond_to?(:config) ? Pry.config.command_prefix : ""
179
179
  prefix = convert_to_regex(pr)
180
180
  prefix = "(?:#{prefix})?" unless options[:use_prefix]
181
181
 
@@ -194,6 +194,7 @@ class Pry
194
194
  # The group in which the command should be displayed in "help" output.
195
195
  # This is usually auto-generated from directory naming, but it can be
196
196
  # manually overridden if necessary.
197
+ # Group should not be changed once it is initialized.
197
198
  def group(name=nil)
198
199
  @group ||= if name
199
200
  name
@@ -201,7 +202,7 @@ class Pry
201
202
  case Pry::Method(block).source_file
202
203
  when %r{/pry/.*_commands/(.*).rb}
203
204
  $1.capitalize.gsub(/_/, " ")
204
- when %r{(pry-\w+)-([\d\.]+([\w\d\.]+)?)}
205
+ when %r{(pry-\w+)-([\d\.]+([\w\.]+)?)}
205
206
  name, version = $1, $2
206
207
  "#{name.to_s} (v#{version.to_s})"
207
208
  when /pryrc/
@@ -242,12 +243,13 @@ class Pry
242
243
  # @example
243
244
  # run "amend-line", "5", 'puts "hello world"'
244
245
  def run(command_string, *args)
246
+ command_string = _pry_.config.command_prefix.to_s + command_string
245
247
  complete_string = "#{command_string} #{args.join(" ")}".rstrip
246
248
  command_set.process_line(complete_string, context)
247
249
  end
248
250
 
249
251
  def commands
250
- command_set.commands
252
+ command_set.to_hash
251
253
  end
252
254
 
253
255
  def text
@@ -283,7 +285,7 @@ class Pry
283
285
  # state.my_state = "my state" # this will not conflict with any
284
286
  # # `state.my_state` used in another command.
285
287
  def state
286
- _pry_.command_state[match] ||= OpenStruct.new
288
+ _pry_.command_state[match] ||= Pry::Config.from_hash({})
287
289
  end
288
290
 
289
291
  # Revaluate the string (str) and perform interpolation.
@@ -307,8 +309,7 @@ class Pry
307
309
  collision_type ||= 'local-variable' if arg_string.match(%r{\A\s*[-+*/%&|^]*=})
308
310
 
309
311
  if collision_type
310
- output.puts "#{text.bold('WARNING:')} Calling Pry command '#{command_match}'," +
311
- "which conflicts with a #{collision_type}.\n\n"
312
+ output.puts "#{text.bold('WARNING:')} Calling Pry command '#{command_match}', which conflicts with a #{collision_type}.\n\n"
312
313
  end
313
314
  rescue Pry::RescuableException
314
315
  end
@@ -438,7 +439,9 @@ class Pry
438
439
  #
439
440
  # @param [String] search The line typed so far
440
441
  # @return [Array<String>] Completion words
441
- def complete(search); Bond::DefaultMission.completions; end
442
+ def complete(search)
443
+ []
444
+ end
442
445
 
443
446
  private
444
447
 
@@ -10,19 +10,15 @@ class Pry
10
10
  class CommandSet
11
11
  include Enumerable
12
12
  include Pry::Helpers::BaseHelpers
13
-
14
- attr_reader :commands
15
13
  attr_reader :helper_module
16
14
 
17
- # @param [Array<CommandSet>] imported_sets Sets which will be imported
18
- # automatically
15
+ # @param [Array<Commandset>] imported_sets
16
+ # Sets which will be imported automatically
19
17
  # @yield Optional block run to define commands
20
18
  def initialize(*imported_sets, &block)
21
19
  @commands = {}
22
20
  @helper_module = Module.new
23
-
24
21
  import(*imported_sets)
25
-
26
22
  instance_eval(&block) if block
27
23
  end
28
24
 
@@ -83,7 +79,7 @@ class Pry
83
79
  description, options = ["No description.", description] if description.is_a?(Hash)
84
80
  options = Pry::Command.default_options(match).merge!(options)
85
81
 
86
- commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block)
82
+ @commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block)
87
83
  end
88
84
  alias_method :command, :block_command
89
85
 
@@ -115,9 +111,9 @@ class Pry
115
111
  description, options = ["No description.", description] if description.is_a?(Hash)
116
112
  options = Pry::Command.default_options(match).merge!(options)
117
113
 
118
- commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block)
119
- commands[match].class_eval(&block)
120
- commands[match]
114
+ @commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block)
115
+ @commands[match].class_eval(&block)
116
+ @commands[match]
121
117
  end
122
118
 
123
119
  # Execute a block of code before a command is invoked. The block also
@@ -126,7 +122,7 @@ class Pry
126
122
  # @param [String, Regexp] search The match or listing of the command.
127
123
  # @yield The block to be run before the command.
128
124
  # @example Display parameter before invoking command
129
- # Pry.commands.before_command("whereami") do |n|
125
+ # Pry.config.commands.before_command("whereami") do |n|
130
126
  # output.puts "parameter passed was #{n}"
131
127
  # end
132
128
  def before_command(search, &block)
@@ -140,7 +136,7 @@ class Pry
140
136
  # @param [String, Regexp] search The match or listing of the command.
141
137
  # @yield The block to be run after the command.
142
138
  # @example Display text 'command complete' after invoking command
143
- # Pry.commands.after_command("whereami") do |n|
139
+ # Pry.config.commands.after_command("whereami") do |n|
144
140
  # output.puts "command complete!"
145
141
  # end
146
142
  def after_command(search, &block)
@@ -152,18 +148,12 @@ class Pry
152
148
  @commands.each(&block)
153
149
  end
154
150
 
155
- # Add a given command object to this set.
156
- # @param [Command] command The subclass of Pry::Command you wish to add.
157
- def add_command(command)
158
- commands[command.match] = command
159
- end
160
-
161
151
  # Removes some commands from the set
162
152
  # @param [Array<String>] searches the matches or listings of the commands to remove
163
153
  def delete(*searches)
164
154
  searches.each do |search|
165
155
  cmd = find_command_by_match_or_listing(search)
166
- commands.delete cmd.match
156
+ @commands.delete cmd.match
167
157
  end
168
158
  end
169
159
 
@@ -173,7 +163,7 @@ class Pry
173
163
  # @return [Pry::CommandSet] Returns the reciever (a command set).
174
164
  def import(*sets)
175
165
  sets.each do |set|
176
- commands.merge! set.commands
166
+ @commands.merge! set.to_hash
177
167
  helper_module.send :include, set.helper_module
178
168
  end
179
169
  self
@@ -187,7 +177,7 @@ class Pry
187
177
  helper_module.send :include, set.helper_module
188
178
  matches.each do |match|
189
179
  cmd = set.find_command_by_match_or_listing(match)
190
- commands[cmd.match] = cmd
180
+ @commands[cmd.match] = cmd
191
181
  end
192
182
  self
193
183
  end
@@ -196,8 +186,8 @@ class Pry
196
186
  # of the command to retrieve.
197
187
  # @return [Command] The command object matched.
198
188
  def find_command_by_match_or_listing(match_or_listing)
199
- cmd = (commands[match_or_listing] ||
200
- Pry::Helpers::BaseHelpers.find_command(match_or_listing, commands))
189
+ cmd = (@commands[match_or_listing] ||
190
+ Pry::Helpers::BaseHelpers.find_command(match_or_listing, @commands))
201
191
  cmd or raise ArgumentError, "Cannot find a command: '#{match_or_listing}'!"
202
192
  end
203
193
 
@@ -256,11 +246,11 @@ class Pry
256
246
  :description => cmd.description
257
247
  }.merge!(options)
258
248
 
259
- commands[new_match] = cmd.dup
260
- commands[new_match].match = new_match
261
- commands[new_match].description = options.delete(:description)
262
- commands[new_match].options.merge!(options)
263
- commands.delete(cmd.match)
249
+ @commands[new_match] = cmd.dup
250
+ @commands[new_match].match = new_match
251
+ @commands[new_match].description = options.delete(:description)
252
+ @commands[new_match].options.merge!(options)
253
+ @commands.delete(cmd.match)
264
254
  end
265
255
 
266
256
  def disabled_command(name_of_disabled_command, message, matcher=name_of_disabled_command)
@@ -309,18 +299,71 @@ class Pry
309
299
  end
310
300
 
311
301
 
312
- # @return [Array] The list of commands provided by the command set.
302
+ # @return [Array]
303
+ # The list of commands provided by the command set.
313
304
  def list_commands
314
- commands.keys
305
+ @commands.keys
306
+ end
307
+ alias_method :keys, :list_commands
308
+
309
+ def to_hash
310
+ @commands.dup
315
311
  end
312
+ alias_method :to_h, :to_hash
316
313
 
317
314
  # Find a command that matches the given line
318
- # @param [String] val The line that might be a command invocation
315
+ # @param [String] pattern The line that might be a command invocation
319
316
  # @return [Pry::Command, nil]
320
- def find_command(val)
321
- commands.values.select{ |c| c.matches?(val) }.sort_by{ |c| c.match_score(val) }.last
317
+ def [](pattern)
318
+ @commands.values.select do |command|
319
+ command.matches?(pattern)
320
+ end.sort_by do |command|
321
+ command.match_score(pattern)
322
+ end.last
323
+ end
324
+ alias_method :find_command, :[]
325
+
326
+ #
327
+ # Re-assign the command found at _pattern_ with _command_.
328
+ #
329
+ # @param [Regexp, String] pattern
330
+ # The command to add or replace(found at _pattern_).
331
+ #
332
+ # @param [Pry::Command] command
333
+ # The command to add.
334
+ #
335
+ # @return [Pry::Command]
336
+ # Returns the new command (matched with "pattern".)
337
+ #
338
+ # @example
339
+ # Pry.config.commands["help"] = MyHelpCommand
340
+ #
341
+ def []=(pattern, command)
342
+ if command.equal?(nil)
343
+ return @commands.delete(pattern)
344
+ end
345
+ unless Class === command && command < Pry::Command
346
+ raise TypeError, "command is not a subclass of Pry::Command"
347
+ end
348
+ bind_command_to_pattern = pattern != command.match
349
+ if bind_command_to_pattern
350
+ command_copy = command.dup
351
+ command_copy.match = pattern
352
+ @commands[pattern] = command_copy
353
+ else
354
+ @commands[pattern] = command
355
+ end
356
+ end
357
+
358
+ #
359
+ # Add a command to set.
360
+ #
361
+ # @param [Command] command
362
+ # a subclass of Pry::Command.
363
+ #
364
+ def add_command(command)
365
+ self[command.match] = command
322
366
  end
323
- alias_method :[], :find_command
324
367
 
325
368
  # Find the command that the user might be trying to refer to.
326
369
  # @param [String] search The user's search.
@@ -356,7 +399,7 @@ class Pry
356
399
 
357
400
  # @private (used for testing)
358
401
  def run_command(context, match, *args)
359
- command = commands[match] or raise NoCommandError.new(match, self)
402
+ command = @commands[match] or raise NoCommandError.new(match, self)
360
403
  command.new(context).call_safely(*args)
361
404
  end
362
405
 
@@ -368,9 +411,9 @@ class Pry
368
411
  if command = find_command(search)
369
412
  command.new(context).complete(search)
370
413
  else
371
- commands.keys.select do |x|
372
- String === x && x.start_with?(search)
373
- end.map{ |command| command + " " } + Bond::DefaultMission.completions
414
+ @commands.keys.select do |key|
415
+ String === key && key.start_with?(search)
416
+ end.map{ |key| key + " " }
374
417
  end
375
418
  end
376
419
  end
@@ -1,6 +1,6 @@
1
1
  # Default commands used by Pry.
2
2
  Pry::Commands = Pry::CommandSet.new
3
3
 
4
- Dir[File.expand_path('../commands', __FILE__) + '/*.rb'].each do |file|
4
+ Dir[File.expand_path('../commands', __FILE__) << '/*.rb'].each do |file|
5
5
  require file
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
  class Command::AmendLine < Pry::ClassCommand
3
- match /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/
3
+ match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
4
4
  group 'Editing'
5
5
  description 'Amend a line of input in multi-line mode.'
6
6
  command_options :interpolate => false, :listing => 'amend-line'
@@ -48,7 +48,7 @@ class Pry
48
48
 
49
49
  def insert_into_array(array, range)
50
50
  insert_slot = Array(range).first
51
- array.insert(insert_slot, arg_string[1..-1] + "\n")
51
+ array.insert(insert_slot, arg_string[1..-1] << "\n")
52
52
  end
53
53
 
54
54
  def replace_in_array(array, range)
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
  class Command::Bang < Pry::ClassCommand
3
- match '!'
3
+ match /^\s*!\s*$/
4
4
  group 'Editing'
5
5
  description 'Clear the input buffer.'
6
6
  command_options :use_prefix => false
@@ -41,11 +41,20 @@ class Pry
41
41
  FileFormatter.new(args.first, _pry_, opts).format
42
42
  end
43
43
 
44
- stagger_output(output)
44
+ _pry_.pager.page output
45
45
  end
46
46
 
47
47
  def complete(search)
48
- super + Bond::Rc.files(search.split(" ").last || '')
48
+ super | load_path_completions
49
+ end
50
+
51
+ def load_path_completions
52
+ $LOAD_PATH.flat_map do |path|
53
+ Dir[path + '/**/*'].map { |f|
54
+ next if File.directory?(f)
55
+ f.sub!(path + '/', '')
56
+ }
57
+ end
49
58
  end
50
59
  end
51
60
 
@@ -1,9 +1,9 @@
1
1
  class Pry
2
2
  class Command::Cat
3
3
  class ExceptionFormatter < AbstractFormatter
4
- attr_accessor :ex
5
- attr_accessor :opts
6
- attr_accessor :_pry_
4
+ attr_reader :ex
5
+ attr_reader :opts
6
+ attr_reader :_pry_
7
7
 
8
8
  def initialize(exception, _pry_, opts)
9
9
  @ex = exception
@@ -16,14 +16,14 @@ class Pry
16
16
  set_file_and_dir_locals(backtrace_file, _pry_, _pry_.current_context)
17
17
  code = decorate(Pry::Code.from_file(backtrace_file).
18
18
  between(*start_and_end_line_for_code_window).
19
- with_marker(backtrace_line)).to_s
19
+ with_marker(backtrace_line))
20
20
  "#{header}#{code}"
21
21
  end
22
22
 
23
23
  private
24
24
 
25
25
  def code_window_size
26
- Pry.config.default_window_size || 5
26
+ _pry_.config.default_window_size || 5
27
27
  end
28
28
 
29
29
  def backtrace_level
@@ -44,8 +44,7 @@ class Pry
44
44
  end
45
45
 
46
46
  def backtrace_file
47
- file = Array(ex.bt_source_location_for(backtrace_level)).first
48
- (file && RbxPath.is_core_path?(file)) ? RbxPath.convert_path_to_full(file) : file
47
+ Array(ex.bt_source_location_for(backtrace_level)).first
49
48
  end
50
49
 
51
50
  def backtrace_line