pry 0.8.4pre1-i386-mswin32 → 0.9.0-i386-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CHANGELOG +25 -6
- data/README.markdown +11 -4
- data/Rakefile +15 -19
- data/TODO +28 -2
- data/bin/pry +28 -11
- data/examples/example_basic.rb +2 -4
- data/examples/example_command_override.rb +2 -5
- data/examples/example_commands.rb +1 -4
- data/examples/example_hooks.rb +2 -5
- data/examples/example_image_edit.rb +4 -8
- data/examples/example_input.rb +1 -4
- data/examples/example_input2.rb +1 -4
- data/examples/example_output.rb +1 -4
- data/examples/example_print.rb +2 -5
- data/examples/example_prompt.rb +2 -5
- data/examples/helper.rb +6 -0
- data/lib/pry.rb +59 -3
- data/lib/pry/command_context.rb +10 -9
- data/lib/pry/command_processor.rb +51 -73
- data/lib/pry/command_set.rb +79 -28
- data/lib/pry/commands.rb +9 -123
- data/lib/pry/completion.rb +30 -29
- data/lib/pry/config.rb +100 -0
- data/lib/pry/default_commands/basic.rb +37 -0
- data/lib/pry/default_commands/context.rb +16 -15
- data/lib/pry/default_commands/documentation.rb +73 -54
- data/lib/pry/default_commands/easter_eggs.rb +1 -20
- data/lib/pry/default_commands/gems.rb +31 -40
- data/lib/pry/default_commands/input.rb +223 -15
- data/lib/pry/default_commands/introspection.rb +108 -73
- data/lib/pry/default_commands/ls.rb +25 -11
- data/lib/pry/default_commands/shell.rb +29 -39
- data/lib/pry/extended_commands/experimental.rb +17 -0
- data/lib/pry/extended_commands/user_command_api.rb +22 -0
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +15 -104
- data/lib/pry/helpers/command_helpers.rb +96 -59
- data/lib/pry/helpers/text.rb +83 -0
- data/lib/pry/history_array.rb +105 -0
- data/lib/pry/plugins.rb +79 -0
- data/lib/pry/pry_class.rb +102 -114
- data/lib/pry/pry_instance.rb +123 -55
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +45 -0
- data/test/helper.rb +57 -7
- data/test/test_command_processor.rb +205 -0
- data/test/{test_commandset.rb → test_command_set.rb} +18 -12
- data/test/test_default_commands.rb +59 -0
- data/test/test_default_commands/test_context.rb +64 -0
- data/test/test_default_commands/test_documentation.rb +31 -0
- data/test/test_default_commands/test_gems.rb +14 -0
- data/test/test_default_commands/test_input.rb +327 -0
- data/test/test_default_commands/test_introspection.rb +155 -0
- data/test/test_history_array.rb +65 -0
- data/test/test_pry.rb +548 -313
- metadata +48 -15
- data/lib/pry/hooks.rb +0 -17
- data/lib/pry/print.rb +0 -16
- data/lib/pry/prompts.rb +0 -31
data/lib/pry/pry_instance.rb
CHANGED
@@ -2,12 +2,13 @@ require "pry/command_processor.rb"
|
|
2
2
|
|
3
3
|
class Pry
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor
|
5
|
+
attr_accessor :input
|
6
|
+
attr_accessor :output
|
7
|
+
attr_accessor :commands
|
8
|
+
attr_accessor :print
|
9
|
+
attr_accessor :exception_handler
|
10
|
+
attr_accessor :hooks
|
11
|
+
attr_accessor :custom_completions
|
11
12
|
|
12
13
|
# Returns the target binding for the session. Note that altering this
|
13
14
|
# attribute will not change the target binding.
|
@@ -18,22 +19,69 @@ class Pry
|
|
18
19
|
# @param [Hash] options The optional configuration parameters.
|
19
20
|
# @option options [#readline] :input The object to use for input.
|
20
21
|
# @option options [#puts] :output The object to use for output.
|
21
|
-
# @option options [Pry::CommandBase] :commands The object to use for commands.
|
22
|
-
# @option options [Hash] :hooks The defined hook Procs
|
23
|
-
# @option options [Array<Proc>] :
|
22
|
+
# @option options [Pry::CommandBase] :commands The object to use for commands.
|
23
|
+
# @option options [Hash] :hooks The defined hook Procs
|
24
|
+
# @option options [Array<Proc>] :prompt The array of Procs to use for the prompts.
|
24
25
|
# @option options [Proc] :print The Proc to use for the 'print'
|
25
26
|
# component of the REPL. (see print.rb)
|
26
27
|
def initialize(options={})
|
28
|
+
refresh(options)
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
default_options.merge!(options)
|
30
|
+
@command_processor = CommandProcessor.new(self)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
# Refresh the Pry instance settings from the Pry class.
|
34
|
+
# Allows options to be specified to override settings from Pry class.
|
35
|
+
# @param [Hash] options The options to override Pry class settings
|
36
|
+
# for this instance.
|
37
|
+
def refresh(options={})
|
38
|
+
defaults = {}
|
39
|
+
attributes = [
|
40
|
+
:input, :output, :commands, :print,
|
41
|
+
:exception_handler, :hooks, :custom_completions,
|
42
|
+
:prompt, :memory_size
|
43
|
+
]
|
44
|
+
|
45
|
+
attributes.each do |attribute|
|
46
|
+
defaults[attribute] = Pry.send attribute
|
34
47
|
end
|
35
48
|
|
36
|
-
|
49
|
+
defaults.merge!(options).each do |key, value|
|
50
|
+
send "#{key}=", value
|
51
|
+
end
|
52
|
+
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
# The current prompt.
|
57
|
+
# This is the prompt at the top of the prompt stack.
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# self.prompt = Pry::SIMPLE_PROMPT
|
61
|
+
# self.prompt # => Pry::SIMPLE_PROMPT
|
62
|
+
#
|
63
|
+
# @return [Array<Proc>] Current prompt.
|
64
|
+
def prompt
|
65
|
+
prompt_stack.last
|
66
|
+
end
|
67
|
+
|
68
|
+
def prompt=(new_prompt)
|
69
|
+
if prompt_stack.empty?
|
70
|
+
push_prompt new_prompt
|
71
|
+
else
|
72
|
+
prompt_stack[-1] = new_prompt
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [Integer] The maximum amount of objects remembered by the inp and
|
77
|
+
# out arrays. Defaults to 100.
|
78
|
+
def memory_size
|
79
|
+
@output_array.max_size
|
80
|
+
end
|
81
|
+
|
82
|
+
def memory_size=(size)
|
83
|
+
@input_array = Pry::HistoryArray.new(size)
|
84
|
+
@output_array = Pry::HistoryArray.new(size)
|
37
85
|
end
|
38
86
|
|
39
87
|
# Get nesting data.
|
@@ -50,6 +98,11 @@ class Pry
|
|
50
98
|
self.class.nesting = v
|
51
99
|
end
|
52
100
|
|
101
|
+
# @return [Boolean] Whether top-level session has ended.
|
102
|
+
def finished_top_level_session?
|
103
|
+
nesting.empty?
|
104
|
+
end
|
105
|
+
|
53
106
|
# Return parent of current Pry session.
|
54
107
|
# @return [Pry] The parent of the current Pry session.
|
55
108
|
def parent
|
@@ -71,8 +124,13 @@ class Pry
|
|
71
124
|
Pry.active_instance = self
|
72
125
|
|
73
126
|
# Make sure special locals exist
|
74
|
-
target.eval("
|
75
|
-
target.eval("
|
127
|
+
target.eval("inp = ::Pry.active_instance.instance_eval { @input_array }")
|
128
|
+
target.eval("out = ::Pry.active_instance.instance_eval { @output_array }")
|
129
|
+
|
130
|
+
set_active_instance(target)
|
131
|
+
@input_array << nil # add empty input so inp and out match
|
132
|
+
set_last_result(Pry.last_result, target)
|
133
|
+
|
76
134
|
self.session_target = target
|
77
135
|
end
|
78
136
|
|
@@ -91,6 +149,8 @@ class Pry
|
|
91
149
|
throw :breakout, break_data
|
92
150
|
end
|
93
151
|
|
152
|
+
save_history if Pry.config.history.should_save && finished_top_level_session?
|
153
|
+
|
94
154
|
return_value
|
95
155
|
end
|
96
156
|
|
@@ -153,20 +213,27 @@ class Pry
|
|
153
213
|
|
154
214
|
# save the pry instance to active_instance
|
155
215
|
Pry.active_instance = self
|
156
|
-
|
216
|
+
|
217
|
+
target.eval("inp = ::Pry.active_instance.instance_eval { @input_array }")
|
218
|
+
target.eval("out = ::Pry.active_instance.instance_eval { @output_array }")
|
157
219
|
|
158
220
|
@last_result_is_exception = false
|
221
|
+
set_active_instance(target)
|
222
|
+
|
223
|
+
code = r(target)
|
159
224
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
# This also sets the `_` local for the session.
|
164
|
-
set_last_result(target.eval(r(target)), target)
|
225
|
+
Pry.line_buffer.push(*code.each_line)
|
226
|
+
res = set_last_result(target.eval(code, Pry.eval_path, Pry.current_line), target)
|
227
|
+
res
|
165
228
|
rescue SystemExit => e
|
166
229
|
exit
|
167
230
|
rescue Exception => e
|
168
231
|
@last_result_is_exception = true
|
232
|
+
@output_array << e
|
169
233
|
set_last_exception(e, target)
|
234
|
+
ensure
|
235
|
+
@input_array << code
|
236
|
+
Pry.current_line += code.each_line.count if code
|
170
237
|
end
|
171
238
|
|
172
239
|
# Perform a read.
|
@@ -175,18 +242,19 @@ class Pry
|
|
175
242
|
# Ruby expression is received.
|
176
243
|
# Pry commands are also accepted here and operate on the target.
|
177
244
|
# @param [Object, Binding] target The receiver of the read.
|
245
|
+
# @param [String] eval_string Optionally Prime `eval_string` with a start value.
|
178
246
|
# @return [String] The Ruby expression.
|
179
247
|
# @example
|
180
248
|
# Pry.new.r(Object.new)
|
181
|
-
def r(target=TOPLEVEL_BINDING)
|
249
|
+
def r(target=TOPLEVEL_BINDING, eval_string="")
|
182
250
|
target = Pry.binding_for(target)
|
183
251
|
@suppress_output = false
|
184
|
-
eval_string = ""
|
185
252
|
|
186
253
|
val = ""
|
187
254
|
loop do
|
188
255
|
val = retrieve_line(eval_string, target)
|
189
256
|
process_line(val, eval_string, target)
|
257
|
+
|
190
258
|
break if valid_expression?(eval_string)
|
191
259
|
end
|
192
260
|
|
@@ -195,7 +263,7 @@ class Pry
|
|
195
263
|
eval_string
|
196
264
|
end
|
197
265
|
|
198
|
-
#
|
266
|
+
# Output the result or pass to an exception handler (if result is an exception).
|
199
267
|
def show_result(result)
|
200
268
|
if last_result_is_exception?
|
201
269
|
exception_handler.call output, result
|
@@ -234,15 +302,15 @@ class Pry
|
|
234
302
|
# This method should not need to be invoked directly.
|
235
303
|
# @param [String] val The line to process.
|
236
304
|
# @param [String] eval_string The cumulative lines of input.
|
237
|
-
# @
|
305
|
+
# @param [Binding] target The target of the Pry session.
|
238
306
|
def process_line(val, eval_string, target)
|
239
|
-
val.rstrip!
|
240
307
|
Pry.cmd_ret_value = @command_processor.process_commands(val, eval_string, target)
|
241
308
|
|
242
309
|
if Pry.cmd_ret_value
|
243
310
|
eval_string << "Pry.cmd_ret_value\n"
|
244
311
|
else
|
245
|
-
|
312
|
+
# only commands (with no ret_value) should have an empty `val` so this ignores their result
|
313
|
+
eval_string << "#{val.rstrip}\n" if !val.empty?
|
246
314
|
end
|
247
315
|
end
|
248
316
|
|
@@ -252,6 +320,7 @@ class Pry
|
|
252
320
|
# @param [Binding] target The binding to set `_` on.
|
253
321
|
def set_last_result(result, target)
|
254
322
|
Pry.last_result = result
|
323
|
+
@output_array << result
|
255
324
|
target.eval("_ = ::Pry.last_result")
|
256
325
|
end
|
257
326
|
|
@@ -260,10 +329,25 @@ class Pry
|
|
260
329
|
# @param [Exception] ex The exception.
|
261
330
|
# @param [Binding] target The binding to set `_ex_` on.
|
262
331
|
def set_last_exception(ex, target)
|
332
|
+
class << ex
|
333
|
+
attr_accessor :file, :line
|
334
|
+
end
|
335
|
+
|
336
|
+
ex.backtrace.first =~ /(.*):(\d+)/
|
337
|
+
ex.file, ex.line = $1, $2.to_i
|
338
|
+
|
263
339
|
Pry.last_exception = ex
|
264
340
|
target.eval("_ex_ = ::Pry.last_exception")
|
265
341
|
end
|
266
342
|
|
343
|
+
# Set the active instance for a session.
|
344
|
+
# This method should not need to be invoked directly.
|
345
|
+
# @param [Binding] target The binding to set `_ex_` on.
|
346
|
+
def set_active_instance(target)
|
347
|
+
Pry.active_instance = self
|
348
|
+
target.eval("_pry_ = ::Pry.active_instance")
|
349
|
+
end
|
350
|
+
|
267
351
|
# @return [Boolean] True if the last result is an exception that was raised,
|
268
352
|
# as opposed to simply an instance of Exception (like the result of
|
269
353
|
# Exception.new)
|
@@ -291,7 +375,7 @@ class Pry
|
|
291
375
|
end
|
292
376
|
|
293
377
|
rescue EOFError
|
294
|
-
self.input =
|
378
|
+
self.input = Pry.input
|
295
379
|
""
|
296
380
|
end
|
297
381
|
end
|
@@ -305,6 +389,14 @@ class Pry
|
|
305
389
|
!@suppress_output || last_result_is_exception?
|
306
390
|
end
|
307
391
|
|
392
|
+
# Save readline history to a file.
|
393
|
+
def save_history
|
394
|
+
history_file = File.expand_path(Pry.config.history.file)
|
395
|
+
File.open(history_file, 'w') do |f|
|
396
|
+
f.write Readline::HISTORY.to_a.join("\n")
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
308
400
|
# Returns the appropriate prompt to use.
|
309
401
|
# This method should not need to be invoked directly.
|
310
402
|
# @param [Boolean] first_line Whether this is the first line of input
|
@@ -326,30 +418,6 @@ class Pry
|
|
326
418
|
end
|
327
419
|
private :prompt_stack
|
328
420
|
|
329
|
-
# The current prompt, this is the prompt at the top of the prompt stack.
|
330
|
-
# @return [Array<Proc>] Current prompt.
|
331
|
-
# @example
|
332
|
-
# push_prompt(Pry::SIMPLE_PROMPT)
|
333
|
-
# prompt # => Pry::SIMPLE_PROMPT
|
334
|
-
def prompt
|
335
|
-
prompt_stack.last
|
336
|
-
end
|
337
|
-
|
338
|
-
# Replaces the current prompt with the new prompt.
|
339
|
-
# Does not change the rest of the prompt stack.
|
340
|
-
# @param [Array<Proc>] new_prompt
|
341
|
-
# @return [Array<Proc>] new_prompt
|
342
|
-
# @example
|
343
|
-
# pry.prompt = Pry::SIMPLE_PROMPT # => Pry::SIMPLE_PROMPT
|
344
|
-
# pry.prompt # => Pry::SIMPLE_PROMPT
|
345
|
-
def prompt=(new_prompt)
|
346
|
-
if prompt_stack.empty?
|
347
|
-
push_prompt new_prompt
|
348
|
-
else
|
349
|
-
prompt_stack[-1] = new_prompt
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
421
|
# Pushes the current prompt onto a stack that it can be restored from later.
|
354
422
|
# Use this if you wish to temporarily change the prompt.
|
355
423
|
# @param [Array<Proc>] new_prompt
|
@@ -374,7 +442,7 @@ class Pry
|
|
374
442
|
# pry.pop_prompt # => prompt1
|
375
443
|
# pry.pop_prompt # => prompt1
|
376
444
|
def pop_prompt
|
377
|
-
|
445
|
+
prompt_stack.size > 1 ? prompt_stack.pop : prompt
|
378
446
|
end
|
379
447
|
|
380
448
|
if RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == "ruby"
|
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'pry/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{pry}
|
7
|
+
s.version = Pry::VERSION
|
8
|
+
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.authors = [%q{John Mair (banisterfiend)}]
|
11
|
+
s.description = %q{an IRB alternative and runtime developer console}
|
12
|
+
s.email = %q{jrmair@gmail.com}
|
13
|
+
s.executables = [%q{pry}]
|
14
|
+
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
15
|
+
s.homepage = %q{http://banisterfiend.wordpress.com}
|
16
|
+
s.summary = %q{an IRB alternative and runtime developer console}
|
17
|
+
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}]
|
18
|
+
|
19
|
+
if s.respond_to? :specification_version then
|
20
|
+
s.specification_version = 3
|
21
|
+
|
22
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
|
+
s.add_runtime_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
24
|
+
s.add_runtime_dependency(%q<coderay>, [">= 0.9.8"])
|
25
|
+
s.add_runtime_dependency(%q<slop>, ["~> 1.7.0"])
|
26
|
+
s.add_runtime_dependency(%q<method_source>, [">= 0.4.0"])
|
27
|
+
s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
|
28
|
+
s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
31
|
+
s.add_dependency(%q<coderay>, [">= 0.9.8"])
|
32
|
+
s.add_dependency(%q<slop>, ["~> 1.7.0"])
|
33
|
+
s.add_dependency(%q<method_source>, [">= 0.4.0"])
|
34
|
+
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
35
|
+
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
36
|
+
end
|
37
|
+
else
|
38
|
+
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
39
|
+
s.add_dependency(%q<coderay>, [">= 0.9.8"])
|
40
|
+
s.add_dependency(%q<slop>, ["~> 1.7.0"])
|
41
|
+
s.add_dependency(%q<method_source>, [">= 0.4.0"])
|
42
|
+
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
43
|
+
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
44
|
+
end
|
45
|
+
end
|
data/test/helper.rb
CHANGED
@@ -4,24 +4,74 @@ unless Object.const_defined? 'Pry'
|
|
4
4
|
end
|
5
5
|
|
6
6
|
require 'bacon'
|
7
|
+
require 'open4'
|
7
8
|
|
8
9
|
# Ensure we do not execute any rc files
|
9
10
|
Pry::RC_FILES.clear
|
10
|
-
Pry.color = false
|
11
|
-
Pry.should_load_rc = false
|
12
|
-
|
13
|
-
class Module
|
14
|
-
public :remove_const
|
15
|
-
end
|
16
11
|
|
12
|
+
# in case the tests call reset_defaults, ensure we reset them to
|
13
|
+
# amended (test friendly) values
|
17
14
|
class << Pry
|
18
15
|
alias_method :orig_reset_defaults, :reset_defaults
|
19
16
|
def reset_defaults
|
20
17
|
orig_reset_defaults
|
18
|
+
|
21
19
|
Pry.color = false
|
20
|
+
Pry.pager = false
|
21
|
+
Pry.config.should_load_rc = false
|
22
|
+
Pry.config.plugins.enabled = false
|
23
|
+
Pry.config.history.should_load = false
|
24
|
+
Pry.config.history.should_save = false
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
28
|
+
Pry.reset_defaults
|
29
|
+
|
30
|
+
# sample doc
|
31
|
+
def sample_method
|
32
|
+
:sample
|
33
|
+
end
|
34
|
+
|
35
|
+
def redirect_pry_io(new_in, new_out)
|
36
|
+
old_in = Pry.input
|
37
|
+
old_out = Pry.output
|
38
|
+
|
39
|
+
Pry.input = new_in
|
40
|
+
Pry.output = new_out
|
41
|
+
begin
|
42
|
+
yield
|
43
|
+
ensure
|
44
|
+
Pry.input = old_in
|
45
|
+
Pry.output = old_out
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def redirect_global_pry_input(new_io)
|
50
|
+
old_io = Pry.input
|
51
|
+
Pry.input = new_io
|
52
|
+
begin
|
53
|
+
yield
|
54
|
+
ensure
|
55
|
+
Pry.input = old_io
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def redirect_global_pry_output(new_io)
|
60
|
+
old_io = Pry.output
|
61
|
+
Pry.output = new_io
|
62
|
+
begin
|
63
|
+
yield
|
64
|
+
ensure
|
65
|
+
Pry.output = old_io
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Module
|
70
|
+
public :remove_const
|
71
|
+
public :remove_method
|
72
|
+
end
|
73
|
+
|
74
|
+
|
25
75
|
class InputTester
|
26
76
|
def initialize(*actions)
|
27
77
|
@orig_actions = actions.dup
|
@@ -47,7 +97,7 @@ class Pry
|
|
47
97
|
end
|
48
98
|
|
49
99
|
|
50
|
-
CommandTester = Pry::CommandSet.new
|
100
|
+
CommandTester = Pry::CommandSet.new do
|
51
101
|
command "command1", "command 1 test" do
|
52
102
|
output.puts "command1"
|
53
103
|
end
|