pry 0.7.7.2-i386-mingw32 → 0.8.0-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +393 -195
- data/Rakefile +5 -4
- data/bin/pry +31 -39
- data/lib/pry.rb +18 -11
- data/lib/pry/command_base.rb +74 -21
- data/lib/pry/command_base_helpers.rb +241 -0
- data/lib/pry/command_helpers.rb +303 -0
- data/lib/pry/command_processor.rb +174 -0
- data/lib/pry/commands.rb +479 -260
- data/lib/pry/completion.rb +1 -1
- data/lib/pry/custom_completions.rb +6 -0
- data/lib/pry/hooks.rb +3 -7
- data/lib/pry/print.rb +10 -13
- data/lib/pry/prompts.rb +7 -2
- data/lib/pry/pry_class.rb +34 -11
- data/lib/pry/pry_instance.rb +83 -106
- data/lib/pry/version.rb +1 -1
- data/test/test.rb +126 -59
- data/test/test_helper.rb +6 -0
- metadata +112 -109
- data/lib/pry.rbc +0 -541
- data/lib/pry/#commands.rb# +0 -718
- data/lib/pry/command_base.rbc +0 -1795
- data/lib/pry/commands.rbc +0 -14430
- data/lib/pry/completion.rbc +0 -4485
- data/lib/pry/core_extensions.rbc +0 -592
- data/lib/pry/hooks.rbc +0 -649
- data/lib/pry/print.rbc +0 -400
- data/lib/pry/prompts.rbc +0 -574
- data/lib/pry/pry_class.rbc +0 -2376
- data/lib/pry/pry_instance.rbc +0 -4633
- data/lib/pry/version.rbc +0 -131
data/lib/pry/version.rb
CHANGED
data/test/test.rb
CHANGED
@@ -10,15 +10,9 @@ puts "Testing Pry #{Pry::VERSION}"
|
|
10
10
|
puts "With method_source version #{MethodSource::VERSION}"
|
11
11
|
puts "--"
|
12
12
|
|
13
|
-
# Ensure we do not execute any rc files
|
14
|
-
Pry::RC_FILES.clear
|
15
|
-
Pry.color = false
|
16
|
-
Pry.should_load_rc = false
|
17
|
-
|
18
13
|
describe Pry do
|
19
14
|
describe "open a Pry session on an object" do
|
20
15
|
describe "rep" do
|
21
|
-
|
22
16
|
before do
|
23
17
|
class Hello
|
24
18
|
end
|
@@ -41,7 +35,7 @@ describe Pry do
|
|
41
35
|
it 'should make self evaluate to the receiver of the rep session' do
|
42
36
|
o = Object.new
|
43
37
|
str_output = StringIO.new
|
44
|
-
|
38
|
+
|
45
39
|
pry_tester = Pry.new(:input => InputTester.new("self"), :output => str_output)
|
46
40
|
pry_tester.rep(o)
|
47
41
|
str_output.string.should =~ /#{o.to_s}/
|
@@ -50,7 +44,7 @@ describe Pry do
|
|
50
44
|
it 'should work with multi-line input' do
|
51
45
|
o = Object.new
|
52
46
|
str_output = StringIO.new
|
53
|
-
|
47
|
+
|
54
48
|
pry_tester = Pry.new(:input => InputTester.new("x = ", "1 + 4"), :output => str_output)
|
55
49
|
pry_tester.rep(o)
|
56
50
|
str_output.string.should =~ /5/
|
@@ -61,6 +55,60 @@ describe Pry do
|
|
61
55
|
pry_tester.rep(Hello)
|
62
56
|
Hello.const_defined?(:Nested).should == true
|
63
57
|
end
|
58
|
+
|
59
|
+
it 'should suppress output if input ends in a ";" and is an Exception object (single line)' do
|
60
|
+
o = Object.new
|
61
|
+
str_output = StringIO.new
|
62
|
+
|
63
|
+
pry_tester = Pry.new(:input => InputTester.new("Exception.new;"), :output => str_output)
|
64
|
+
pry_tester.rep(o)
|
65
|
+
str_output.string.should == ""
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should suppress output if input ends in a ";" (single line)' do
|
69
|
+
o = Object.new
|
70
|
+
str_output = StringIO.new
|
71
|
+
|
72
|
+
pry_tester = Pry.new(:input => InputTester.new("x = 5;"), :output => str_output)
|
73
|
+
pry_tester.rep(o)
|
74
|
+
str_output.string.should == ""
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
it 'should suppress output if input ends in a ";" (multi-line)' do
|
79
|
+
o = Object.new
|
80
|
+
str_output = StringIO.new
|
81
|
+
|
82
|
+
pry_tester = Pry.new(:input => InputTester.new("def self.blah", ":test", "end;"), :output => str_output)
|
83
|
+
pry_tester.rep(o)
|
84
|
+
str_output.string.should == ""
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should be able to evaluate exceptions normally' do
|
88
|
+
o = Exception.new
|
89
|
+
str_output = StringIO.new
|
90
|
+
|
91
|
+
was_called = false
|
92
|
+
pry_tester = Pry.new(:input => InputTester.new("self"),
|
93
|
+
:output => str_output,
|
94
|
+
:exception_handler => proc { was_called = true })
|
95
|
+
|
96
|
+
pry_tester.rep(o)
|
97
|
+
was_called.should == false
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should notice when exceptions are raised' do
|
101
|
+
o = Exception.new
|
102
|
+
str_output = StringIO.new
|
103
|
+
|
104
|
+
was_called = false
|
105
|
+
pry_tester = Pry.new(:input => InputTester.new("raise self"),
|
106
|
+
:output => str_output,
|
107
|
+
:exception_handler => proc { was_called = true })
|
108
|
+
|
109
|
+
pry_tester.rep(o)
|
110
|
+
was_called.should == true
|
111
|
+
end
|
64
112
|
end
|
65
113
|
|
66
114
|
describe "repl" do
|
@@ -75,16 +123,6 @@ describe Pry do
|
|
75
123
|
|
76
124
|
o.instance_variable_get(:@x).should == 10
|
77
125
|
end
|
78
|
-
|
79
|
-
it 'should execute start session and end session hooks' do
|
80
|
-
input = InputTester.new("exit")
|
81
|
-
str_output = StringIO.new
|
82
|
-
o = Object.new
|
83
|
-
|
84
|
-
pry_tester = Pry.start(o, :input => input, :output => str_output)
|
85
|
-
str_output.string.should =~ /Beginning.*#{o}/
|
86
|
-
str_output.string.should =~ /Ending.*#{o}/
|
87
|
-
end
|
88
126
|
end
|
89
127
|
|
90
128
|
describe "test loading rc files" do
|
@@ -119,13 +157,13 @@ describe Pry do
|
|
119
157
|
Pry.should_load_rc = false
|
120
158
|
end
|
121
159
|
end
|
122
|
-
|
160
|
+
|
123
161
|
describe "nesting" do
|
124
162
|
after do
|
125
163
|
Pry.reset_defaults
|
126
164
|
Pry.color = false
|
127
165
|
end
|
128
|
-
|
166
|
+
|
129
167
|
it 'should nest properly' do
|
130
168
|
Pry.input = InputTester.new("pry", "pry", "pry", "\"nest:\#\{Pry.nesting.level\}\"", "exit_all")
|
131
169
|
|
@@ -144,7 +182,7 @@ describe Pry do
|
|
144
182
|
[Object.new, {}, []].each do |val|
|
145
183
|
str_input = StringIO.new("def hello;end")
|
146
184
|
Pry.new(:input => str_input, :output => StringIO.new).rep(val)
|
147
|
-
|
185
|
+
|
148
186
|
val.methods(false).map(&:to_sym).include?(:hello).should == true
|
149
187
|
end
|
150
188
|
end
|
@@ -172,9 +210,9 @@ describe Pry do
|
|
172
210
|
val.class.instance_methods(false).map(&:to_sym).include?(:hello).should == true
|
173
211
|
end
|
174
212
|
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
213
|
+
|
214
|
+
end
|
215
|
+
|
178
216
|
|
179
217
|
describe "commands" do
|
180
218
|
it 'should run a command with no parameter' do
|
@@ -212,7 +250,7 @@ describe Pry do
|
|
212
250
|
Pry.reset_defaults
|
213
251
|
Pry.color = false
|
214
252
|
end
|
215
|
-
|
253
|
+
|
216
254
|
it "should start a pry session on the receiver (first form)" do
|
217
255
|
Pry.input = InputTester.new("self", "exit")
|
218
256
|
|
@@ -231,7 +269,7 @@ describe Pry do
|
|
231
269
|
Pry.output = str_output
|
232
270
|
|
233
271
|
pry 20
|
234
|
-
|
272
|
+
|
235
273
|
str_output.string.should =~ /20/
|
236
274
|
end
|
237
275
|
|
@@ -256,14 +294,14 @@ describe Pry do
|
|
256
294
|
Pry.reset_defaults
|
257
295
|
Pry.color = false
|
258
296
|
end
|
259
|
-
|
297
|
+
|
260
298
|
describe "input" do
|
261
299
|
|
262
300
|
after do
|
263
301
|
Pry.reset_defaults
|
264
302
|
Pry.color = false
|
265
303
|
end
|
266
|
-
|
304
|
+
|
267
305
|
it 'should set the input default, and the default should be overridable' do
|
268
306
|
Pry.input = InputTester.new("5")
|
269
307
|
|
@@ -308,7 +346,7 @@ describe Pry do
|
|
308
346
|
|
309
347
|
arity_multi_input = Class.new do
|
310
348
|
attr_accessor :prompt
|
311
|
-
|
349
|
+
|
312
350
|
def readline(*args)
|
313
351
|
@prompt = args.first
|
314
352
|
"exit"
|
@@ -318,15 +356,15 @@ describe Pry do
|
|
318
356
|
Pry.start(self, :input => arity_multi_input, :output => Pry::NullOutput)
|
319
357
|
arity_multi_input.prompt.should == nil
|
320
358
|
end
|
321
|
-
|
359
|
+
|
322
360
|
end
|
323
361
|
|
324
362
|
it 'should set the output default, and the default should be overridable' do
|
325
363
|
Pry.input = InputTester.new("5", "6", "7")
|
326
|
-
|
364
|
+
|
327
365
|
str_output = StringIO.new
|
328
366
|
Pry.output = str_output
|
329
|
-
|
367
|
+
|
330
368
|
Pry.new.rep
|
331
369
|
str_output.string.should =~ /5/
|
332
370
|
|
@@ -351,7 +389,7 @@ describe Pry do
|
|
351
389
|
after do
|
352
390
|
Object.remove_const(:RCTest)
|
353
391
|
end
|
354
|
-
|
392
|
+
|
355
393
|
it "should execute command in the appropriate object context" do
|
356
394
|
result = Pry.run_command "ls", :context => RCTest
|
357
395
|
result.map(&:to_sym).should == [:@x]
|
@@ -365,7 +403,7 @@ describe Pry do
|
|
365
403
|
it "should execute command and show output with :show_output => true flag" do
|
366
404
|
str = StringIO.new
|
367
405
|
Pry.output = str
|
368
|
-
result = Pry.run_command "ls -
|
406
|
+
result = Pry.run_command "ls -afv", :context => RCTest, :show_output => true
|
369
407
|
str.string.should =~ /global variables/
|
370
408
|
Pry.output = $stdout
|
371
409
|
end
|
@@ -377,6 +415,30 @@ describe Pry do
|
|
377
415
|
end
|
378
416
|
|
379
417
|
describe "commands" do
|
418
|
+
it 'should interpolate ruby code into commands' do
|
419
|
+
klass = Class.new(Pry::CommandBase) do
|
420
|
+
command "hello", "", :keep_retval => true do |arg|
|
421
|
+
arg
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
$test_interpolation = "bing"
|
426
|
+
str_output = StringIO.new
|
427
|
+
Pry.new(:input => StringIO.new("hello #{$test_interpolation}"), :output => str_output, :commands => klass).rep
|
428
|
+
str_output.string.should =~ /bing/
|
429
|
+
$test_interpolation = nil
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'should create a comand in a nested context and that command should be accessible from the parent' do
|
433
|
+
str_input = StringIO.new("@x=nil\ncd 7\n_pry_.commands.instance_eval {\ncommand('bing') { |arg| run arg }\n}\ncd ..\nbing ls\nexit")
|
434
|
+
str_output = StringIO.new
|
435
|
+
Pry.input = str_input
|
436
|
+
obj = Object.new
|
437
|
+
Pry.new(:output => str_output).repl(obj)
|
438
|
+
Pry.input = Readline
|
439
|
+
str_output.string.should =~ /@x/
|
440
|
+
end
|
441
|
+
|
380
442
|
it 'should define a command that keeps its return value' do
|
381
443
|
class Command68 < Pry::CommandBase
|
382
444
|
command "hello", "", :keep_retval => true do
|
@@ -384,8 +446,9 @@ describe Pry do
|
|
384
446
|
end
|
385
447
|
end
|
386
448
|
str_output = StringIO.new
|
387
|
-
Pry.new(:input => StringIO.new("hello"), :output => str_output, :commands => Command68).rep
|
449
|
+
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => Command68).rep
|
388
450
|
str_output.string.should =~ /:kept_hello/
|
451
|
+
str_output.string.should =~ /=>/
|
389
452
|
|
390
453
|
Object.remove_const(:Command68)
|
391
454
|
end
|
@@ -397,13 +460,13 @@ describe Pry do
|
|
397
460
|
end
|
398
461
|
end
|
399
462
|
str_output = StringIO.new
|
400
|
-
Pry.new(:input => StringIO.new("hello"), :output => str_output, :commands => Command68).rep
|
463
|
+
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => Command68).rep
|
401
464
|
(str_output.string =~ /:kept_hello/).should == nil
|
465
|
+
str_output.string !~ /=>/
|
402
466
|
|
403
467
|
Object.remove_const(:Command68)
|
404
468
|
end
|
405
|
-
|
406
|
-
|
469
|
+
|
407
470
|
it 'should set the commands default, and the default should be overridable' do
|
408
471
|
class Command0 < Pry::CommandBase
|
409
472
|
command "hello" do
|
@@ -424,7 +487,7 @@ describe Pry do
|
|
424
487
|
end
|
425
488
|
|
426
489
|
str_output = StringIO.new
|
427
|
-
|
490
|
+
|
428
491
|
Pry.new(:input => InputTester.new("goodbye"), :output => str_output, :commands => Command1).rep
|
429
492
|
str_output.string.should =~ /goodbye world/
|
430
493
|
|
@@ -438,8 +501,9 @@ describe Pry do
|
|
438
501
|
end
|
439
502
|
end
|
440
503
|
|
441
|
-
Command2.commands.keys.size.should ==
|
504
|
+
Command2.commands.keys.size.should == 3
|
442
505
|
Command2.commands.keys.include?("help").should == true
|
506
|
+
Command2.commands.keys.include?("install").should == true
|
443
507
|
Command2.commands.keys.include?("h").should == true
|
444
508
|
|
445
509
|
Object.remove_const(:Command2)
|
@@ -473,7 +537,7 @@ describe Pry do
|
|
473
537
|
end
|
474
538
|
|
475
539
|
it 'should change description of a command using desc' do
|
476
|
-
|
540
|
+
|
477
541
|
class Command7 < Pry::Commands
|
478
542
|
end
|
479
543
|
|
@@ -485,10 +549,10 @@ describe Pry do
|
|
485
549
|
|
486
550
|
Command7.commands["help"][:description].should.not == orig
|
487
551
|
Command7.commands["help"][:description].should == "blah"
|
488
|
-
|
552
|
+
|
489
553
|
Object.remove_const(:Command7)
|
490
554
|
end
|
491
|
-
|
555
|
+
|
492
556
|
it 'should run a command from within a command' do
|
493
557
|
class Command01 < Pry::Commands
|
494
558
|
command "v" do
|
@@ -520,30 +584,33 @@ describe Pry do
|
|
520
584
|
str_output = StringIO.new
|
521
585
|
Pry.new(:print => proc {}, :input => InputTester.new("v"),
|
522
586
|
:output => str_output, :commands => Command4).rep("john")
|
523
|
-
|
587
|
+
|
588
|
+
str_output.string.rstrip.should == "john"
|
524
589
|
|
525
590
|
Object.remove_const(:Command3)
|
526
591
|
Object.remove_const(:Command4)
|
527
592
|
end
|
528
593
|
|
529
594
|
it 'should import commands from another command object' do
|
530
|
-
|
595
|
+
Object.remove_const(:Command77) if Object.const_defined?(:Command77)
|
596
|
+
|
597
|
+
class Command77 < Pry::CommandBase
|
531
598
|
import_from Pry::Commands, "status", "jump-to"
|
532
599
|
end
|
533
600
|
|
534
601
|
str_output = StringIO.new
|
535
602
|
Pry.new(:print => proc {}, :input => InputTester.new("status"),
|
536
|
-
:output => str_output, :commands =>
|
603
|
+
:output => str_output, :commands => Command77).rep("john")
|
537
604
|
str_output.string.should =~ /Status:/
|
538
605
|
|
539
|
-
Object.remove_const(:
|
606
|
+
Object.remove_const(:Command77)
|
540
607
|
end
|
541
608
|
|
542
609
|
it 'should delete some inherited commands when using delete method' do
|
543
610
|
class Command3 < Pry::Commands
|
544
611
|
command "v" do
|
545
612
|
end
|
546
|
-
|
613
|
+
|
547
614
|
delete "show_doc", "show_method"
|
548
615
|
delete "ls"
|
549
616
|
end
|
@@ -572,15 +639,15 @@ describe Pry do
|
|
572
639
|
|
573
640
|
# suppress evaluation output
|
574
641
|
Pry.print = proc {}
|
575
|
-
|
642
|
+
|
576
643
|
str_output = StringIO.new
|
577
644
|
Pry.new(:input => InputTester.new("jump-to"), :output => str_output, :commands => Command3).rep
|
578
|
-
str_output.string.
|
645
|
+
str_output.string.rstrip.should == "jump-to the music"
|
579
646
|
|
580
647
|
str_output = StringIO.new
|
581
648
|
Pry.new(:input => InputTester.new("help"), :output => str_output, :commands => Command3).rep
|
582
|
-
str_output.string.
|
583
|
-
|
649
|
+
str_output.string.rstrip.should == "help to the music"
|
650
|
+
|
584
651
|
Object.remove_const(:Command3)
|
585
652
|
|
586
653
|
Pry.reset_defaults
|
@@ -601,7 +668,7 @@ describe Pry do
|
|
601
668
|
Pry.new(:input => InputTester.new("\"test\""), :output => str_output,
|
602
669
|
:print => proc { |out, value| out.puts value.reverse }).rep
|
603
670
|
str_output.string.should == "tset\n"
|
604
|
-
|
671
|
+
|
605
672
|
Pry.new.print.should == Pry.print
|
606
673
|
str_output = StringIO.new
|
607
674
|
Pry.new(:input => InputTester.new("\"test\""), :output => str_output).rep
|
@@ -629,7 +696,7 @@ describe Pry do
|
|
629
696
|
Pry.start("carl", :input => StringIO.new("exit self"), :output => Pry::NullOutput).should == "carl"
|
630
697
|
end
|
631
698
|
end
|
632
|
-
|
699
|
+
|
633
700
|
describe "prompts" do
|
634
701
|
it 'should set the prompt default, and the default should be overridable (single prompt)' do
|
635
702
|
new_prompt = proc { "test prompt> " }
|
@@ -644,7 +711,7 @@ describe Pry do
|
|
644
711
|
pry_tester.prompt.should == new_prompt
|
645
712
|
pry_tester.select_prompt(true, 0).should == "A"
|
646
713
|
pry_tester.select_prompt(false, 0).should == "A"
|
647
|
-
|
714
|
+
|
648
715
|
Pry.new.prompt.should == Pry.prompt
|
649
716
|
Pry.new.select_prompt(true, 0).should == "test prompt> "
|
650
717
|
Pry.new.select_prompt(false, 0).should == "test prompt> "
|
@@ -663,7 +730,7 @@ describe Pry do
|
|
663
730
|
pry_tester.prompt.should == new_prompt
|
664
731
|
pry_tester.select_prompt(true, 0).should == "A"
|
665
732
|
pry_tester.select_prompt(false, 0).should == "B"
|
666
|
-
|
733
|
+
|
667
734
|
Pry.new.prompt.should == Pry.prompt
|
668
735
|
Pry.new.select_prompt(true, 0).should == "test prompt> "
|
669
736
|
Pry.new.select_prompt(false, 0).should == "test prompt* "
|
@@ -676,12 +743,12 @@ describe Pry do
|
|
676
743
|
:before_session => proc { |out,_| out.puts "HELLO" },
|
677
744
|
:after_session => proc { |out,_| out.puts "BYE" }
|
678
745
|
}
|
679
|
-
|
746
|
+
|
680
747
|
str_output = StringIO.new
|
681
748
|
Pry.new(:output => str_output).repl
|
682
749
|
str_output.string.should =~ /HELLO/
|
683
750
|
str_output.string.should =~ /BYE/
|
684
|
-
|
751
|
+
|
685
752
|
Pry.input.rewind
|
686
753
|
|
687
754
|
str_output = StringIO.new
|
@@ -703,7 +770,7 @@ describe Pry do
|
|
703
770
|
:before_session => proc { |out,_| out.puts "OPEN" }
|
704
771
|
}
|
705
772
|
).repl
|
706
|
-
|
773
|
+
|
707
774
|
str_output.string.should =~ /OPEN/
|
708
775
|
|
709
776
|
Pry.input.rewind
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Ensure we do not execute any rc files
|
2
|
+
Pry::RC_FILES.clear
|
3
|
+
Pry.color = false
|
4
|
+
Pry.should_load_rc = false
|
5
|
+
|
1
6
|
class Module
|
2
7
|
public :remove_const
|
3
8
|
end
|
@@ -30,6 +35,7 @@ class Pry
|
|
30
35
|
# null output class - doesn't write anywwhere.
|
31
36
|
class NullOutput
|
32
37
|
def self.puts(*) end
|
38
|
+
def self.string(*) end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|