pry 0.10.2-i386-mswin32 → 1.0.0.pre1-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/.document +2 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +21 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG +503 -0
  6. data/CONTRIBUTORS +55 -0
  7. data/Gemfile +9 -0
  8. data/Guardfile +62 -0
  9. data/LICENSE +2 -2
  10. data/{README.md → README.markdown} +31 -37
  11. data/Rakefile +144 -0
  12. data/TODO +117 -0
  13. data/lib/pry.rb +146 -33
  14. data/lib/pry/cli.rb +13 -35
  15. data/lib/pry/code.rb +63 -24
  16. data/lib/pry/code/loc.rb +2 -2
  17. data/lib/pry/code_object.rb +21 -40
  18. data/lib/pry/command.rb +6 -9
  19. data/lib/pry/command_set.rb +37 -80
  20. data/lib/pry/commands.rb +1 -1
  21. data/lib/pry/commands/amend_line.rb +1 -1
  22. data/lib/pry/commands/bang.rb +1 -1
  23. data/lib/pry/commands/cat.rb +2 -11
  24. data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
  25. data/lib/pry/commands/cat/exception_formatter.rb +7 -6
  26. data/lib/pry/commands/cat/file_formatter.rb +32 -15
  27. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  28. data/lib/pry/commands/cd.rb +3 -14
  29. data/lib/pry/commands/code_collector.rb +4 -4
  30. data/lib/pry/commands/easter_eggs.rb +3 -3
  31. data/lib/pry/commands/edit.rb +22 -10
  32. data/lib/pry/commands/edit/exception_patcher.rb +1 -1
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
  34. data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
  35. data/lib/pry/commands/find_method.rb +22 -16
  36. data/lib/pry/commands/gem_install.rb +2 -5
  37. data/lib/pry/commands/gem_open.rb +1 -1
  38. data/lib/pry/commands/gist.rb +11 -10
  39. data/lib/pry/commands/help.rb +14 -14
  40. data/lib/pry/commands/hist.rb +5 -24
  41. data/lib/pry/commands/ls.rb +287 -56
  42. data/lib/pry/commands/play.rb +10 -44
  43. data/lib/pry/commands/pry_backtrace.rb +2 -1
  44. data/lib/pry/commands/raise_up.rb +1 -1
  45. data/lib/pry/commands/reload_code.rb +15 -31
  46. data/lib/pry/commands/ri.rb +3 -7
  47. data/lib/pry/commands/shell_command.rb +12 -17
  48. data/lib/pry/commands/shell_mode.rb +2 -2
  49. data/lib/pry/commands/show_doc.rb +0 -5
  50. data/lib/pry/commands/show_info.rb +10 -11
  51. data/lib/pry/commands/show_source.rb +3 -15
  52. data/lib/pry/commands/simple_prompt.rb +1 -1
  53. data/lib/pry/commands/toggle_color.rb +4 -8
  54. data/lib/pry/commands/whereami.rb +10 -18
  55. data/lib/pry/completion.rb +293 -0
  56. data/lib/pry/config.rb +233 -20
  57. data/lib/pry/core_extensions.rb +19 -29
  58. data/lib/pry/custom_completions.rb +6 -0
  59. data/lib/pry/editor.rb +103 -109
  60. data/lib/pry/helpers/base_helpers.rb +109 -22
  61. data/lib/pry/helpers/command_helpers.rb +8 -10
  62. data/lib/pry/helpers/documentation_helpers.rb +2 -1
  63. data/lib/pry/helpers/text.rb +5 -4
  64. data/lib/pry/history.rb +10 -21
  65. data/lib/pry/history_array.rb +0 -5
  66. data/lib/pry/hooks.rb +29 -9
  67. data/lib/pry/indent.rb +10 -5
  68. data/lib/pry/method.rb +86 -81
  69. data/lib/pry/method/weird_method_locator.rb +2 -4
  70. data/lib/pry/module_candidate.rb +14 -5
  71. data/lib/pry/pager.rb +48 -193
  72. data/lib/pry/plugins.rb +2 -2
  73. data/lib/pry/pry_class.rb +193 -104
  74. data/lib/pry/pry_instance.rb +154 -152
  75. data/lib/pry/rbx_method.rb +13 -0
  76. data/lib/pry/rbx_path.rb +1 -1
  77. data/lib/pry/repl.rb +14 -17
  78. data/lib/pry/repl_file_loader.rb +3 -8
  79. data/lib/pry/rubygem.rb +3 -3
  80. data/lib/pry/terminal.rb +3 -4
  81. data/lib/pry/test/helper.rb +11 -6
  82. data/lib/pry/version.rb +1 -1
  83. data/lib/pry/wrapped_module.rb +56 -49
  84. data/man/pry.1 +195 -0
  85. data/man/pry.1.html +204 -0
  86. data/man/pry.1.ronn +141 -0
  87. data/pry.gemspec +31 -0
  88. data/spec/Procfile +3 -0
  89. data/spec/cli_spec.rb +78 -0
  90. data/spec/code_object_spec.rb +277 -0
  91. data/spec/code_spec.rb +219 -0
  92. data/spec/command_helpers_spec.rb +29 -0
  93. data/spec/command_integration_spec.rb +562 -0
  94. data/spec/command_set_spec.rb +627 -0
  95. data/spec/command_spec.rb +821 -0
  96. data/spec/commands/amend_line_spec.rb +247 -0
  97. data/spec/commands/bang_spec.rb +18 -0
  98. data/spec/commands/cat_spec.rb +164 -0
  99. data/spec/commands/cd_spec.rb +250 -0
  100. data/spec/commands/disable_pry_spec.rb +25 -0
  101. data/spec/commands/edit_spec.rb +725 -0
  102. data/spec/commands/exit_all_spec.rb +27 -0
  103. data/spec/commands/exit_program_spec.rb +19 -0
  104. data/spec/commands/exit_spec.rb +28 -0
  105. data/spec/commands/find_method_spec.rb +70 -0
  106. data/spec/commands/gem_list_spec.rb +26 -0
  107. data/spec/commands/gist_spec.rb +79 -0
  108. data/spec/commands/help_spec.rb +56 -0
  109. data/spec/commands/hist_spec.rb +172 -0
  110. data/spec/commands/jump_to_spec.rb +15 -0
  111. data/spec/commands/ls_spec.rb +189 -0
  112. data/spec/commands/play_spec.rb +136 -0
  113. data/spec/commands/raise_up_spec.rb +56 -0
  114. data/spec/commands/save_file_spec.rb +177 -0
  115. data/spec/commands/show_doc_spec.rb +488 -0
  116. data/spec/commands/show_input_spec.rb +17 -0
  117. data/spec/commands/show_source_spec.rb +760 -0
  118. data/spec/commands/whereami_spec.rb +203 -0
  119. data/spec/completion_spec.rb +221 -0
  120. data/spec/control_d_handler_spec.rb +62 -0
  121. data/spec/documentation_helper_spec.rb +73 -0
  122. data/spec/editor_spec.rb +79 -0
  123. data/spec/exception_whitelist_spec.rb +21 -0
  124. data/spec/fixtures/candidate_helper1.rb +11 -0
  125. data/spec/fixtures/candidate_helper2.rb +8 -0
  126. data/spec/fixtures/example.erb +5 -0
  127. data/spec/fixtures/example_nesting.rb +33 -0
  128. data/spec/fixtures/show_source_doc_examples.rb +15 -0
  129. data/spec/fixtures/testlinkrc +2 -0
  130. data/spec/fixtures/testrc +2 -0
  131. data/spec/fixtures/testrcbad +2 -0
  132. data/spec/fixtures/whereami_helper.rb +6 -0
  133. data/spec/helper.rb +35 -0
  134. data/spec/helpers/bacon.rb +86 -0
  135. data/spec/helpers/mock_pry.rb +44 -0
  136. data/spec/helpers/repl_tester.rb +112 -0
  137. data/spec/helpers/table_spec.rb +105 -0
  138. data/spec/history_array_spec.rb +67 -0
  139. data/spec/hooks_spec.rb +522 -0
  140. data/spec/indent_spec.rb +301 -0
  141. data/spec/method_spec.rb +482 -0
  142. data/spec/prompt_spec.rb +61 -0
  143. data/spec/pry_defaults_spec.rb +420 -0
  144. data/spec/pry_history_spec.rb +69 -0
  145. data/spec/pry_output_spec.rb +95 -0
  146. data/spec/pry_repl_spec.rb +86 -0
  147. data/spec/pry_spec.rb +394 -0
  148. data/spec/pryrc_spec.rb +97 -0
  149. data/spec/run_command_spec.rb +25 -0
  150. data/spec/sticky_locals_spec.rb +147 -0
  151. data/spec/syntax_checking_spec.rb +81 -0
  152. data/spec/wrapped_module_spec.rb +261 -0
  153. data/wiki/Customizing-pry.md +397 -0
  154. data/wiki/Home.md +4 -0
  155. metadata +272 -61
  156. checksums.yaml +0 -7
  157. data/CHANGELOG.md +0 -714
  158. data/lib/pry/code/code_file.rb +0 -103
  159. data/lib/pry/color_printer.rb +0 -55
  160. data/lib/pry/commands/change_inspector.rb +0 -27
  161. data/lib/pry/commands/change_prompt.rb +0 -26
  162. data/lib/pry/commands/list_inspectors.rb +0 -35
  163. data/lib/pry/commands/list_prompts.rb +0 -35
  164. data/lib/pry/commands/ls/constants.rb +0 -47
  165. data/lib/pry/commands/ls/formatter.rb +0 -49
  166. data/lib/pry/commands/ls/globals.rb +0 -48
  167. data/lib/pry/commands/ls/grep.rb +0 -21
  168. data/lib/pry/commands/ls/instance_vars.rb +0 -39
  169. data/lib/pry/commands/ls/interrogatable.rb +0 -18
  170. data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
  171. data/lib/pry/commands/ls/local_names.rb +0 -35
  172. data/lib/pry/commands/ls/local_vars.rb +0 -39
  173. data/lib/pry/commands/ls/ls_entity.rb +0 -70
  174. data/lib/pry/commands/ls/methods.rb +0 -57
  175. data/lib/pry/commands/ls/methods_helper.rb +0 -46
  176. data/lib/pry/commands/ls/self_methods.rb +0 -32
  177. data/lib/pry/commands/watch_expression.rb +0 -105
  178. data/lib/pry/commands/watch_expression/expression.rb +0 -38
  179. data/lib/pry/config/behavior.rb +0 -139
  180. data/lib/pry/config/convenience.rb +0 -25
  181. data/lib/pry/config/default.rb +0 -161
  182. data/lib/pry/exceptions.rb +0 -78
  183. data/lib/pry/input_completer.rb +0 -242
  184. data/lib/pry/input_lock.rb +0 -132
  185. data/lib/pry/inspector.rb +0 -27
  186. data/lib/pry/last_exception.rb +0 -61
  187. data/lib/pry/object_path.rb +0 -82
  188. data/lib/pry/output.rb +0 -50
  189. data/lib/pry/prompt.rb +0 -26
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ require "pry/indent"
2
+
2
3
  ##
