pry 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/Rakefile +12 -1
- data/lib/pry/command_base.rb +23 -0
- data/lib/pry/commands.rb +10 -5
- data/lib/pry/pry_class.rb +0 -2
- data/lib/pry/version.rb +1 -1
- data/test/test.rb +33 -3
- metadata +4 -9
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
License
|
2
|
+
-------
|
3
|
+
|
4
|
+
(The MIT License)
|
5
|
+
|
6
|
+
Copyright (c) 2011 John Mair (banisterfiend)
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
'Software'), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ def apply_spec_defaults(s)
|
|
25
25
|
s.homepage = "http://banisterfiend.wordpress.com"
|
26
26
|
s.has_rdoc = 'yard'
|
27
27
|
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb",
|
28
|
-
"test/*.rb", "CHANGELOG", "README.markdown", "Rakefile", ".gemtest"]
|
28
|
+
"test/*.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"]
|
29
29
|
end
|
30
30
|
|
31
31
|
task :test do
|
@@ -37,6 +37,17 @@ task :show_version do
|
|
37
37
|
puts "Pry version: #{Pry::VERSION}"
|
38
38
|
end
|
39
39
|
|
40
|
+
desc "run pry"
|
41
|
+
task :pry do
|
42
|
+
require "#{direc}/lib/pry.rb"
|
43
|
+
Pry.start
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "show pry version"
|
47
|
+
task :version do
|
48
|
+
puts "Pry version: #{Pry::VERSION}"
|
49
|
+
end
|
50
|
+
|
40
51
|
namespace :ruby do
|
41
52
|
spec = Gem::Specification.new do |s|
|
42
53
|
apply_spec_defaults(s)
|
data/lib/pry/command_base.rb
CHANGED
@@ -83,6 +83,29 @@ class Pry
|
|
83
83
|
imported_hash = Hash[klass.commands.select { |k, v| names.include?(k) }]
|
84
84
|
commands.merge!(imported_hash)
|
85
85
|
end
|
86
|
+
|
87
|
+
# Create an alias for a command.
|
88
|
+
# @param [String] new_command The alias name.
|
89
|
+
# @param [String] orig_command The original command name.
|
90
|
+
# @example
|
91
|
+
# class MyCommands < Pry::CommandBase
|
92
|
+
# alias_command "help_alias", "help"
|
93
|
+
def alias_command(new_command_name, orig_command_name, desc=nil)
|
94
|
+
commands[new_command_name] = commands[orig_command_name].dup
|
95
|
+
commands[new_command_name][:description] = desc if desc
|
96
|
+
end
|
97
|
+
|
98
|
+
# Set the description for a command (replacing the old
|
99
|
+
# description.)
|
100
|
+
# @param [String] name The command name.
|
101
|
+
# @param [String] description The command description.
|
102
|
+
# @example
|
103
|
+
# class MyCommands < Pry::CommandBase
|
104
|
+
# desc "help", "help description"
|
105
|
+
# end
|
106
|
+
def desc(name, description)
|
107
|
+
commands[name][:description] = description
|
108
|
+
end
|
86
109
|
end
|
87
110
|
|
88
111
|
command "help", "This menu." do |cmd|
|
data/lib/pry/commands.rb
CHANGED
@@ -76,12 +76,17 @@ class Pry
|
|
76
76
|
end
|
77
77
|
|
78
78
|
command "show_method", "Show sourcecode for method <methname>." do |meth_name|
|
79
|
-
|
80
|
-
|
79
|
+
if meth_name
|
80
|
+
meth_name = target.eval("__method__").to_s if !meth_name
|
81
|
+
doc = target.eval("method(\"#{meth_name}\")").source
|
82
|
+
output.puts doc
|
83
|
+
else
|
84
|
+
output.puts "Error: Not in a method."
|
85
|
+
end
|
81
86
|
end
|
82
87
|
|
83
88
|
command "show_imethod", "Show sourcecode for instance method <methname>." do |meth_name|
|
84
|
-
doc = target.eval("instance_method(
|
89
|
+
doc = target.eval("instance_method(\"#{meth_name}\")").source
|
85
90
|
output.puts doc
|
86
91
|
end
|
87
92
|
|
@@ -101,11 +106,11 @@ class Pry
|
|
101
106
|
end
|
102
107
|
|
103
108
|
command "ls_methods", "List all methods defined on class of receiver." do
|
104
|
-
output.puts "#{Pry.view(target.eval('public_methods(false) + private_methods(false) + protected_methods(false)'))}"
|
109
|
+
output.puts "#{Pry.view(target.eval('(public_methods(false) + private_methods(false) + protected_methods(false)).sort'))}"
|
105
110
|
end
|
106
111
|
|
107
112
|
command "ls_imethods", "List all instance methods defined on class of receiver." do
|
108
|
-
output.puts "#{Pry.view(target.eval('public_instance_methods(false) + private_instance_methods(false) + protected_instance_methods(false)'))}"
|
113
|
+
output.puts "#{Pry.view(target.eval('(public_instance_methods(false) + private_instance_methods(false) + protected_instance_methods(false)).sort'))}"
|
109
114
|
end
|
110
115
|
|
111
116
|
command ["exit", "quit", "back"], "End the current Pry session." do
|
data/lib/pry/pry_class.rb
CHANGED
data/lib/pry/version.rb
CHANGED
data/test/test.rb
CHANGED
@@ -353,8 +353,38 @@ describe Pry do
|
|
353
353
|
Object.remove_const(:Command3)
|
354
354
|
end
|
355
355
|
|
356
|
+
it 'should alias a command with another command' do
|
357
|
+
class Command6 < Pry::CommandBase
|
358
|
+
alias_command "help2", "help"
|
359
|
+
end
|
360
|
+
|
361
|
+
Command6.commands["help2"].should == Command6.commands["help"]
|
362
|
+
# str_output = StringIO.new
|
363
|
+
# Pry.new(:input => InputTester.new("run_v"), :output => str_output, :commands => Command3).rep
|
364
|
+
# str_output.string.should =~ /v command/
|
365
|
+
|
366
|
+
Object.remove_const(:Command6)
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'should change description of a command using desc' do
|
370
|
+
|
371
|
+
class Command7 < Pry::Commands
|
372
|
+
end
|
373
|
+
|
374
|
+
orig = Command7.commands["help"][:description]
|
375
|
+
|
376
|
+
class Command7
|
377
|
+
desc "help", "blah"
|
378
|
+
end
|
379
|
+
|
380
|
+
Command7.commands["help"][:description].should.not == orig
|
381
|
+
Command7.commands["help"][:description].should == "blah"
|
382
|
+
|
383
|
+
Object.remove_const(:Command7)
|
384
|
+
end
|
385
|
+
|
356
386
|
it 'should run a command from within a command' do
|
357
|
-
class
|
387
|
+
class Command01 < Pry::Commands
|
358
388
|
command "v" do
|
359
389
|
output.puts "v command"
|
360
390
|
end
|
@@ -365,10 +395,10 @@ describe Pry do
|
|
365
395
|
end
|
366
396
|
|
367
397
|
str_output = StringIO.new
|
368
|
-
Pry.new(:input => InputTester.new("run_v"), :output => str_output, :commands =>
|
398
|
+
Pry.new(:input => InputTester.new("run_v"), :output => str_output, :commands => Command01).rep
|
369
399
|
str_output.string.should =~ /v command/
|
370
400
|
|
371
|
-
Object.remove_const(:
|
401
|
+
Object.remove_const(:Command01)
|
372
402
|
end
|
373
403
|
|
374
404
|
it 'should enable an inherited method to access opts and output and target, due to instance_exec' do
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 13
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- John Mair (banisterfiend)
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-27 00:00:00 +13:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
28
|
segments:
|
31
29
|
- 2
|
32
30
|
- 0
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 23
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 2
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 19
|
62
58
|
segments:
|
63
59
|
- 1
|
64
60
|
- 1
|
@@ -89,6 +85,7 @@ files:
|
|
89
85
|
- test/test.rb
|
90
86
|
- test/test_helper.rb
|
91
87
|
- CHANGELOG
|
88
|
+
- LICENSE
|
92
89
|
- README.markdown
|
93
90
|
- Rakefile
|
94
91
|
- .gemtest
|
@@ -106,7 +103,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
103
|
requirements:
|
107
104
|
- - ">="
|
108
105
|
- !ruby/object:Gem::Version
|
109
|
-
hash: 3
|
110
106
|
segments:
|
111
107
|
- 0
|
112
108
|
version: "0"
|
@@ -115,7 +111,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
111
|
requirements:
|
116
112
|
- - ">="
|
117
113
|
- !ruby/object:Gem::Version
|
118
|
-
hash: 3
|
119
114
|
segments:
|
120
115
|
- 0
|
121
116
|
version: "0"
|