pry-stack_explorer 0.2.7pre3 → 0.2.7pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pry-stack_explorer/commands.rb +43 -18
- data/lib/pry-stack_explorer/version.rb +1 -1
- metadata +5 -5
@@ -7,18 +7,18 @@ module PryStackExplorer
|
|
7
7
|
output.puts "Nowhere to go!"
|
8
8
|
else
|
9
9
|
binding_index = PryStackExplorer.frame_manager(_pry_).binding_index
|
10
|
-
PryStackExplorer.frame_manager(_pry_).change_frame_to binding_index + inc
|
10
|
+
PryStackExplorer.frame_manager(_pry_).change_frame_to binding_index + inc
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
command "down", "Go down to the callee's context." do |inc_str|
|
15
15
|
inc = inc_str.nil? ? 1 : inc_str.to_i
|
16
16
|
|
17
|
-
if !PryStackExplorer.frame_manager(_pry_)
|
17
|
+
if !PryStackExplorer.frame_manager(_pry_)
|
18
18
|
output.puts "Nowhere to go!"
|
19
19
|
else
|
20
20
|
binding_index = PryStackExplorer.frame_manager(_pry_).binding_index
|
21
|
-
PryStackExplorer.frame_manager(_pry_).change_frame_to binding_index - inc
|
21
|
+
PryStackExplorer.frame_manager(_pry_).change_frame_to binding_index - inc
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -39,22 +39,10 @@ module PryStackExplorer
|
|
39
39
|
output.puts "\n#{text.bold('Showing all accessible frames in stack:')}\n--\n"
|
40
40
|
|
41
41
|
PryStackExplorer.frame_manager(_pry_).each_with_index do |b, i|
|
42
|
-
meth = b.eval('__method__')
|
43
|
-
b_self = b.eval('self')
|
44
|
-
|
45
|
-
desc = b.frame_description ? "#{text.bold('Description:')} #{b.frame_description}".ljust(40) :
|
46
|
-
"#{text.bold('Description:')} #{PryStackExplorer.frame_manager(_pry_).frame_info_for(b)}".ljust(40)
|
47
|
-
sig = meth ? "#{text.bold('Signature:')} #{Pry::Method.new(b_self.method(meth)).signature}".ljust(40) : "".ljust(32)
|
48
|
-
type = b.frame_type ? "#{text.bold('Type:')} #{b.frame_type}".ljust(20) : "".ljust(20)
|
49
|
-
slf_class = "#{text.bold('Self.class:')} #{b_self.class}".ljust(20)
|
50
|
-
path = "#{text.bold("@ File:")} #{b.eval('__FILE__')}:#{b.eval('__LINE__')}"
|
51
|
-
|
52
|
-
info = "##{i} #{desc} #{slf_class} #{sig} #{type \
|
53
|
-
if opts[:v]} #{path if opts[:v]}"
|
54
42
|
if i == PryStackExplorer.frame_manager(_pry_).binding_index
|
55
|
-
output.puts "=> #{
|
43
|
+
output.puts "=> ##{i} #{frame_info(b, opts[:v])}"
|
56
44
|
else
|
57
|
-
output.puts " #{
|
45
|
+
output.puts " ##{i} #{frame_info(b, opts[:v])}"
|
58
46
|
end
|
59
47
|
end
|
60
48
|
end
|
@@ -64,12 +52,49 @@ module PryStackExplorer
|
|
64
52
|
if !PryStackExplorer.frame_manager(_pry_)
|
65
53
|
output.puts "nowhere to go!"
|
66
54
|
else
|
67
|
-
|
55
|
+
if frame_num
|
56
|
+
PryStackExplorer.frame_manager(_pry_).change_frame_to frame_num.to_i
|
57
|
+
else
|
58
|
+
output.puts "##{PryStackExplorer.frame_manager(_pry_).binding_index} #{frame_info(target)}"
|
59
|
+
end
|
68
60
|
end
|
69
61
|
end
|
70
62
|
|
71
63
|
command "frame-type", "Display current frame type." do
|
72
64
|
output.puts _pry_.binding_stack.last.frame_type
|
73
65
|
end
|
66
|
+
|
67
|
+
helpers do
|
68
|
+
def frame_info(b, verbose = false)
|
69
|
+
meth = b.eval('__method__')
|
70
|
+
methobj = b.eval('method(__method__)') if meth
|
71
|
+
b_self = b.eval('self')
|
72
|
+
|
73
|
+
desc = b.frame_description ? "#{text.bold('Description:')} #{b.frame_description}".ljust(40) :
|
74
|
+
"#{text.bold('Description:')} #{PryStackExplorer.frame_manager(_pry_).frame_info_for(b)}".ljust(40)
|
75
|
+
sig = meth ? "#{text.bold('Signature:')} #{signature_with_values(b, methobj)}".ljust(40) : "".ljust(32)
|
76
|
+
type = b.frame_type ? "#{text.bold('Type:')} #{b.frame_type}".ljust(20) : "".ljust(20)
|
77
|
+
slf_class = "#{text.bold('Self.class:')} #{b_self.class}".ljust(20)
|
78
|
+
path = "#{text.bold("@ File:")} #{b.eval('__FILE__')}:#{b.eval('__LINE__')}"
|
79
|
+
|
80
|
+
"#{desc} #{slf_class} #{sig} #{type if verbose} #{path if verbose}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def signature_with_values(b, meth)
|
84
|
+
args = meth.parameters.inject([]) do |arr, (type, name)|
|
85
|
+
name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
|
86
|
+
arr << case type
|
87
|
+
when :req then "#{name}=#{b.eval(name.to_s)}"
|
88
|
+
when :opt then "#{name}=#{b.eval(name.to_s)}"
|
89
|
+
when :rest then "*#{name}=#{b.eval(name.to_s)}"
|
90
|
+
when :block then "&#{name}"
|
91
|
+
else '?'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
"#{meth.name}(#{args.join(', ')})"
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
74
99
|
end
|
75
100
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-stack_explorer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7pre4
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: binding_of_caller
|
16
|
-
requirement: &
|
16
|
+
requirement: &70311169718300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70311169718300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bacon
|
27
|
-
requirement: &
|
27
|
+
requirement: &70311169717200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.1.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70311169717200
|
36
36
|
description: Walk the stack in a Pry session
|
37
37
|
email: jrmair@gmail.com
|
38
38
|
executables: []
|