3
4
  # Pry is a powerful alternative to the standard IRB shell for Ruby. It
4
5
  # features syntax highlighting, a flexible plugin architecture, runtime
@@ -20,27 +21,54 @@
20
21
  # * https://github.com/pry/pry
21
22
  # * the IRC channel, which is #pry on the Freenode network
22
23
  #
23
-
24
24
  class Pry
25
- attr_accessor :binding_stack
25
+ attr_accessor :input
26
+ attr_accessor :output
27
+ attr_accessor :commands
28
+ attr_accessor :print
29
+ attr_accessor :exception_handler
30
+ attr_accessor :quiet
31
+ alias :quiet? :quiet
32
+
26
33
  attr_accessor :custom_completions
34
+
35
+ attr_accessor :binding_stack
27
36
  attr_accessor :eval_string
28
- attr_accessor :backtrace
29
- attr_accessor :suppress_output
37
+
30
38
  attr_accessor :last_result
31
39
  attr_accessor :last_file
32
40
  attr_accessor :last_dir
33
41
 
34
42
  attr_reader :last_exception
35
- attr_reader :command_state
36
- attr_reader :exit_value
43
+
37
44
  attr_reader :input_array
38
45
  attr_reader :output_array
39
- attr_reader :config
40
46
 
41
- extend Pry::Config::Convenience
42
- config_shortcut(*Pry::Config.shortcuts)
43
- EMPTY_COMPLETIONS = [].freeze
47
+ attr_accessor :backtrace
48
+
49
+ attr_accessor :extra_sticky_locals
50
+
51
+ attr_accessor :suppress_output
52
+
53
+ # This is exposed via Pry::Command#state.
54
+ attr_reader :command_state
55
+
56
+ attr_reader :exit_value
57
+
58
+ attr_reader :hooks # Special treatment as we want to alert people of the
59
+ # changed API.
60
+
61
+ # FIXME: This is a hack to alert people of the new API.
62
+ # @param [Pry::Hooks] hooks
63
+ def hooks=(hooks)
64
+ if hooks.is_a?(Hash)
65
+ warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \
66
+ "instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
67
+ @hooks = Pry::Hooks.from_hash(hooks)
68
+ else
69
+ @hooks = hooks
70
+ end
71
+ end
44
72
 
