pry 0.9.8pre7-java → 0.9.8pre8-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pry.rb +10 -2
- data/lib/pry/code.rb +8 -1
- data/lib/pry/command.rb +3 -3
- data/lib/pry/command_set.rb +36 -33
- data/lib/pry/config.rb +13 -1
- data/lib/pry/default_commands/context.rb +9 -4
- data/lib/pry/default_commands/documentation.rb +69 -99
- data/lib/pry/default_commands/input.rb +57 -49
- data/lib/pry/default_commands/introspection.rb +20 -15
- data/lib/pry/default_commands/ls.rb +1 -1
- data/lib/pry/default_commands/shell.rb +76 -1
- data/lib/pry/helpers/command_helpers.rb +9 -0
- data/lib/pry/hooks.rb +89 -10
- data/lib/pry/plugins.rb +3 -3
- data/lib/pry/pry_class.rb +6 -4
- data/lib/pry/pry_instance.rb +16 -1
- data/lib/pry/version.rb +1 -1
- data/test/helper.rb +6 -1
- data/test/test_command.rb +17 -17
- data/test/test_command_set.rb +4 -4
- data/test/test_default_commands/test_documentation.rb +20 -8
- data/test/test_default_commands/test_input.rb +71 -32
- data/test/test_default_commands/test_shell.rb +190 -0
- data/test/test_hooks.rb +72 -2
- metadata +76 -70
@@ -1,6 +1,196 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe "Pry::DefaultCommands::Shell" do
|
4
|
+
describe "save-file" do
|
5
|
+
before do
|
6
|
+
@tf = Tempfile.new(["pry", ".py"])
|
7
|
+
@path = @tf.path
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
@tf.close(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "-f" do
|
15
|
+
it 'should save a file to a file' do
|
16
|
+
f = Tempfile.new(["pry", ".py"])
|
17
|
+
path = f.path
|
18
|
+
f.write ":cute_horse"
|
19
|
+
|
20
|
+
redirect_pry_io(InputTester.new("save-file -f #{path} #{@path}",
|
21
|
+
"exit-all")) do
|
22
|
+
Pry.start(@o)
|
23
|
+
end
|
24
|
+
File.read(@path).should == File.read(path)
|
25
|
+
|
26
|
+
f.close(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "-i" do
|
31
|
+
it 'should save input expressions to a file (single expression)' do
|
32
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
33
|
+
"save-file -i 1 #{@path}",
|
34
|
+
"exit-all")) do
|
35
|
+
Pry.start(@o)
|
36
|
+
end
|
37
|
+
File.read(@path).should == ":horse_nostrils\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should save input expressions to a file (range)' do
|
41
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
42
|
+
":sucking_up_all_the_oxygen",
|
43
|
+
"save-file -i 1..2 #{@path}",
|
44
|
+
"exit-all")) do
|
45
|
+
Pry.start(@o)
|
46
|
+
end
|
47
|
+
File.read(@path).should == ":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "-m" do
|
52
|
+
before do
|
53
|
+
@o = Object.new
|
54
|
+
def @o.baby
|
55
|
+
:baby
|
56
|
+
end
|
57
|
+
def @o.bang
|
58
|
+
:bang
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "single method" do
|
63
|
+
it 'should save a method to a file' do
|
64
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -m baby",
|
65
|
+
"exit-all")) do
|
66
|
+
Pry.start(@o)
|
67
|
+
end
|
68
|
+
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should save a method to a file truncated by --lines' do
|
72
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -m baby --lines 2..4",
|
73
|
+
"exit-all")) do
|
74
|
+
Pry.start(@o)
|
75
|
+
end
|
76
|
+
|
77
|
+
# must add 1 as first line of method is 1
|
78
|
+
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source.lines.to_a[1..5].join
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "multiple method" do
|
83
|
+
it 'should save multiple methods to a file' do
|
84
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang",
|
85
|
+
"exit-all")) do
|
86
|
+
Pry.start(@o)
|
87
|
+
end
|
88
|
+
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source +
|
89
|
+
Pry::Method.from_obj(@o, :bang).source
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should save multiple methods to a file trucated by --lines' do
|
93
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang --lines 2..-2",
|
94
|
+
"exit-all")) do
|
95
|
+
Pry.start(@o)
|
96
|
+
end
|
97
|
+
|
98
|
+
# must add 1 as first line of method is 1
|
99
|
+
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
100
|
+
Pry::Method.from_obj(@o, :bang).source).lines.to_a[1..-2].join
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should save multiple methods to a file trucated by --lines 1 (single parameter, not range)' do
|
104
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang --lines 1",
|
105
|
+
"exit-all")) do
|
106
|
+
Pry.start(@o)
|
107
|
+
end
|
108
|
+
|
109
|
+
# must add 1 as first line of method is 1
|
110
|
+
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
111
|
+
Pry::Method.from_obj(@o, :bang).source).lines.to_a[0]
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "overwrite by default (no --append)" do
|
119
|
+
it 'should overwrite specified file with new input' do
|
120
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
121
|
+
"save-file -i 1 #{@path}",
|
122
|
+
"exit-all")) do
|
123
|
+
Pry.start(@o)
|
124
|
+
end
|
125
|
+
|
126
|
+
redirect_pry_io(InputTester.new(":sucking_up_all_the_oxygen",
|
127
|
+
"save-file -i 1 #{@path}",
|
128
|
+
"exit-all")) do
|
129
|
+
Pry.start(@o)
|
130
|
+
end
|
131
|
+
|
132
|
+
File.read(@path).should == ":sucking_up_all_the_oxygen\n"
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "--append" do
|
138
|
+
it 'should append to end of specified file' do
|
139
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
140
|
+
"save-file -i 1 #{@path}",
|
141
|
+
"exit-all")) do
|
142
|
+
Pry.start(@o)
|
143
|
+
end
|
144
|
+
|
145
|
+
redirect_pry_io(InputTester.new(":sucking_up_all_the_oxygen",
|
146
|
+
"save-file -i 1 #{@path} -a",
|
147
|
+
"exit-all")) do
|
148
|
+
Pry.start(@o)
|
149
|
+
end
|
150
|
+
|
151
|
+
File.read(@path).should == ":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "-c" do
|
156
|
+
it 'should save a command to a file' do
|
157
|
+
redirect_pry_io(InputTester.new("save-file #{@path} -c show-method",
|
158
|
+
"exit-all")) do
|
159
|
+
Pry.start(@o)
|
160
|
+
end
|
161
|
+
cmd = Pry::Method.new(Pry.commands.find_command("show-method").block)
|
162
|
+
File.read(@path).should == Pry::Code.from_method(cmd).to_s
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "combined options" do
|
167
|
+
before do
|
168
|
+
@o = Object.new
|
169
|
+
def @o.baby
|
170
|
+
:baby
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should save input cache and a method to a file (in that order)' do
|
175
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
176
|
+
"save-file -i 1 -m baby #{@path}",
|
177
|
+
"exit-all")) do
|
178
|
+
Pry.start(@o)
|
179
|
+
end
|
180
|
+
File.read(@path).should == ":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should select a portion to save using --lines' do
|
184
|
+
redirect_pry_io(InputTester.new(":horse_nostrils",
|
185
|
+
"save-file -i 1 -m baby #{@path} --lines 2..-2",
|
186
|
+
"exit-all")) do
|
187
|
+
Pry.start(@o)
|
188
|
+
end
|
189
|
+
File.read(@path).should == (":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source).lines.to_a[1..-2].join
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
4
194
|
describe "cat" do
|
5
195
|
|
6
196
|
describe "on receiving a file that does not exist" do
|
data/test/test_hooks.rb
CHANGED
@@ -152,7 +152,7 @@ describe Pry::Hooks do
|
|
152
152
|
hooks_dup.get_hook(:test_hook, :testing).should == @hooks.get_hook(:test_hook, :testing)
|
153
153
|
end
|
154
154
|
|
155
|
-
|
155
|
+
it 'adding a new event to dupped instance should not affect original' do
|
156
156
|
@hooks.add_hook(:test_hook, :testing) { :none_such }
|
157
157
|
hooks_dup = @hooks.dup
|
158
158
|
|
@@ -161,7 +161,7 @@ describe Pry::Hooks do
|
|
161
161
|
hooks_dup.get_hook(:other_test_hook, :testing).should.not == @hooks.get_hook(:other_test_hook, :testing)
|
162
162
|
end
|
163
163
|
|
164
|
-
|
164
|
+
it 'adding a new hook to dupped instance should not affect original' do
|
165
165
|
@hooks.add_hook(:test_hook, :testing) { :none_such }
|
166
166
|
hooks_dup = @hooks.dup
|
167
167
|
|
@@ -415,6 +415,76 @@ describe Pry::Hooks do
|
|
415
415
|
end
|
416
416
|
end
|
417
417
|
end
|
418
|
+
end
|
418
419
|
|
420
|
+
describe "anonymous hooks" do
|
421
|
+
it 'should allow adding of hook without a name' do
|
422
|
+
@hooks.add_hook(:test_hook, nil) {}
|
423
|
+
@hooks.hook_count(:test_hook).should == 1
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'should only allow one anonymous hook to exist' do
|
427
|
+
@hooks.add_hook(:test_hook, nil) { }
|
428
|
+
@hooks.add_hook(:test_hook, nil) { }
|
429
|
+
@hooks.hook_count(:test_hook).should == 1
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'should execute most recently added anonymous hook' do
|
433
|
+
x = nil
|
434
|
+
y = nil
|
435
|
+
@hooks.add_hook(:test_hook, nil) { y = 1 }
|
436
|
+
@hooks.add_hook(:test_hook, nil) { x = 2 }
|
437
|
+
@hooks.exec_hook(:test_hook)
|
438
|
+
y.should == nil
|
439
|
+
x.should == 2
|
440
|
+
end
|
419
441
|
end
|
442
|
+
|
443
|
+
describe "deprecated hash-based API" do
|
444
|
+
after do
|
445
|
+
Pry.config.hooks.clear_all if Pry.config.hooks
|
446
|
+
end
|
447
|
+
|
448
|
+
describe "Pry.config.hooks" do
|
449
|
+
it 'should allow a hash-assignment' do
|
450
|
+
Pry.config.hooks = { :before_session => proc { :hello } }
|
451
|
+
Pry.config.hooks.get_hook(:before_session, nil).call.should == :hello
|
452
|
+
end
|
453
|
+
|
454
|
+
describe "Pry.config.hooks[]" do
|
455
|
+
it 'should return the only anonymous hook' do
|
456
|
+
Pry.config.hooks = { :before_session => proc { :hello } }
|
457
|
+
Pry.config.hooks[:before_session].call.should == :hello
|
458
|
+
end
|
459
|
+
|
460
|
+
it 'should add an anonymous hook when using Pry.config.hooks[]=' do
|
461
|
+
Pry.config.hooks[:before_session] = proc { :bing }
|
462
|
+
Pry.config.hooks.hook_count(:before_session).should == 1
|
463
|
+
end
|
464
|
+
|
465
|
+
it 'should add overwrite previous anonymous hooks with new one when calling Pry.config.hooks[]= multiple times' do
|
466
|
+
x = nil
|
467
|
+
Pry.config.hooks[:before_session] = proc { x = 1 }
|
468
|
+
Pry.config.hooks[:before_session] = proc { x = 2 }
|
469
|
+
|
470
|
+
Pry.config.hooks.exec_hook(:before_session)
|
471
|
+
Pry.config.hooks.hook_count(:before_session).should == 1
|
472
|
+
x.should == 2
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
describe "Pry.start" do
|
478
|
+
it 'should accept a hash for :hooks parameter' do
|
479
|
+
|
480
|
+
redirect_pry_io(InputTester.new("exit-all"), out=StringIO.new) do
|
481
|
+
Pry.start binding, :hooks => { :before_session => proc { |output, _, _| output.puts 'hello friend' } }
|
482
|
+
end
|
483
|
+
|
484
|
+
out.string.should =~ /hello friend/
|
485
|
+
end
|
486
|
+
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
420
490
|
end
|
metadata
CHANGED
@@ -1,103 +1,106 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.8pre7
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease: 5
|
5
|
+
version: 0.9.8pre8
|
6
6
|
platform: java
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- John Mair (banisterfiend)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-01-25 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: coderay
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
20
|
+
requirements:
|
19
21
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
22
|
+
- !ruby/object:Gem::Version
|
21
23
|
version: 1.0.5
|
22
24
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
26
27
|
name: slop
|
27
|
-
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
30
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
32
34
|
version: 2.4.3
|
33
35
|
- - <
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "3"
|
36
38
|
type: :runtime
|
37
|
-
|
38
|
-
|
39
|
-
- !ruby/object:Gem::Dependency
|
39
|
+
version_requirements: *id002
|
40
|
+
- !ruby/object:Gem::Dependency
|
40
41
|
name: method_source
|
41
|
-
|
42
|
+
prerelease: false
|
43
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
44
|
none: false
|
43
|
-
requirements:
|
45
|
+
requirements:
|
44
46
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0.7"
|
47
49
|
type: :runtime
|
48
|
-
|
49
|
-
|
50
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id003
|
51
|
+
- !ruby/object:Gem::Dependency
|
51
52
|
name: bacon
|
52
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
55
|
none: false
|
54
|
-
requirements:
|
56
|
+
requirements:
|
55
57
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "1.1"
|
58
60
|
type: :development
|
59
|
-
|
60
|
-
|
61
|
-
- !ruby/object:Gem::Dependency
|
61
|
+
version_requirements: *id004
|
62
|
+
- !ruby/object:Gem::Dependency
|
62
63
|
name: open4
|
63
|
-
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
66
|
none: false
|
65
|
-
requirements:
|
67
|
+
requirements:
|
66
68
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "1.3"
|
69
71
|
type: :development
|
70
|
-
|
71
|
-
|
72
|
-
- !ruby/object:Gem::Dependency
|
72
|
+
version_requirements: *id005
|
73
|
+
- !ruby/object:Gem::Dependency
|
73
74
|
name: rake
|
74
|
-
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
77
|
none: false
|
76
|
-
requirements:
|
78
|
+
requirements:
|
77
79
|
- - ~>
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0.9"
|
80
82
|
type: :development
|
81
|
-
|
82
|
-
|
83
|
-
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: *id006
|
84
|
+
- !ruby/object:Gem::Dependency
|
84
85
|
name: spoon
|
85
|
-
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
88
|
none: false
|
87
|
-
requirements:
|
89
|
+
requirements:
|
88
90
|
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0.0"
|
91
93
|
type: :runtime
|
92
|
-
|
93
|
-
version_requirements: *70177450982060
|
94
|
+
version_requirements: *id007
|
94
95
|
description: An IRB alternative and runtime developer console
|
95
96
|
email: jrmair@gmail.com
|
96
|
-
executables:
|
97
|
+
executables:
|
97
98
|
- pry
|
98
99
|
extensions: []
|
100
|
+
|
99
101
|
extra_rdoc_files: []
|
100
|
-
|
102
|
+
|
103
|
+
files:
|
101
104
|
- .document
|
102
105
|
- .gemtest
|
103
106
|
- .gitignore
|
@@ -198,29 +201,32 @@ files:
|
|
198
201
|
- wiki/Home.md
|
199
202
|
homepage: http://pry.github.com
|
200
203
|
licenses: []
|
204
|
+
|
201
205
|
post_install_message:
|
202
206
|
rdoc_options: []
|
203
|
-
|
207
|
+
|
208
|
+
require_paths:
|
204
209
|
- lib
|
205
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
211
|
none: false
|
207
|
-
requirements:
|
208
|
-
- -
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version:
|
211
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: "0"
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
217
|
none: false
|
213
|
-
requirements:
|
214
|
-
- -
|
215
|
-
- !ruby/object:Gem::Version
|
218
|
+
requirements:
|
219
|
+
- - ">"
|
220
|
+
- !ruby/object:Gem::Version
|
216
221
|
version: 1.3.1
|
217
222
|
requirements: []
|
223
|
+
|
218
224
|
rubyforge_project:
|
219
|
-
rubygems_version: 1.8.
|
225
|
+
rubygems_version: 1.8.11
|
220
226
|
signing_key:
|
221
227
|
specification_version: 3
|
222
228
|
summary: An IRB alternative and runtime developer console
|
223
|
-
test_files:
|
229
|
+
test_files:
|
224
230
|
- test/helper.rb
|
225
231
|
- test/test_cli.rb
|
226
232
|
- test/test_code.rb
|