pry 0.3.0 → 0.4.0pre1
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/CHANGELOG +10 -0
- data/README.markdown +442 -29
- data/lib/pry.rb +10 -247
- data/lib/pry/command_base.rb +114 -0
- data/lib/pry/commands.rb +115 -0
- data/lib/pry/completion.rb +202 -0
- data/lib/pry/core_extensions.rb +47 -0
- data/lib/pry/hooks.rb +8 -0
- data/lib/pry/print.rb +15 -0
- data/lib/pry/prompts.rb +24 -0
- data/lib/pry/pry_class.rb +109 -0
- data/lib/pry/pry_instance.rb +309 -0
- data/lib/pry/version.rb +1 -1
- data/test/test.rb +528 -0
- data/test/test_helper.rb +38 -0
- metadata +21 -15
- data/lib/pry/input.rb +0 -22
- data/lib/pry/output.rb +0 -100
data/test/test_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Module
|
2
|
+
public :remove_const
|
3
|
+
end
|
4
|
+
|
5
|
+
class InputTester
|
6
|
+
def initialize(*actions)
|
7
|
+
@orig_actions = actions.dup
|
8
|
+
@actions = actions
|
9
|
+
end
|
10
|
+
|
11
|
+
def readline(*)
|
12
|
+
@actions.shift
|
13
|
+
end
|
14
|
+
|
15
|
+
def rewind
|
16
|
+
@actions = @orig_actions.dup
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Pry
|
21
|
+
|
22
|
+
# null output class - doesn't write anywwhere.
|
23
|
+
class NullOutput
|
24
|
+
def self.puts(*) end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
class CommandTester < Pry::CommandBase
|
30
|
+
|
31
|
+
command "command1", "command 1 test" do
|
32
|
+
output.puts "command1"
|
33
|
+
end
|
34
|
+
|
35
|
+
command "command2", "command 2 test" do |arg|
|
36
|
+
output.puts arg
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
4
|
+
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0pre1
|
9
|
+
version: 0.4.0pre1
|
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:
|
17
|
+
date: 2011-01-22 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
|
@@ -59,10 +56,19 @@ extensions: []
|
|
59
56
|
extra_rdoc_files: []
|
60
57
|
|
61
58
|
files:
|
62
|
-
- lib/pry/
|
63
|
-
- lib/pry/
|
59
|
+
- lib/pry/commands.rb
|
60
|
+
- lib/pry/command_base.rb
|
61
|
+
- lib/pry/completion.rb
|
62
|
+
- lib/pry/core_extensions.rb
|
63
|
+
- lib/pry/hooks.rb
|
64
|
+
- lib/pry/print.rb
|
65
|
+
- lib/pry/prompts.rb
|
66
|
+
- lib/pry/pry_class.rb
|
67
|
+
- lib/pry/pry_instance.rb
|
64
68
|
- lib/pry/version.rb
|
65
69
|
- lib/pry.rb
|
70
|
+
- test/test.rb
|
71
|
+
- test/test_helper.rb
|
66
72
|
- CHANGELOG
|
67
73
|
- README.markdown
|
68
74
|
- Rakefile
|
@@ -80,19 +86,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
86
|
requirements:
|
81
87
|
- - ">="
|
82
88
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
89
|
segments:
|
85
90
|
- 0
|
86
91
|
version: "0"
|
87
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
93
|
none: false
|
89
94
|
requirements:
|
90
|
-
- - "
|
95
|
+
- - ">"
|
91
96
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
97
|
segments:
|
94
|
-
-
|
95
|
-
|
98
|
+
- 1
|
99
|
+
- 3
|
100
|
+
- 1
|
101
|
+
version: 1.3.1
|
96
102
|
requirements: []
|
97
103
|
|
98
104
|
rubyforge_project:
|
data/lib/pry/input.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'readline'
|
2
|
-
|
3
|
-
class Pry
|
4
|
-
class Input
|
5
|
-
trap('INT') { exit }
|
6
|
-
|
7
|
-
def read(prompt)
|
8
|
-
Readline.readline(prompt, true)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class SourceInput
|
13
|
-
def initialize(file, line)
|
14
|
-
@f = File.open(file)
|
15
|
-
(line - 1).times { @f.readline }
|
16
|
-
end
|
17
|
-
|
18
|
-
def read(prompt)
|
19
|
-
@f.readline
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/pry/output.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
class Output
|
3
|
-
attr_reader :out
|
4
|
-
|
5
|
-
def initialize(out=STDOUT)
|
6
|
-
@out = out
|
7
|
-
end
|
8
|
-
|
9
|
-
def refresh
|
10
|
-
out.puts "Refreshed REPL"
|
11
|
-
end
|
12
|
-
|
13
|
-
def session_start(obj)
|
14
|
-
out.puts "Beginning Pry session for #{Pry.view(obj)}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def session_end(obj)
|
18
|
-
out.puts "Ending Pry session for #{Pry.view(obj)}"
|
19
|
-
end
|
20
|
-
|
21
|
-
# the print component of READ-EVAL-PRINT-LOOP
|
22
|
-
def print(value)
|
23
|
-
case value
|
24
|
-
when Exception
|
25
|
-
out.puts "#{value.class}: #{value.message}"
|
26
|
-
else
|
27
|
-
out.puts "=> #{Pry.view(value)}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def show_help
|
32
|
-
out.puts "Command list:"
|
33
|
-
out.puts "--"
|
34
|
-
out.puts "help This menu"
|
35
|
-
out.puts "status Show status information"
|
36
|
-
out.puts "! Refresh the REPL"
|
37
|
-
out.puts "nesting Show nesting information"
|
38
|
-
out.puts "ls Show the list of variables in the current scope"
|
39
|
-
out.puts "cat <var> Show output of <var>.inspect"
|
40
|
-
out.puts "cd <var> Start a Pry session on <var> (use `cd ..` to go back)"
|
41
|
-
out.puts "show_method <methname> Show the sourcecode for the method <methname>"
|
42
|
-
out.puts "show_imethod <methname> Show the sourcecode for the instance method <method_name>"
|
43
|
-
out.puts "show_doc <methname> Show the comments above <methname>"
|
44
|
-
out.puts "show_idoc <methname> Show the comments above instance method <methname>"
|
45
|
-
out.puts "exit/quit/back End the current Pry session"
|
46
|
-
out.puts "exit_all End all nested Pry sessions"
|
47
|
-
out.puts "exit_program/quit_program End the current program"
|
48
|
-
out.puts "jump_to <level> Jump to a Pry session further up the stack, exiting all sessions below"
|
49
|
-
end
|
50
|
-
|
51
|
-
def show_nesting(nesting)
|
52
|
-
out.puts "Nesting status:"
|
53
|
-
out.puts "--"
|
54
|
-
nesting.each do |level, obj|
|
55
|
-
if level == 0
|
56
|
-
out.puts "#{level}. #{Pry.view(obj)} (Pry top level)"
|
57
|
-
else
|
58
|
-
out.puts "#{level}. #{Pry.view(obj)}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def show_status(nesting, target)
|
64
|
-
out.puts "Status:"
|
65
|
-
out.puts "--"
|
66
|
-
out.puts "Receiver: #{Pry.view(target.eval('self'))}"
|
67
|
-
out.puts "Nesting level: #{nesting.level}"
|
68
|
-
out.puts "Local variables: #{target.eval('Pry.view(local_variables)')}"
|
69
|
-
out.puts "Last result: #{Pry.view(Pry.last_result)}"
|
70
|
-
end
|
71
|
-
|
72
|
-
def ls(target)
|
73
|
-
out.puts "#{target.eval('Pry.view(local_variables + instance_variables)')}"
|
74
|
-
end
|
75
|
-
|
76
|
-
def cat(target, var)
|
77
|
-
out.puts target.eval("#{var}.inspect")
|
78
|
-
end
|
79
|
-
|
80
|
-
def show_method(code)
|
81
|
-
out.puts code
|
82
|
-
end
|
83
|
-
|
84
|
-
def show_doc(doc)
|
85
|
-
out.puts doc
|
86
|
-
end
|
87
|
-
|
88
|
-
def warn_already_at_level(nesting_level)
|
89
|
-
out.puts "Already at nesting level #{nesting_level}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def err_invalid_nest_level(nest_level, max_nest_level)
|
93
|
-
out.puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{nest_level}."
|
94
|
-
end
|
95
|
-
|
96
|
-
def exit() end
|
97
|
-
def jump_to(nesting_level_breakout) end
|
98
|
-
def exit_program() end
|
99
|
-
end
|
100
|
-
end
|