45
73
  # Create a new {Pry} instance.
46
74
  # @param [Hash] options
@@ -67,38 +95,40 @@ class Pry
67
95
  @indent = Pry::Indent.new
68
96
  @command_state = {}
69
97
  @eval_string = ""
70
- @backtrace = options.delete(:backtrace) || caller
71
- target = options.delete(:target)
72
- @config = Pry::Config.new
73
- config.merge!(options)
74
- push_prompt(config.prompt)
75
- @input_array = Pry::HistoryArray.new config.memory_size
76
- @output_array = Pry::HistoryArray.new config.memory_size
77
- @custom_completions = config.command_completions
78
- set_last_result nil
79
- @input_array << nil
80
- push_initial_binding(target)
81
- exec_hook(:when_started, target, options, self)
82
- end
98
+ @backtrace = options[:backtrace] || caller
83
99
 
84
- # The current prompt.
85
- # This is the prompt at the top of the prompt stack.
86
- #
87
- # @example
88
- # self.prompt = Pry::SIMPLE_PROMPT
89
- # self.prompt # => Pry::SIMPLE_PROMPT
90
- #
91
- # @return [Array<Proc>] Current prompt.
92
- def prompt
93
- prompt_stack.last
94
- end
100
+ refresh_config(options)
95
101
 
