pry 0.9.7.4-i386-mswin32 → 0.9.8-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -3
- data/CHANGELOG +43 -0
- data/README.markdown +3 -1
- data/Rakefile +51 -32
- data/bin/pry +2 -80
- data/lib/pry.rb +33 -26
- data/lib/pry/cli.rb +152 -0
- data/lib/pry/code.rb +351 -0
- data/lib/pry/command.rb +422 -0
- data/lib/pry/command_set.rb +259 -129
- data/lib/pry/commands.rb +0 -1
- data/lib/pry/config.rb +43 -9
- data/lib/pry/default_commands/context.rb +109 -92
- data/lib/pry/default_commands/documentation.rb +174 -63
- data/lib/pry/default_commands/easter_eggs.rb +26 -2
- data/lib/pry/default_commands/gems.rb +65 -37
- data/lib/pry/default_commands/input.rb +175 -243
- data/lib/pry/default_commands/introspection.rb +173 -112
- data/lib/pry/default_commands/ls.rb +96 -114
- data/lib/pry/default_commands/shell.rb +175 -70
- data/lib/pry/helpers/base_helpers.rb +7 -2
- data/lib/pry/helpers/command_helpers.rb +71 -77
- data/lib/pry/helpers/options_helpers.rb +10 -41
- data/lib/pry/helpers/text.rb +24 -4
- data/lib/pry/history.rb +55 -17
- data/lib/pry/history_array.rb +2 -0
- data/lib/pry/hooks.rb +252 -0
- data/lib/pry/indent.rb +9 -5
- data/lib/pry/method.rb +149 -50
- data/lib/pry/plugins.rb +12 -4
- data/lib/pry/pry_class.rb +69 -26
- data/lib/pry/pry_instance.rb +187 -115
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +73 -0
- data/man/pry.1 +195 -0
- data/man/pry.1.html +204 -0
- data/man/pry.1.ronn +141 -0
- data/pry.gemspec +29 -32
- data/test/helper.rb +32 -36
- data/test/test_cli.rb +78 -0
- data/test/test_code.rb +201 -0
- data/test/test_command.rb +327 -0
- data/test/test_command_integration.rb +512 -0
- data/test/test_command_set.rb +338 -12
- data/test/test_completion.rb +1 -1
- data/test/test_default_commands.rb +1 -2
- data/test/test_default_commands/test_context.rb +27 -5
- data/test/test_default_commands/test_documentation.rb +20 -8
- data/test/test_default_commands/test_input.rb +84 -45
- data/test/test_default_commands/test_introspection.rb +74 -17
- data/test/test_default_commands/test_ls.rb +9 -36
- data/test/test_default_commands/test_shell.rb +240 -13
- data/test/test_hooks.rb +490 -0
- data/test/test_indent.rb +2 -0
- data/test/test_method.rb +60 -0
- data/test/test_pry.rb +29 -904
- data/test/test_pry_defaults.rb +380 -0
- data/test/test_pry_history.rb +24 -24
- data/test/test_syntax_checking.rb +63 -0
- data/test/test_wrapped_module.rb +71 -0
- metadata +50 -39
- data/lib/pry/command_context.rb +0 -53
- data/lib/pry/command_processor.rb +0 -181
- data/lib/pry/extended_commands/user_command_api.rb +0 -65
- data/test/test_command_processor.rb +0 -176
@@ -1,65 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
module ExtendedCommands
|
3
|
-
|
4
|
-
UserCommandAPI = Pry::CommandSet.new do
|
5
|
-
|
6
|
-
command "define-command", "Define a command in the session, use same syntax as `command` method for command API" do |arg|
|
7
|
-
if arg.nil?
|
8
|
-
raise CommandError, "Provide an arg!"
|
9
|
-
end
|
10
|
-
|
11
|
-
prime_string = "command #{arg_string}\n"
|
12
|
-
command_string = _pry_.r(target, prime_string)
|
13
|
-
|
14
|
-
eval_string.replace <<-HERE
|
15
|
-
_pry_.commands.instance_eval do
|
16
|
-
#{command_string}
|
17
|
-
end
|
18
|
-
HERE
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
command "reload-command", "Reload a command. reload-command CMD_NAME CMD_SET" do |command_name, set_name|
|
23
|
-
if command_name.nil?
|
24
|
-
raise CommandError, "Must provide command name"
|
25
|
-
end
|
26
|
-
|
27
|
-
if set_name.nil?
|
28
|
-
raise CommandError, "Must provide command set name"
|
29
|
-
end
|
30
|
-
|
31
|
-
cmd = Pry.config.commands.commands[command_name]
|
32
|
-
file_name = cmd.block.source_location.first
|
33
|
-
|
34
|
-
silence_warnings do
|
35
|
-
load file_name
|
36
|
-
end
|
37
|
-
Pry.config.commands.import target.eval(set_name)
|
38
|
-
_pry_.commands.import target.eval(set_name)
|
39
|
-
set_file_and_dir_locals(file_name)
|
40
|
-
end
|
41
|
-
|
42
|
-
command "edit-command", "Edit a command. edit-command CMD_NAME CMD_SET" do |command_name, set_name|
|
43
|
-
if command_name.nil?
|
44
|
-
raise CommandError, "Must provide command name"
|
45
|
-
end
|
46
|
-
|
47
|
-
if set_name.nil?
|
48
|
-
raise CommandError, "Must provide command set name"
|
49
|
-
end
|
50
|
-
|
51
|
-
cmd = Pry.config.commands.commands[command_name]
|
52
|
-
file_name = cmd.block.source_location.first
|
53
|
-
|
54
|
-
invoke_editor(*cmd.block.source_location)
|
55
|
-
silence_warnings do
|
56
|
-
load file_name
|
57
|
-
end
|
58
|
-
Pry.config.commands.import target.eval(set_name)
|
59
|
-
_pry_.commands.import target.eval(set_name)
|
60
|
-
set_file_and_dir_locals(file_name)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "Pry::CommandProcessor" do
|
4
|
-
before do
|
5
|
-
@pry = Pry.new
|
6
|
-
@pry.commands = Pry::CommandSet.new
|
7
|
-
@command_processor = Pry::CommandProcessor.new(@pry)
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
@pry.commands = Pry::CommandSet.new
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should accurately determine if a command is valid' do
|
15
|
-
@pry.commands.command("test-command") {}
|
16
|
-
valid = @command_processor.valid_command? "test-command"
|
17
|
-
valid.should == true
|
18
|
-
|
19
|
-
valid = @command_processor.valid_command? "blah"
|
20
|
-
valid.should == false
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should correctly match a simple string command' do
|
24
|
-
@pry.commands.command("test-command") {}
|
25
|
-
command, captures, pos = @command_processor.command_matched "test-command", binding
|
26
|
-
|
27
|
-
command.name.should == "test-command"
|
28
|
-
captures.should == []
|
29
|
-
pos.should == "test-command".length
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should correctly match a simple string command with parameters' do
|
33
|
-
@pry.commands.command("test-command") { |arg|}
|
34
|
-
command, captures, pos = @command_processor.command_matched "test-command hello", binding
|
35
|
-
|
36
|
-
command.name.should == "test-command"
|
37
|
-
captures.should == []
|
38
|
-
pos.should == "test-command".length
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should not match when the relevant command does not exist' do
|
42
|
-
command, captures, pos = @command_processor.command_matched "test-command", binding
|
43
|
-
|
44
|
-
command.should == nil
|
45
|
-
captures.should == nil
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should correctly match a regex command' do
|
49
|
-
@pry.commands.command(/rue(.?)/) { }
|
50
|
-
command, captures, pos = @command_processor.command_matched "rue hello", binding
|
51
|
-
|
52
|
-
command.name.should == /rue(.?)/
|
53
|
-
captures.should == [""]
|
54
|
-
pos.should == 3
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should correctly match a regex command and extract the capture groups' do
|
58
|
-
@pry.commands.command(/rue(.?)/) { }
|
59
|
-
command, captures, pos = @command_processor.command_matched "rue5 hello", binding
|
60
|
-
|
61
|
-
command.name.should == /rue(.?)/
|
62
|
-
captures.should == ["5"]
|
63
|
-
pos.should == 4
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should correctly match a string command with spaces in its name' do
|
67
|
-
@pry.commands.command("test command") {}
|
68
|
-
command, captures, pos = @command_processor.command_matched "test command", binding
|
69
|
-
|
70
|
-
command.name.should == "test command"
|
71
|
-
captures.should == []
|
72
|
-
pos.should == command.name.length
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should correctly match a string command with spaces in its name with parameters' do
|
76
|
-
@pry.commands.command("test command") {}
|
77
|
-
command, captures, pos = @command_processor.command_matched "test command param1 param2", binding
|
78
|
-
|
79
|
-
command.name.should == "test command"
|
80
|
-
captures.should == []
|
81
|
-
pos.should == command.name.length
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should correctly match a command preceded by the command_prefix if one is defined' do
|
85
|
-
Pry.config.command_prefix = "%"
|
86
|
-
|
87
|
-
@pry.commands.command("test-command") {}
|
88
|
-
command, captures, pos = @command_processor.command_matched "%test-command hello", binding
|
89
|
-
|
90
|
-
command.name.should == "test-command"
|
91
|
-
captures.should == []
|
92
|
-
pos.should == "test-command".length + "%".length
|
93
|
-
|
94
|
-
Pry.config.command_prefix = ''
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should not match a command not preceded by the command_prefix if one is defined' do
|
98
|
-
Pry.config.command_prefix = "%"
|
99
|
-
|
100
|
-
@pry.commands.command("test-command") {}
|
101
|
-
command, captures, pos = @command_processor.command_matched "test-command hello", binding
|
102
|
-
|
103
|
-
command.should == nil
|
104
|
-
captures.should == nil
|
105
|
-
|
106
|
-
Pry.config.command_prefix = ''
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should match a command preceded by the command_prefix when :use_prefix => false' do
|
110
|
-
Pry.config.command_prefix = "%"
|
111
|
-
|
112
|
-
@pry.commands.command("test-command", "", :use_prefix => false) {}
|
113
|
-
command, captures, pos = @command_processor.command_matched "%test-command hello", binding
|
114
|
-
|
115
|
-
command.name.should == "test-command"
|
116
|
-
captures.should == []
|
117
|
-
pos.should == "test-command".length + "%".length
|
118
|
-
|
119
|
-
Pry.config.command_prefix = ''
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should match a command not preceded by the command_prefix when :use_prefix => false' do
|
123
|
-
Pry.config.command_prefix = "%"
|
124
|
-
|
125
|
-
@pry.commands.command("test-command", "", :use_prefix => false) {}
|
126
|
-
command, captures, pos = @command_processor.command_matched "test-command hello", binding
|
127
|
-
|
128
|
-
command.name.should == "test-command"
|
129
|
-
captures.should == []
|
130
|
-
pos.should == "test-command".length
|
131
|
-
|
132
|
-
Pry.config.command_prefix = ''
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should correctly match a regex command with spaces in its name' do
|
136
|
-
regex_command_name = /test\s+(.+)\s+command/
|
137
|
-
@pry.commands.command(regex_command_name) {}
|
138
|
-
|
139
|
-
sample_text = "test friendship command"
|
140
|
-
command, captures, pos = @command_processor.command_matched sample_text, binding
|
141
|
-
|
142
|
-
command.name.should == regex_command_name
|
143
|
-
captures.should == ["friendship"]
|
144
|
-
pos.should == sample_text.size
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should correctly match a complex regex command' do
|
148
|
-
regex_command_name = /\.(.*)/
|
149
|
-
@pry.commands.command(regex_command_name) {}
|
150
|
-
|
151
|
-
sample_text = ".cd ~/pry"
|
152
|
-
command, captures, pos = @command_processor.command_matched sample_text, binding
|
153
|
-
|
154
|
-
command.name.should == regex_command_name
|
155
|
-
captures.should == ["cd ~/pry"]
|
156
|
-
pos.should == sample_text.size
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'should not interpolate commands that have :interpolate => false (interpolate_string should *not* be called)' do
|
160
|
-
@pry.commands.command("boast", "", :interpolate => false) {}
|
161
|
-
|
162
|
-
# remember to use '' instead of "" when testing interpolation or
|
163
|
-
# you'll cause yourself incredible confusion
|
164
|
-
lambda { @command_processor.command_matched('boast #{c}', binding) }.should.not.raise NameError
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'should only execute the contents of an interpolation once' do
|
168
|
-
$obj = 'a'
|
169
|
-
|
170
|
-
redirect_pry_io(InputTester.new('cat #{$obj.succ!}'), StringIO.new) do
|
171
|
-
Pry.new.rep
|
172
|
-
end
|
173
|
-
|
174
|
-
$obj.should == 'b'
|
175
|
-
end
|
176
|
-
end
|