pry 0.9.8.4-i386-mingw32 → 0.9.9-i386-mingw32
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 +26 -0
- data/README.markdown +3 -3
- data/lib/pry.rb +9 -1
- data/lib/pry/code.rb +93 -0
- data/lib/pry/command.rb +35 -22
- data/lib/pry/command_set.rb +97 -67
- data/lib/pry/config.rb +63 -10
- data/lib/pry/core_extensions.rb +24 -18
- data/lib/pry/default_commands/context.rb +72 -12
- data/lib/pry/default_commands/easter_eggs.rb +4 -0
- data/lib/pry/default_commands/editing.rb +43 -15
- data/lib/pry/default_commands/find_method.rb +171 -0
- data/lib/pry/default_commands/hist.rb +10 -6
- data/lib/pry/default_commands/introspection.rb +183 -30
- data/lib/pry/default_commands/ls.rb +77 -7
- data/lib/pry/default_commands/misc.rb +1 -0
- data/lib/pry/default_commands/navigating_pry.rb +1 -8
- data/lib/pry/helpers/base_helpers.rb +10 -2
- data/lib/pry/helpers/command_helpers.rb +23 -40
- data/lib/pry/helpers/documentation_helpers.rb +65 -0
- data/lib/pry/indent.rb +17 -4
- data/lib/pry/method.rb +61 -45
- data/lib/pry/pry_class.rb +9 -3
- data/lib/pry/pry_instance.rb +99 -65
- data/lib/pry/rbx_method.rb +2 -9
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +236 -1
- data/pry.gemspec +5 -5
- data/test/helper.rb +22 -0
- data/test/test_command.rb +29 -0
- data/test/test_command_integration.rb +193 -10
- data/test/test_command_set.rb +82 -17
- data/test/test_default_commands/test_cd.rb +16 -0
- data/test/test_default_commands/test_context.rb +61 -0
- data/test/test_default_commands/test_documentation.rb +163 -43
- data/test/test_default_commands/test_find_method.rb +42 -0
- data/test/test_default_commands/test_input.rb +32 -0
- data/test/test_default_commands/test_introspection.rb +50 -197
- data/test/test_default_commands/test_ls.rb +22 -0
- data/test/test_default_commands/test_show_source.rb +306 -0
- data/test/test_pry.rb +3 -3
- data/test/test_pry_defaults.rb +21 -0
- data/test/test_sticky_locals.rb +81 -1
- data/test/test_syntax_checking.rb +7 -6
- metadata +24 -16
data/pry.gemspec
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "pry"
|
5
|
-
s.version = "0.9.
|
5
|
+
s.version = "0.9.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["John Mair (banisterfiend)"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-04-18"
|
10
10
|
s.description = "An IRB alternative and runtime developer console"
|
11
11
|
s.email = "jrmair@gmail.com"
|
12
12
|
s.executables = ["pry"]
|
13
|
-
s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/cli.rb", "lib/pry/code.rb", "lib/pry/command.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/cd.rb", "lib/pry/default_commands/commands.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/editing.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/help.rb", "lib/pry/default_commands/hist.rb", "lib/pry/default_commands/input_and_output.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/misc.rb", "lib/pry/default_commands/navigating_pry.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"]
|
13
|
+
s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/cli.rb", "lib/pry/code.rb", "lib/pry/command.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/cd.rb", "lib/pry/default_commands/commands.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/editing.rb", "lib/pry/default_commands/find_method.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/help.rb", "lib/pry/default_commands/hist.rb", "lib/pry/default_commands/input_and_output.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/misc.rb", "lib/pry/default_commands/navigating_pry.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/documentation_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_default_commands/test_show_source.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"]
|
14
14
|
s.homepage = "http://pry.github.com"
|
15
15
|
s.require_paths = ["lib"]
|
16
|
-
s.rubygems_version = "1.8.
|
16
|
+
s.rubygems_version = "1.8.12"
|
17
17
|
s.summary = "An IRB alternative and runtime developer console"
|
18
|
-
s.test_files = ["test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
|
18
|
+
s.test_files = ["test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_default_commands/test_show_source.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
|
19
19
|
|
20
20
|
if s.respond_to? :specification_version then
|
21
21
|
s.specification_version = 3
|
data/test/helper.rb
CHANGED
@@ -24,6 +24,28 @@ ensure
|
|
24
24
|
Thread.current[:__pry_local__] = nil
|
25
25
|
end
|
26
26
|
|
27
|
+
def constant_scope(*names)
|
28
|
+
names.each do |name|
|
29
|
+
Object.remove_const name if Object.const_defined?(name)
|
30
|
+
end
|
31
|
+
|
32
|
+
yield
|
33
|
+
ensure
|
34
|
+
names.each do |name|
|
35
|
+
Object.remove_const name if Object.const_defined?(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def mri18_and_no_real_source_location?
|
40
|
+
Pry::Helpers::BaseHelpers.mri_18? && !(Method.instance_method(:source_location).owner == Method)
|
41
|
+
end
|
42
|
+
|
43
|
+
# used by test_show_source.rb and test_documentation.rb
|
44
|
+
class TestClassForShowSource
|
45
|
+
def alpha
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
# in case the tests call reset_defaults, ensure we reset them to
|
28
50
|
# amended (test friendly) values
|
29
51
|
class << Pry
|
data/test/test_command.rb
CHANGED
@@ -594,4 +594,33 @@ describe "Pry::Command" do
|
|
594
594
|
end
|
595
595
|
end
|
596
596
|
end
|
597
|
+
|
598
|
+
describe "commands made with custom sub-classes" do
|
599
|
+
before do
|
600
|
+
|
601
|
+
class MyTestCommand < Pry::ClassCommand
|
602
|
+
match /my-*test/
|
603
|
+
description "So just how many sound technicians does it take to change a lightbulb? 1? 2? 3? 1-2-3? Testing?"
|
604
|
+
options :shellwords => false, :listing => "my-test"
|
605
|
+
|
606
|
+
def process
|
607
|
+
output.puts command_name * 2
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
Pry.commands.add_command MyTestCommand
|
612
|
+
end
|
613
|
+
|
614
|
+
after do
|
615
|
+
Pry.commands.delete 'my-test'
|
616
|
+
end
|
617
|
+
|
618
|
+
it "should allow creating custom sub-classes of Pry::Command" do
|
619
|
+
mock_pry("my---test").should =~ /my-testmy-test/
|
620
|
+
end
|
621
|
+
|
622
|
+
it "should show the source of the process method" do
|
623
|
+
mock_pry("show-command my-test").should =~ /output.puts command_name/
|
624
|
+
end
|
625
|
+
end
|
597
626
|
end
|
@@ -1,5 +1,117 @@
|
|
1
1
|
require 'helper'
|
2
2
|
describe "commands" do
|
3
|
+
|
4
|
+
describe "alias_command" do
|
5
|
+
it 'should make an aliasd command behave like its original' do
|
6
|
+
set = Pry::CommandSet.new do
|
7
|
+
command "test-command" do
|
8
|
+
output.puts "testing 1, 2, 3"
|
9
|
+
end
|
10
|
+
alias_command "test-alias", "test-command"
|
11
|
+
end
|
12
|
+
redirect_pry_io(InputTester.new("test-alias"), out1 = StringIO.new) do
|
13
|
+
Pry.start self, :commands => set
|
14
|
+
end
|
15
|
+
|
16
|
+
redirect_pry_io(InputTester.new("test-command"), out2 = StringIO.new) do
|
17
|
+
Pry.start self, :commands => set
|
18
|
+
end
|
19
|
+
|
20
|
+
out1.string.should == out2.string
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should pass on arguments to original' do
|
24
|
+
set = Pry::CommandSet.new do
|
25
|
+
command "test-command" do |*args|
|
26
|
+
output.puts "testing #{args.join(' ')}"
|
27
|
+
end
|
28
|
+
alias_command "test-alias", "test-command"
|
29
|
+
end
|
30
|
+
|
31
|
+
redirect_pry_io(InputTester.new("test-command hello baby duck"), out1 = StringIO.new) do
|
32
|
+
Pry.start self, :commands => set
|
33
|
+
end
|
34
|
+
|
35
|
+
out1.string.should =~ /hello baby duck/
|
36
|
+
|
37
|
+
redirect_pry_io(InputTester.new("test-alias hello baby duck"), out2 = StringIO.new) do
|
38
|
+
Pry.start self, :commands => set
|
39
|
+
end
|
40
|
+
|
41
|
+
out2.string.should == out1.string
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should pass option arguments to original' do
|
45
|
+
set = Pry::CommandSet.new do
|
46
|
+
import Pry::Commands
|
47
|
+
alias_command "test-alias", "ls"
|
48
|
+
end
|
49
|
+
|
50
|
+
obj = Class.new { @x = 10 }
|
51
|
+
redirect_pry_io(InputTester.new("ls -i"), out1 = StringIO.new) do
|
52
|
+
Pry.start obj, :commands => set
|
53
|
+
end
|
54
|
+
|
55
|
+
out1.string.should =~ /@x/
|
56
|
+
|
57
|
+
redirect_pry_io(InputTester.new("test-alias -i"), out2 = StringIO.new) do
|
58
|
+
Pry.start obj, :commands => set
|
59
|
+
end
|
60
|
+
|
61
|
+
out2.string.should == out1.string
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should pass option arguments to original with additional parameters' do
|
65
|
+
set = Pry::CommandSet.new do
|
66
|
+
import Pry::Commands
|
67
|
+
alias_command "test-alias", "ls -M"
|
68
|
+
end
|
69
|
+
|
70
|
+
obj = Class.new { @x = Class.new { define_method(:plymouth) {} } }
|
71
|
+
redirect_pry_io(InputTester.new("ls -M @x"), out1 = StringIO.new) do
|
72
|
+
Pry.start obj, :commands => set
|
73
|
+
end
|
74
|
+
|
75
|
+
out1.string.should =~ /plymouth/
|
76
|
+
|
77
|
+
redirect_pry_io(InputTester.new("test-alias @x"), out2 = StringIO.new) do
|
78
|
+
Pry.start obj, :commands => set
|
79
|
+
end
|
80
|
+
|
81
|
+
out2.string.should == out1.string
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should be able to alias a regex command' do
|
85
|
+
set = Pry::CommandSet.new do
|
86
|
+
command /du.k/ do
|
87
|
+
output.puts "ducky"
|
88
|
+
end
|
89
|
+
alias_command "test-alias", "duck"
|
90
|
+
end
|
91
|
+
|
92
|
+
redirect_pry_io(InputTester.new("test-alias"), out1 = StringIO.new) do
|
93
|
+
Pry.start self, :commands => set
|
94
|
+
end
|
95
|
+
|
96
|
+
out1.string.should =~ /ducky/
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should be able to make the alias a regex' do
|
100
|
+
set = Pry::CommandSet.new do
|
101
|
+
command /du.k/ do
|
102
|
+
output.puts "ducky"
|
103
|
+
end
|
104
|
+
alias_command /test-ali.s/, "duck"
|
105
|
+
end
|
106
|
+
|
107
|
+
redirect_pry_io(InputTester.new("test-alias"), out1 = StringIO.new) do
|
108
|
+
Pry.start self, :commands => set
|
109
|
+
end
|
110
|
+
|
111
|
+
out1.string.should =~ /ducky/
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
3
115
|
it 'should interpolate ruby code into commands' do
|
4
116
|
klass = Pry::CommandSet.new do
|
5
117
|
command "hello", "", :keep_retval => true do |arg|
|
@@ -199,7 +311,7 @@ describe "commands" do
|
|
199
311
|
str_output = StringIO.new
|
200
312
|
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => klass).rep
|
201
313
|
(str_output.string =~ /:kept_hello/).should == nil
|
202
|
-
|
314
|
+
str_output.string !~ /=>/
|
203
315
|
end
|
204
316
|
|
205
317
|
it 'should define a command that keeps its return value even when nil' do
|
@@ -211,7 +323,7 @@ describe "commands" do
|
|
211
323
|
str_output = StringIO.new
|
212
324
|
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => klass).rep
|
213
325
|
str_output.string.should =~ /nil/
|
214
|
-
|
326
|
+
str_output.string.should =~ /=>/
|
215
327
|
end
|
216
328
|
|
217
329
|
it 'should define a command that keeps its return value but does not return when value is void' do
|
@@ -299,14 +411,6 @@ describe "commands" do
|
|
299
411
|
klass.commands.include?("v").should == true
|
300
412
|
end
|
301
413
|
|
302
|
-
it 'should alias a command with another command' do
|
303
|
-
klass = Pry::CommandSet.new do
|
304
|
-
import Pry::DefaultCommands::Help
|
305
|
-
alias_command "help2", "help"
|
306
|
-
end
|
307
|
-
klass.commands["help2"].block.should == klass.commands["help"].block
|
308
|
-
end
|
309
|
-
|
310
414
|
it 'should change description of a command using desc' do
|
311
415
|
klass = Pry::CommandSet.new do; import Pry::DefaultCommands::Help; end
|
312
416
|
orig = klass.commands["help"].description
|
@@ -317,6 +421,83 @@ describe "commands" do
|
|
317
421
|
klass.commands["help"].description.should == "blah"
|
318
422
|
end
|
319
423
|
|
424
|
+
|
425
|
+
describe "Pry::Command#run" do
|
426
|
+
it 'should allow running of commands with following whitespace' do
|
427
|
+
$_scratch = Object.new
|
428
|
+
o = Object.new
|
429
|
+
|
430
|
+
set = Pry::CommandSet.new do
|
431
|
+
import Pry::Commands
|
432
|
+
command "test-run" do
|
433
|
+
run "cd / "
|
434
|
+
end
|
435
|
+
end
|
436
|
+
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6/$_scratch",
|
437
|
+
"@nesting1 = _pry_.binding_stack.size",
|
438
|
+
"test-run",
|
439
|
+
"@obj = self",
|
440
|
+
"@nesting2 = _pry_.binding_stack.size",
|
441
|
+
"exit-all")) do
|
442
|
+
Pry.start(o, :commands => set)
|
443
|
+
end
|
444
|
+
|
445
|
+
$_scratch.instance_variable_get(:@nesting1).should == 8
|
446
|
+
o.instance_variable_get(:@obj).should == o
|
447
|
+
o.instance_variable_get(:@nesting2).should == 1
|
448
|
+
$_scratch = nil
|
449
|
+
end
|
450
|
+
|
451
|
+
it 'should allow running of cd command when contained in a single string' do
|
452
|
+
$_scratch = Object.new
|
453
|
+
o = Object.new
|
454
|
+
|
455
|
+
set = Pry::CommandSet.new do
|
456
|
+
import Pry::Commands
|
457
|
+
command "test-run" do
|
458
|
+
run "cd /"
|
459
|
+
end
|
460
|
+
end
|
461
|
+
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6/$_scratch",
|
462
|
+
"@nesting1 = _pry_.binding_stack.size",
|
463
|
+
"test-run",
|
464
|
+
"@obj = self",
|
465
|
+
"@nesting2 = _pry_.binding_stack.size",
|
466
|
+
"exit-all")) do
|
467
|
+
Pry.start(o, :commands => set)
|
468
|
+
end
|
469
|
+
|
470
|
+
$_scratch.instance_variable_get(:@nesting1).should == 8
|
471
|
+
o.instance_variable_get(:@obj).should == o
|
472
|
+
o.instance_variable_get(:@nesting2).should == 1
|
473
|
+
$_scratch = nil
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'should allow running of cd command when split into array' do
|
477
|
+
$_scratch = Object.new
|
478
|
+
o = Object.new
|
479
|
+
|
480
|
+
set = Pry::CommandSet.new do
|
481
|
+
import Pry::Commands
|
482
|
+
command "test-run" do
|
483
|
+
run "cd", "/"
|
484
|
+
end
|
485
|
+
end
|
486
|
+
redirect_pry_io(InputTester.new("cd 1/2/3/4/5/6/$_scratch",
|
487
|
+
"@nesting1 = _pry_.binding_stack.size",
|
488
|
+
"test-run",
|
489
|
+
"@obj = self",
|
490
|
+
"@nesting2 = _pry_.binding_stack.size",
|
491
|
+
"exit-all")) do
|
492
|
+
Pry.start(o, :commands => set)
|
493
|
+
end
|
494
|
+
|
495
|
+
$_scratch.instance_variable_get(:@nesting1).should == 8
|
496
|
+
o.instance_variable_get(:@obj).should == o
|
497
|
+
o.instance_variable_get(:@nesting2).should == 1
|
498
|
+
$_scratch = nil
|
499
|
+
end
|
500
|
+
|
320
501
|
it 'should run a command from within a command' do
|
321
502
|
klass = Pry::CommandSet.new do
|
322
503
|
command "v" do
|
@@ -376,6 +557,8 @@ describe "commands" do
|
|
376
557
|
end
|
377
558
|
end
|
378
559
|
|
560
|
+
end
|
561
|
+
|
379
562
|
it 'should enable an inherited method to access opts and output and target, due to instance_exec' do
|
380
563
|
klass = Pry::CommandSet.new do
|
381
564
|
command "v" do
|
data/test/test_command_set.rb
CHANGED
@@ -80,6 +80,28 @@ describe Pry::CommandSet do
|
|
80
80
|
}.should.raise(Pry::NoCommandError)
|
81
81
|
end
|
82
82
|
|
83
|
+
it 'should return command set after import' do
|
84
|
+
run = false
|
85
|
+
|
86
|
+
other_set = Pry::CommandSet.new do
|
87
|
+
command('foo') { run = true }
|
88
|
+
command('bar') {}
|
89
|
+
end
|
90
|
+
|
91
|
+
@set.import(other_set).should == @set
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should return command set after import_from' do
|
95
|
+
run = false
|
96
|
+
|
97
|
+
other_set = Pry::CommandSet.new do
|
98
|
+
command('foo') { run = true }
|
99
|
+
command('bar') {}
|
100
|
+
end
|
101
|
+
|
102
|
+
@set.import_from(other_set, 'foo').should == @set
|
103
|
+
end
|
104
|
+
|
83
105
|
it 'should be able to import some commands from other sets using listing name' do
|
84
106
|
run = false
|
85
107
|
|
@@ -121,28 +143,71 @@ describe Pry::CommandSet do
|
|
121
143
|
@set.commands['foo'].description.should == 'some stuff'
|
122
144
|
end
|
123
145
|
|
124
|
-
|
125
|
-
|
126
|
-
|
146
|
+
describe "aliases" do
|
147
|
+
it 'should be able to alias command' do
|
148
|
+
run = false
|
149
|
+
@set.command('foo', 'stuff') { run = true }
|
127
150
|
|
128
|
-
|
129
|
-
|
130
|
-
|
151
|
+
@set.alias_command 'bar', 'foo'
|
152
|
+
@set.commands['bar'].match.should == 'bar'
|
153
|
+
@set.commands['bar'].description.should == 'Alias for `foo`'
|
131
154
|
|
132
|
-
|
133
|
-
|
134
|
-
|
155
|
+
@set.run_command @ctx, 'bar'
|
156
|
+
run.should == true
|
157
|
+
end
|
135
158
|
|
136
|
-
|
137
|
-
|
138
|
-
|
159
|
+
it 'should inherit options from original command' do
|
160
|
+
run = false
|
161
|
+
@set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true }
|
139
162
|
|
140
|
-
|
141
|
-
|
142
|
-
|
163
|
+
@set.alias_command 'bar', 'foo'
|
164
|
+
@set.commands['bar'].options[:shellwords].should == @set.commands['foo'].options[:shellwords]
|
165
|
+
@set.commands['bar'].options[:interpolate].should == @set.commands['foo'].options[:interpolate]
|
143
166
|
|
144
|
-
|
145
|
-
|
167
|
+
# however some options should not be inherited
|
168
|
+
@set.commands['bar'].options[:listing].should.not == @set.commands['foo'].options[:listing]
|
169
|
+
@set.commands['bar'].options[:listing].should == "bar"
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should be able to specify alias\'s description when aliasing' do
|
173
|
+
run = false
|
174
|
+
@set.command('foo', 'stuff') { run = true }
|
175
|
+
|
176
|
+
@set.alias_command 'bar', 'foo', :desc => "tobina"
|
177
|
+
@set.commands['bar'].match.should == 'bar'
|
178
|
+
@set.commands['bar'].description.should == "tobina"
|
179
|
+
|
180
|
+
@set.run_command @ctx, 'bar'
|
181
|
+
run.should == true
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should be able to alias a command by its invocation line" do
|
185
|
+
run = false
|
186
|
+
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
187
|
+
|
188
|
+
@set.alias_command 'bar', 'foo1'
|
189
|
+
@set.commands['bar'].match.should == 'bar'
|
190
|
+
@set.commands['bar'].description.should == 'Alias for `foo1`'
|
191
|
+
|
192
|
+
@set.run_command @ctx, 'bar'
|
193
|
+
run.should == true
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should be able to specify options when creating alias" do
|
197
|
+
run = false
|
198
|
+
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
199
|
+
|
200
|
+
@set.alias_command /^b.r/, 'foo1', :listing => "bar"
|
201
|
+
@set.commands[/^b.r/].options[:listing].should == "bar"
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should set description to default if description parameter is nil" do
|
205
|
+
run = false
|
206
|
+
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
|
207
|
+
|
208
|
+
@set.alias_command "bar", 'foo1'
|
209
|
+
@set.commands["bar"].description.should == "Alias for `foo1`"
|
210
|
+
end
|
146
211
|
end
|
147
212
|
|
148
213
|
it 'should be able to change the descriptions of commands' do
|