pry 0.9.9.6 → 0.9.10pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +35 -0
- data/CONTRIBUTORS +27 -26
- data/README.markdown +4 -4
- data/Rakefile +2 -2
- data/lib/pry.rb +25 -19
- data/lib/pry/cli.rb +31 -10
- data/lib/pry/code.rb +41 -83
- data/lib/pry/command.rb +87 -76
- data/lib/pry/command_set.rb +13 -20
- data/lib/pry/completion.rb +139 -121
- data/lib/pry/config.rb +4 -0
- data/lib/pry/core_extensions.rb +87 -30
- data/lib/pry/default_commands/cd.rb +31 -8
- data/lib/pry/default_commands/context.rb +4 -58
- data/lib/pry/default_commands/easter_eggs.rb +1 -1
- data/lib/pry/default_commands/editing.rb +21 -14
- data/lib/pry/default_commands/find_method.rb +5 -7
- data/lib/pry/default_commands/gist.rb +187 -0
- data/lib/pry/default_commands/hist.rb +6 -6
- data/lib/pry/default_commands/input_and_output.rb +73 -129
- data/lib/pry/default_commands/introspection.rb +107 -52
- data/lib/pry/default_commands/ls.rb +1 -1
- data/lib/pry/default_commands/misc.rb +0 -5
- data/lib/pry/default_commands/whereami.rb +92 -0
- data/lib/pry/helpers/base_helpers.rb +6 -1
- data/lib/pry/helpers/command_helpers.rb +30 -9
- data/lib/pry/helpers/documentation_helpers.rb +7 -7
- data/lib/pry/helpers/options_helpers.rb +1 -1
- data/lib/pry/helpers/text.rb +7 -9
- data/lib/pry/history.rb +15 -2
- data/lib/pry/hooks.rb +1 -1
- data/lib/pry/indent.rb +17 -10
- data/lib/pry/method.rb +35 -19
- data/lib/pry/module_candidate.rb +130 -0
- data/lib/pry/pry_class.rb +54 -22
- data/lib/pry/pry_instance.rb +71 -14
- data/lib/pry/repl_file_loader.rb +80 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +121 -142
- data/pry.gemspec +12 -12
- data/test/candidate_helper1.rb +11 -0
- data/test/candidate_helper2.rb +8 -0
- data/test/helper.rb +16 -0
- data/test/test_code.rb +1 -1
- data/test/test_command.rb +364 -270
- data/test/test_command_integration.rb +235 -267
- data/test/test_completion.rb +36 -0
- data/test/test_control_d_handler.rb +45 -0
- data/test/test_default_commands/example.erb +5 -0
- data/test/test_default_commands/test_cd.rb +316 -11
- data/test/test_default_commands/test_context.rb +143 -192
- data/test/test_default_commands/test_documentation.rb +81 -14
- data/test/test_default_commands/test_find_method.rb +10 -2
- data/test/test_default_commands/test_input.rb +102 -111
- data/test/test_default_commands/test_introspection.rb +17 -12
- data/test/test_default_commands/test_ls.rb +8 -6
- data/test/test_default_commands/test_shell.rb +18 -15
- data/test/test_default_commands/test_show_source.rb +170 -44
- data/test/test_exception_whitelist.rb +6 -2
- data/test/test_hooks.rb +32 -0
- data/test/test_input_stack.rb +19 -16
- data/test/test_method.rb +0 -4
- data/test/test_prompt.rb +60 -0
- data/test/test_pry.rb +23 -31
- data/test/test_pry_defaults.rb +75 -57
- data/test/test_syntax_checking.rb +12 -11
- data/test/test_wrapped_module.rb +103 -0
- metadata +65 -24
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'helper'
|
2
|
+
|
2
3
|
describe Pry do
|
4
|
+
before do
|
5
|
+
@str_output = StringIO.new
|
6
|
+
end
|
3
7
|
|
4
8
|
[
|
5
9
|
["p = '", "'"],
|
@@ -11,12 +15,11 @@ describe Pry do
|
|
11
15
|
["pouts(<<HI, 'foo", "bar", "HI", "baz')"],
|
12
16
|
].each do |foo|
|
13
17
|
it "should not raise an error on broken lines: #{foo.join("\\n")}" do
|
14
|
-
|
15
|
-
redirect_pry_io(InputTester.new(*foo), output) do
|
18
|
+
redirect_pry_io(InputTester.new(*foo), @str_output) do
|
16
19
|
Pry.start
|
17
20
|
end
|
18
21
|
|
19
|
-
|
22
|
+
@str_output.string.should.not =~ /SyntaxError/
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -30,25 +33,24 @@ describe Pry do
|
|
30
33
|
["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
|
31
34
|
]).compact.each do |foo|
|
32
35
|
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
33
|
-
|
34
|
-
redirect_pry_io(InputTester.new(*foo), output) do
|
36
|
+
redirect_pry_io(InputTester.new(*foo), @str_output) do
|
35
37
|
Pry.start
|
36
38
|
end
|
37
|
-
|
39
|
+
|
40
|
+
@str_output.string.should =~ /SyntaxError/
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
it "should not intefere with syntax errors explicitly raised" do
|
42
|
-
|
43
|
-
redirect_pry_io(InputTester.new(%q{raise SyntaxError, "unexpected $end"}), output) do
|
45
|
+
redirect_pry_io(InputTester.new(%q{raise SyntaxError, "unexpected $end"}), @str_output) do
|
44
46
|
Pry.start
|
45
47
|
end
|
46
|
-
|
48
|
+
|
49
|
+
@str_output.string.should =~ /SyntaxError/
|
47
50
|
end
|
48
51
|
|
49
52
|
it "should allow trailing , to continue the line" do
|
50
53
|
pry = Pry.new
|
51
|
-
|
52
54
|
Pry::Code.complete_expression?("puts 1, 2,").should == false
|
53
55
|
end
|
54
56
|
|
@@ -58,7 +60,6 @@ describe Pry do
|
|
58
60
|
end
|
59
61
|
|
60
62
|
it "should not clobber _ex_ on a SyntaxError in the repl" do
|
61
|
-
|
62
63
|
mock_pry("raise RuntimeError, 'foo';", "puts foo)", "_ex_.is_a?(RuntimeError)").should =~ /^RuntimeError.*\nSyntaxError.*\n=> true/m
|
63
64
|
end
|
64
65
|
end
|
data/test/test_wrapped_module.rb
CHANGED
@@ -8,6 +8,109 @@ describe Pry::WrappedModule do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
describe "candidates" do
|
12
|
+
before do
|
13
|
+
class Host
|
14
|
+
source_files = [File.join(File.dirname(__FILE__), "candidate_helper1.rb"),
|
15
|
+
File.join(File.dirname(__FILE__), "candidate_helper2.rb")]
|
16
|
+
|
17
|
+
source_files.each do |file|
|
18
|
+
binding.eval File.read(file), file, 1
|
19
|
+
end
|
20
|
+
|
21
|
+
# rank 2
|
22
|
+
class CandidateTest
|
23
|
+
def test6
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ForeverAlone
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "number_of_candidates" do
|
33
|
+
it 'should return the correct number of candidates' do
|
34
|
+
Pry::WrappedModule(Host::CandidateTest).number_of_candidates.should == 3
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return 0 candidates for a class with no methods and no other definitions' do
|
38
|
+
Pry::WrappedModule(Host::ForeverAlone).number_of_candidates.should == 0
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "ordering of candidates" do
|
43
|
+
it 'should return class with largest number of methods as primary candidate' do
|
44
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(0).file.should =~ /helper1/
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return class with second largest number of methods as second ranked candidate' do
|
48
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(1).file.should =~ /helper2/
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return class with third largest number of methods as third ranked candidate' do
|
52
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(2).file.should =~ /#{__FILE__}/
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should raise when trying to access non-existent candidate' do
|
56
|
+
lambda { Pry::WrappedModule(Host::CandidateTest).candidate(3) }.should.raise Pry::CommandError
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "source_location" do
|
61
|
+
it 'should return primary candidates source_location by default' do
|
62
|
+
wm = Pry::WrappedModule(Host::CandidateTest)
|
63
|
+
wm.source_location.should == wm.candidate(0).source_location
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return nil if no source_location can be found' do
|
67
|
+
Pry::WrappedModule(Host::ForeverAlone).source_location.should == nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "source" do
|
72
|
+
it 'should return primary candidates source by default' do
|
73
|
+
wm = Pry::WrappedModule(Host::CandidateTest)
|
74
|
+
wm.source.should == wm.candidate(0).source
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should return source for highest ranked candidate' do
|
78
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(0).source.should =~ /test1/
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should return source for second ranked candidate' do
|
82
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(1).source.should =~ /test4/
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should return source for third ranked candidate' do
|
86
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(2).source.should =~ /test6/
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "doc" do
|
91
|
+
it 'should return primary candidates doc by default' do
|
92
|
+
wm = Pry::WrappedModule(Host::CandidateTest)
|
93
|
+
wm.doc.should == wm.candidate(0).doc
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return doc for highest ranked candidate' do
|
97
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(0).doc.should =~ /rank 0/
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should return doc for second ranked candidate' do
|
101
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(1).doc.should =~ /rank 1/
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return doc for third ranked candidate' do
|
105
|
+
Pry::WrappedModule(Host::CandidateTest).candidate(2).doc.should =~ /rank 2/
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
after do
|
110
|
+
Object.remove_const(:Host)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
11
114
|
describe ".method_prefix" do
|
12
115
|
before do
|
13
116
|
Foo = Class.new
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.10pre1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Mair (banisterfiend)
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: coderay
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,35 +22,47 @@ dependencies:
|
|
22
22
|
version: 1.0.5
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.5
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: slop
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.4.4
|
34
|
-
- - <
|
36
|
+
- - ~>
|
35
37
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
38
|
+
version: 3.3.1
|
37
39
|
type: :runtime
|
38
40
|
prerelease: false
|
39
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.3.1
|
40
47
|
- !ruby/object:Gem::Dependency
|
41
48
|
name: method_source
|
42
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
43
50
|
none: false
|
44
51
|
requirements:
|
45
52
|
- - ~>
|
46
53
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
54
|
+
version: '0.8'
|
48
55
|
type: :runtime
|
49
56
|
prerelease: false
|
50
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.8'
|
51
63
|
- !ruby/object:Gem::Dependency
|
52
64
|
name: bacon
|
53
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
54
66
|
none: false
|
55
67
|
requirements:
|
56
68
|
- - ~>
|
@@ -58,10 +70,15 @@ dependencies:
|
|
58
70
|
version: '1.1'
|
59
71
|
type: :development
|
60
72
|
prerelease: false
|
61
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.1'
|
62
79
|
- !ruby/object:Gem::Dependency
|
63
80
|
name: open4
|
64
|
-
requirement:
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
65
82
|
none: false
|
66
83
|
requirements:
|
67
84
|
- - ~>
|
@@ -69,10 +86,15 @@ dependencies:
|
|
69
86
|
version: '1.3'
|
70
87
|
type: :development
|
71
88
|
prerelease: false
|
72
|
-
version_requirements:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.3'
|
73
95
|
- !ruby/object:Gem::Dependency
|
74
96
|
name: rake
|
75
|
-
requirement:
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
76
98
|
none: false
|
77
99
|
requirements:
|
78
100
|
- - ~>
|
@@ -80,7 +102,12 @@ dependencies:
|
|
80
102
|
version: '0.9'
|
81
103
|
type: :development
|
82
104
|
prerelease: false
|
83
|
-
version_requirements:
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
84
111
|
description: An IRB alternative and runtime developer console
|
85
112
|
email:
|
86
113
|
- jrmair@gmail.com
|
@@ -131,6 +158,7 @@ files:
|
|
131
158
|
- lib/pry/default_commands/editing.rb
|
132
159
|
- lib/pry/default_commands/find_method.rb
|
133
160
|
- lib/pry/default_commands/gems.rb
|
161
|
+
- lib/pry/default_commands/gist.rb
|
134
162
|
- lib/pry/default_commands/help.rb
|
135
163
|
- lib/pry/default_commands/hist.rb
|
136
164
|
- lib/pry/default_commands/input_and_output.rb
|
@@ -138,6 +166,7 @@ files:
|
|
138
166
|
- lib/pry/default_commands/ls.rb
|
139
167
|
- lib/pry/default_commands/misc.rb
|
140
168
|
- lib/pry/default_commands/navigating_pry.rb
|
169
|
+
- lib/pry/default_commands/whereami.rb
|
141
170
|
- lib/pry/extended_commands/experimental.rb
|
142
171
|
- lib/pry/helpers.rb
|
143
172
|
- lib/pry/helpers/base_helpers.rb
|
@@ -150,17 +179,21 @@ files:
|
|
150
179
|
- lib/pry/hooks.rb
|
151
180
|
- lib/pry/indent.rb
|
152
181
|
- lib/pry/method.rb
|
182
|
+
- lib/pry/module_candidate.rb
|
153
183
|
- lib/pry/plugins.rb
|
154
184
|
- lib/pry/pry_class.rb
|
155
185
|
- lib/pry/pry_instance.rb
|
156
186
|
- lib/pry/rbx_method.rb
|
157
187
|
- lib/pry/rbx_path.rb
|
188
|
+
- lib/pry/repl_file_loader.rb
|
158
189
|
- lib/pry/version.rb
|
159
190
|
- lib/pry/wrapped_module.rb
|
160
191
|
- man/pry.1
|
161
192
|
- man/pry.1.html
|
162
193
|
- man/pry.1.ronn
|
163
194
|
- pry.gemspec
|
195
|
+
- test/candidate_helper1.rb
|
196
|
+
- test/candidate_helper2.rb
|
164
197
|
- test/helper.rb
|
165
198
|
- test/test_cli.rb
|
166
199
|
- test/test_code.rb
|
@@ -169,6 +202,8 @@ files:
|
|
169
202
|
- test/test_command_integration.rb
|
170
203
|
- test/test_command_set.rb
|
171
204
|
- test/test_completion.rb
|
205
|
+
- test/test_control_d_handler.rb
|
206
|
+
- test/test_default_commands/example.erb
|
172
207
|
- test/test_default_commands/test_cd.rb
|
173
208
|
- test/test_default_commands/test_context.rb
|
174
209
|
- test/test_default_commands/test_documentation.rb
|
@@ -186,6 +221,7 @@ files:
|
|
186
221
|
- test/test_indent.rb
|
187
222
|
- test/test_input_stack.rb
|
188
223
|
- test/test_method.rb
|
224
|
+
- test/test_prompt.rb
|
189
225
|
- test/test_pry.rb
|
190
226
|
- test/test_pry_defaults.rb
|
191
227
|
- test/test_pry_history.rb
|
@@ -212,16 +248,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
249
|
none: false
|
214
250
|
requirements:
|
215
|
-
- - ! '
|
251
|
+
- - ! '>'
|
216
252
|
- !ruby/object:Gem::Version
|
217
|
-
version:
|
253
|
+
version: 1.3.1
|
218
254
|
requirements: []
|
219
255
|
rubyforge_project:
|
220
|
-
rubygems_version: 1.8.
|
256
|
+
rubygems_version: 1.8.24
|
221
257
|
signing_key:
|
222
258
|
specification_version: 3
|
223
259
|
summary: An IRB alternative and runtime developer console
|
224
260
|
test_files:
|
261
|
+
- test/candidate_helper1.rb
|
262
|
+
- test/candidate_helper2.rb
|
225
263
|
- test/helper.rb
|
226
264
|
- test/test_cli.rb
|
227
265
|
- test/test_code.rb
|
@@ -230,6 +268,8 @@ test_files:
|
|
230
268
|
- test/test_command_integration.rb
|
231
269
|
- test/test_command_set.rb
|
232
270
|
- test/test_completion.rb
|
271
|
+
- test/test_control_d_handler.rb
|
272
|
+
- test/test_default_commands/example.erb
|
233
273
|
- test/test_default_commands/test_cd.rb
|
234
274
|
- test/test_default_commands/test_context.rb
|
235
275
|
- test/test_default_commands/test_documentation.rb
|
@@ -247,6 +287,7 @@ test_files:
|
|
247
287
|
- test/test_indent.rb
|
248
288
|
- test/test_input_stack.rb
|
249
289
|
- test/test_method.rb
|
290
|
+
- test/test_prompt.rb
|
250
291
|
- test/test_pry.rb
|
251
292
|
- test/test_pry_defaults.rb
|
252
293
|
- test/test_pry_history.rb
|