96
- def prompt=(new_prompt)
97
- if prompt_stack.empty?
98
- push_prompt new_prompt
99
- else
100
- prompt_stack[-1] = new_prompt
102
+ push_initial_binding(options[:target])
103
+
104
+ set_last_result nil
105
+ @input_array << nil # add empty input so _in_ and _out_ match
106
+
107
+ # yield the binding_stack to the hook for modification
108
+ exec_hook(:when_started, options[:target], options, self)
109
+ end
110
+
111
+ # Refresh the Pry instance settings from the Pry class.
112
+ # Allows options to be specified to override settings from Pry class.
113
+ # @param [Hash] options The options to override Pry class settings
114
+ # for this instance.
115
+ def refresh_config(options={})
116
+ defaults = {}
117
+ attributes = [
118
+ :input, :output, :commands, :print, :quiet,
119
+ :exception_handler, :hooks, :custom_completions,
120
+ :prompt, :memory_size, :extra_sticky_locals
121
+ ]
122
+
123
+ attributes.each do |attribute|
124
+ defaults[attribute] = Pry.send attribute
101
125
  end
126
+
127
+ defaults.merge!(options).each do |key, value|
128
+ send("#{key}=", value) if respond_to?("#{key}=")
129
+ end
130
+
131
+ true
102
132
  end
103
133
 
104
134
  # Initialize this instance by pushing its initial context into the binding
@@ -121,60 +151,55 @@ class Pry
121
151
  binding_stack << Pry.binding_for(object)
