pry-stack_explorer 0.2.0pre1 → 0.2.1pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pry-stack_explorer/version.rb +1 -1
- data/lib/pry-stack_explorer.rb +58 -29
- metadata +29 -62
data/lib/pry-stack_explorer.rb
CHANGED
@@ -23,7 +23,6 @@ module PryStackExplorer
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class FrameManager
|
26
|
-
attr_reader :pry_instance
|
27
26
|
attr_reader :binding_index
|
28
27
|
attr_accessor :bindings
|
29
28
|
|
@@ -32,7 +31,17 @@ module PryStackExplorer
|
|
32
31
|
@binding_index = 0
|
33
32
|
end
|
34
33
|
|
34
|
+
def convert_from_one_index(n)
|
35
|
+
if n >= 0
|
36
|
+
n - 1
|
37
|
+
else
|
38
|
+
n
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
35
42
|
def change_binding_to(index, pry_instance)
|
43
|
+
index = convert_from_one_index(index)
|
44
|
+
|
36
45
|
if index > bindings.size - 1
|
37
46
|
pry_instance.output.puts "Warning: At top of stack, cannot go further!"
|
38
47
|
elsif index < 0
|
@@ -52,9 +61,9 @@ module PryStackExplorer
|
|
52
61
|
|
53
62
|
if !PryStackExplorer.frame_manager
|
54
63
|
output.puts "Nowhere to go!"
|
55
|
-
|
64
|
+
else
|
56
65
|
binding_index = PryStackExplorer.frame_manager.binding_index
|
57
|
-
PryStackExplorer.frame_manager.change_binding_to binding_index + inc, _pry_
|
66
|
+
PryStackExplorer.frame_manager.change_binding_to binding_index + inc + 1, _pry_
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
@@ -65,7 +74,7 @@ module PryStackExplorer
|
|
65
74
|
output.puts "Nowhere to go!"
|
66
75
|
else
|
67
76
|
binding_index = PryStackExplorer.frame_manager.binding_index
|
68
|
-
PryStackExplorer.frame_manager.change_binding_to binding_index - inc, _pry_
|
77
|
+
PryStackExplorer.frame_manager.change_binding_to binding_index - inc + 1, _pry_
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
@@ -80,35 +89,55 @@ module PryStackExplorer
|
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
# were invoked with Pry.start or Object#pry
|
90
|
-
if binding.of_caller(1).eval('__method__') == :pry
|
91
|
-
drop_number = 2
|
92
|
-
else
|
93
|
-
drop_number = 1
|
94
|
-
end
|
95
|
-
|
96
|
-
bindings = binding.callers.drop(drop_number)
|
97
|
-
|
98
|
-
# Use the binding returned by #of_caller if possible (as we get
|
99
|
-
# access to frame_type).
|
100
|
-
# Otherwise stick to the given binding (target).
|
101
|
-
if !PryStackExplorer.bindings_equal?(target, bindings.first)
|
102
|
-
bindings.shift
|
103
|
-
bindings.unshift(target)
|
104
|
-
end
|
92
|
+
Pry.config.hooks.add_hook(:when_started) do |target|
|
93
|
+
if binding.of_caller(4).eval('__method__') == :pry
|
94
|
+
drop_number = 5
|
95
|
+
else
|
96
|
+
drop_number = 4
|
97
|
+
end
|
105
98
|
|
106
|
-
|
99
|
+
bindings = binding.callers.drop(drop_number)
|
107
100
|
|
108
|
-
|
101
|
+
# Use the binding returned by #of_caller if possible (as we get
|
102
|
+
# access to frame_type).
|
103
|
+
# Otherwise stick to the given binding (target).
|
104
|
+
if !PryStackExplorer.bindings_equal?(target, bindings.first)
|
105
|
+
bindings.shift
|
106
|
+
bindings.unshift(target)
|
109
107
|
end
|
108
|
+
|
109
|
+
PryStackExplorer.frame_manager = PryStackExplorer::FrameManager.new(bindings)
|
110
110
|
end
|
111
111
|
|
112
|
+
# class << Pry
|
113
|
+
# alias_method :PSE_old_start, :start
|
114
|
+
# def start(target, *args, &block)
|
115
|
+
# target = Pry.binding_for(target)
|
116
|
+
|
117
|
+
# # we need to know how many frames to skip depending on whether we
|
118
|
+
# # were invoked with Pry.start or Object#pry
|
119
|
+
# if binding.of_caller(1).eval('__method__') == :pry
|
120
|
+
# drop_number = 2
|
121
|
+
# else
|
122
|
+
# drop_number = 1
|
123
|
+
# end
|
124
|
+
|
125
|
+
# bindings = binding.callers.drop(drop_number)
|
126
|
+
|
127
|
+
# # Use the binding returned by #of_caller if possible (as we get
|
128
|
+
# # access to frame_type).
|
129
|
+
# # Otherwise stick to the given binding (target).
|
130
|
+
# if !PryStackExplorer.bindings_equal?(target, bindings.first)
|
131
|
+
# bindings.shift
|
132
|
+
# bindings.unshift(target)
|
133
|
+
# end
|
134
|
+
|
135
|
+
# PryStackExplorer.frame_manager = PryStackExplorer::FrameManager.new(bindings)
|
136
|
+
|
137
|
+
# PSE_old_start(bindings.first, *args, &block)
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
|
112
141
|
Pry.config.commands.import PryStackExplorer::StackCommands
|
113
142
|
|
114
143
|
Pry.config.commands.alias_command "__old_whereami__", "whereami", ""
|
@@ -121,7 +150,7 @@ Pry.config.commands.command "whereami", "Show the code context for the session.
|
|
121
150
|
binding_index = PryStackExplorer.frame_manager.binding_index
|
122
151
|
|
123
152
|
output.puts "\n"
|
124
|
-
output.puts "#{Pry::Helpers::Text.bold('Frame number:')} #{binding_index}/#{bindings.size
|
153
|
+
output.puts "#{Pry::Helpers::Text.bold('Frame number:')} #{binding_index + 1}/#{bindings.size}"
|
125
154
|
output.puts "#{Pry::Helpers::Text.bold('Frame type:')} #{bindings[binding_index].frame_type}" rescue nil
|
126
155
|
end
|
127
156
|
|
metadata
CHANGED
@@ -1,65 +1,44 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-stack_explorer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1pre1
|
5
5
|
prerelease: 5
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
- pre
|
11
|
-
- 1
|
12
|
-
version: 0.2.0pre1
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- John Mair (banisterfiend)
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
23
15
|
name: binding_of_caller
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70296103138940 !ruby/object:Gem::Requirement
|
26
17
|
none: false
|
27
|
-
requirements:
|
18
|
+
requirements:
|
28
19
|
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 11
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
- 5
|
34
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
35
21
|
version: 0.5.0
|
36
22
|
type: :runtime
|
37
|
-
version_requirements: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: bacon
|
40
23
|
prerelease: false
|
41
|
-
|
24
|
+
version_requirements: *70296103138940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bacon
|
27
|
+
requirement: &70296103138400 !ruby/object:Gem::Requirement
|
42
28
|
none: false
|
43
|
-
requirements:
|
29
|
+
requirements:
|
44
30
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
hash: 19
|
47
|
-
segments:
|
48
|
-
- 1
|
49
|
-
- 1
|
50
|
-
- 0
|
31
|
+
- !ruby/object:Gem::Version
|
51
32
|
version: 1.1.0
|
52
33
|
type: :development
|
53
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70296103138400
|
54
36
|
description: Walk the stack in a Pry session
|
55
37
|
email: jrmair@gmail.com
|
56
38
|
executables: []
|
57
|
-
|
58
39
|
extensions: []
|
59
|
-
|
60
40
|
extra_rdoc_files: []
|
61
|
-
|
62
|
-
files:
|
41
|
+
files:
|
63
42
|
- lib/pry-stack_explorer/version.rb
|
64
43
|
- lib/pry-stack_explorer.rb
|
65
44
|
- test/test.rb
|
@@ -68,38 +47,26 @@ files:
|
|
68
47
|
- Rakefile
|
69
48
|
homepage: https://github.com/banister
|
70
49
|
licenses: []
|
71
|
-
|
72
50
|
post_install_message:
|
73
51
|
rdoc_options: []
|
74
|
-
|
75
|
-
require_paths:
|
52
|
+
require_paths:
|
76
53
|
- lib
|
77
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
55
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
|
84
|
-
- 0
|
85
|
-
version: "0"
|
86
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
61
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
hash: 25
|
92
|
-
segments:
|
93
|
-
- 1
|
94
|
-
- 3
|
95
|
-
- 1
|
62
|
+
requirements:
|
63
|
+
- - ! '>'
|
64
|
+
- !ruby/object:Gem::Version
|
96
65
|
version: 1.3.1
|
97
66
|
requirements: []
|
98
|
-
|
99
67
|
rubyforge_project:
|
100
68
|
rubygems_version: 1.8.10
|
101
69
|
signing_key:
|
102
70
|
specification_version: 3
|
103
71
|
summary: Walk the stack in a Pry session
|
104
72
|
test_files: []
|
105
|
-
|