122
152
  end
123
153
 
154
+ # The current prompt.
155
+ # This is the prompt at the top of the prompt stack.
124
156
  #
125
- # Generate completions.
126
- #
127
- # @param [String] input
128
- # What the user has typed so far
129
- #
130
- # @return [Array<String>]
131
- # Possible completions
157
+ # @example
158
+ # self.prompt = Pry::SIMPLE_PROMPT
159
+ # self.prompt # => Pry::SIMPLE_PROMPT
132
160
  #
133
- def complete(str)
134
- return EMPTY_COMPLETIONS unless config.completer
161
+ # @return [Array<Proc>] Current prompt.
162
+ def prompt
163
+ prompt_stack.last
164
+ end
165
+
166
+ def prompt=(new_prompt)
167
+ if prompt_stack.empty?
168
+ push_prompt new_prompt
169
+ else
170
+ prompt_stack[-1] = new_prompt
171
+ end
172
+ end
173
+
174
+ # Generate completions.
175
+ # @param [String] input What the user has typed so far
176
+ # @return [Array<String>] Possible completions
177
+ def complete(input)
135
178
  Pry.critical_section do
136
- completer = config.completer.new(config.input, self)
137
- completer.call str, target: current_binding, custom_completions: custom_completions.call.push(*sticky_locals.keys)
179
+ Pry.config.completer.call(input, :target => current_binding,
180
+ :pry => self,
181
+ :custom_completions => instance_eval(&custom_completions))
138
182
  end
139
183
  end
140
184
 
141
- #
142
185
  # Injects a local variable into the provided binding.
143
- #
144
- # @param [String] name
145
- # The name of the local to inject.
146
- #
147
- # @param [Object] value
148
- # The value to set the local to.
149
- #
150
- # @param [Binding] b
151
- # The binding to set the local on.
152
- #
153
- # @return [Object]
154
- # The value the local was set to.
155
- #
186
+ # @param [String] name The name of the local to inject.
187
+ # @param [Object] value The value to set the local to.
188
+ # @param [Binding] b The binding to set the local on.
189
+ # @return [Object] The value the local was set to.
156
190
  def inject_local(name, value, b)
157
- value = Proc === value ? value.call : value
158
- if b.respond_to?(:local_variable_set)
159
- b.local_variable_set name, value
160
- else # < 2.1
161
- begin
162
- Pry.current[:pry_local] = value
163
- b.eval "#{name} = ::Pry.current[:pry_local]"
164
- ensure
165
- Pry.current[:pry_local] = nil
166
- end
167
- end
191
+ Pry.current[:pry_local] = value.is_a?(Proc) ? value.call : value
192
+ b.eval("#{name} = ::Pry.current[:pry_local]")
193
+ ensure
194
+ Pry.current[:pry_local] = nil
168
195
  end
169
196
 
170
- undef :memory_size if method_defined? :memory_size
171
197
  # @return [Integer] The maximum amount of objects remembered by the inp and
172
198
  # out arrays. Defaults to 100.
173
199
  def memory_size
174
200
  @output_array.max_size
175
201
  end
176
202
 
177
- undef :memory_size= if method_defined? :memory_size=
178
203
  def memory_size=(size)
179
204
  @input_array = Pry::HistoryArray.new(size)
180
205
  @output_array = Pry::HistoryArray.new(size)
@@ -193,19 +218,21 @@ class Pry
193
218
  # @yield The block that defines the content of the local. The local
194
219
  # will be refreshed at each tick of the repl loop.
195
220
  def add_sticky_local(name, &block)
196
- config.extra_sticky_locals[name] = block
221
+ sticky_locals[name] = block
197
222
  end
198
223
 
224
+ # @return [Hash] The currently defined sticky locals.
199
225
  def sticky_locals
200
- { _in_: input_array,
201
- _out_: output_array,
202
- _pry_: self,
203
- _ex_: last_exception && last_exception.wrapped_exception,
204
- _file_: last_file,
205
- _dir_: last_dir,
206
- _: proc { last_result },
207
- __: proc { output_array[-2] }
208
- }.merge(config.extra_sticky_locals)
226
+ @sticky_locals ||= {
227
+ :_in_ => proc { @input_array },
228
+ :_out_ => proc { @output_array },
229
+ :_pry_ => self,
230
+ :_ex_ => proc { last_exception },
231
+ :_file_ => proc { last_file },
232
+ :_dir_ => proc { last_dir },
233
+ :_ => proc { last_result },
234
+ :__ => proc { @output_array[-2] }
235
+ }.merge(extra_sticky_locals)
209
236
  end
210
237
 
211
238
  # Reset the current eval string. If the user has entered part of a multiline
@@ -222,7 +249,7 @@ class Pry
222
249
  # 1. Pry commands will be executed immediately if the line matches.
223
250
  # 2. Partial lines of input will be queued up until a complete expression has
224
251
  # been accepted.
225
- # 3. Output is written to `#output` in pretty colours, not returned.
252
+ # 3. Output is written to {#output} in pretty colours, not returned.
226
253
  #
227
254
  # Once this method has raised an exception or returned false, this instance
228
255
  # is no longer usable. {#exit_value} will return the session's breakout
@@ -259,7 +286,7 @@ class Pry
259
286
 
260
287
  def handle_line(line, options)
261
288
  if line.nil?
262
- config.control_d_handler.call(@eval_string, self)
289
+ Pry.config.control_d_handler.call(@eval_string, self)
263
290
  return
264
291
  end
265
292
 
@@ -298,22 +325,6 @@ class Pry
298
325
  @suppress_output = true
299
326
  end
300
327
 
301
- # A bug in jruby makes java.lang.Exception not rescued by
302
- # `rescue Pry::RescuableException` clause.
303
- #
304
- # * https://github.com/pry/pry/issues/854
305
- # * https://jira.codehaus.org/browse/JRUBY-7100
306
- #
307
- # Until that gets fixed upstream, treat java.lang.Exception
308
- # as an additional exception to be rescued explicitly.
309
- #
310
- # This workaround has a side effect: java exceptions specified
311
- # in `Pry.config.exception_whitelist` are ignored.
312
- jruby_exceptions = []
313
- if Pry::Helpers::BaseHelpers.jruby?
314
- jruby_exceptions << Java::JavaLang::Exception
315
- end
316
-
317
328
  begin
318
329
  # Reset eval string, in case we're evaluating Ruby that does something
319
330
  # like open a nested REPL on this instance.
@@ -321,13 +332,7 @@ class Pry
321
332
  reset_eval_string
322
333
 
323
334
  result = evaluate_ruby(eval_string)
324
- rescue RescuableException, *jruby_exceptions => e
325
- # Eliminate following warning:
326
- # warning: singleton on non-persistent Java type X
327
- # (http://wiki.jruby.org/Persistence)
328
- if Pry::Helpers::BaseHelpers.jruby? && e.class.respond_to?('__persistent__')
329
- e.class.__persistent__ = true
330
- end
335
+ rescue RescuableException => e
331
336
  self.last_exception = e
332
337
  result = e
333
338
  end
@@ -341,10 +346,19 @@ class Pry
341
346
  end
342
347
  private :handle_line
343
348
 
344
- # Potentially deprecated Use `Pry::REPL.new(pry, :target => target).start`
345
- # (If nested sessions are going to exist, this method is fine, but a goal is
346
- # to come up with an alternative to nested sessions altogether.)
349
+ # @deprecated Use `Pry::REPL.new(pry, :target => target).start` instead.
347
350
  def repl(target = nil)
351
+ @@repl_warning ||= (warn Pry::Helpers::CommandHelpers.unindent(<<-S); true)
352
+ DEPRECATION: Pry#repl is deprecated. Instead, use
353
+
354
+ Pry::REPL.new(pry, :target => target).start
355
+
356
+ where pry is the Pry instance you called #repl on and target is the
357
+ optional target parameter of #repl.
358
+
359
+ Call stack:
360
+ #{caller.join("\n" + (' ' * 8))}
361
+ S
348
362
  Pry::REPL.new(self, :target => target).start
349
363
  end
350
364
 
@@ -364,7 +378,7 @@ class Pry
364
378
  if last_result_is_exception?
365
379
  exception_handler.call(output, result, self)
366
380
  elsif should_print?
367
- print.call(output, result, self)
381
+ print.call(output, result)
368
382
  else
369
383
  # nothin'
370
384
  end
@@ -427,7 +441,7 @@ class Pry
427
441
  end
428
442
  end
429
443
 
430
- # Same as process_command, but outputs exceptions to `#output` instead of
444
+ # Same as process_command, but outputs exceptions to {#output} instead of
431
445
  # raising.
432
446
  # @param [String] val The line to process.
433
447
  # @return [Boolean] `true` if `val` is a command, `false` otherwise
@@ -484,17 +498,27 @@ class Pry
484
498
  self.last_result = result unless code =~ /\A\s*\z/
485
499
  end
486
500
 
487
- #
488
501
  # Set the last exception for a session.
489
- #
490
- # @param [Exception] e
491
- # the last exception.
492
- #
493
- def last_exception=(e)
494
- last_exception = Pry::LastException.new(e)
502
+ # @param [Exception] ex
503
+ def last_exception=(ex)
504
+ class << ex
505
+ attr_accessor :file, :line, :bt_index
506
+ def bt_source_location_for(index)
507
+ backtrace[index] =~ /(.*):(\d+)/
508
+ [$1, $2.to_i]
509
+ end
510
+
511
+ def inc_bt_index
512
+ @bt_index = (@bt_index + 1) % backtrace.size
513
+ end
514
+ end
515
+
516
+ ex.bt_index = 0
517
+ ex.file, ex.line = ex.bt_source_location_for(0)
518
+
495
519
  @last_result_is_exception = true
496
- @output_array << last_exception
497
- @last_exception = last_exception
520
+ @output_array << ex
521
+ @last_exception = ex
498
522
  end
499
523
 
500
524
  # Update Pry's internal state after evalling code.
@@ -505,7 +529,7 @@ class Pry
505
529
  @input_array << code
506
530
  if code
507
531
  Pry.line_buffer.push(*code.each_line)
508
- Pry.current_line += code.lines.count
532
+ Pry.current_line += code.each_line.count
509
533
  end
510
534
  end
511
535
 
@@ -531,7 +555,7 @@ class Pry
531
555
  open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last :
532
556
  @indent.stack.last
533
557
 
534
- c = Pry::Config.from_hash({
558
+ c = OpenStruct.new(
535
559
  :object => object,
536
560
  :nesting_level => binding_stack.size - 1,
537
561
  :open_token => open_token,
@@ -542,7 +566,7 @@ class Pry
542
566
  :binding_stack => binding_stack,
543
567
  :input_array => input_array,
544
568
  :eval_string => @eval_string,
545
- :cont => !@eval_string.empty?})
569
+ :cont => !@eval_string.empty?)
546
570
 
547
571
  Pry.critical_section do
548
572
  # If input buffer is empty then use normal prompt
@@ -598,22 +622,6 @@ class Pry
598
622
  prompt_stack.size > 1 ? prompt_stack.pop : prompt
599
623
  end
600
624
 
601
- undef :pager if method_defined? :pager
602
- # Returns the currently configured pager
603
- # @example
604
- # _pry_.pager.page text
605
- def pager
606
- Pry::Pager.new(self)
607
- end
608
-
609
- undef :output if method_defined? :output
610
- # Returns an output device
611
- # @example
612
- # _pry_.output.puts "ohai!"
613
- def output
614
- Pry::Output.new(self)
615
- end
616
-
617
625
  # Raise an exception out of Pry.
618
626
  #
619
627
  # See Kernel#raise for documentation of parameters.
@@ -655,10 +663,4 @@ class Pry
655
663
  end
656
664
  def raise_up(*args); raise_up_common(false, *args); end
657
665
  def raise_up!(*args); raise_up_common(true, *args); end
658
-
659
- # Convenience accessor for the `quiet` config key.
660
- # @return [Boolean]
661
- def quiet?
662
- config.quiet
663
- end
664
666
  end