pry-stack_explorer 0.4.8pre1 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/lib/pry-stack_explorer.rb +2 -2
- data/lib/pry-stack_explorer/version.rb +1 -1
- data/lib/pry-stack_explorer/when_started_hook.rb +53 -24
- data/pry-stack_explorer.gemspec +7 -4
- metadata +22 -6
data/Rakefile
CHANGED
@@ -23,9 +23,10 @@ def apply_spec_defaults(s)
|
|
23
23
|
s.description = s.summary
|
24
24
|
s.require_path = 'lib'
|
25
25
|
s.add_dependency("binding_of_caller","~>0.6.8")
|
26
|
+
s.add_dependency("pry","~>0.9.11")
|
26
27
|
s.add_development_dependency("bacon","~>1.1.0")
|
27
28
|
s.add_development_dependency('rake', '~> 0.9')
|
28
|
-
s.homepage = "https://github.com/
|
29
|
+
s.homepage = "https://github.com/pry/pry-stack_explorer"
|
29
30
|
s.files = `git ls-files`.split("\n")
|
30
31
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
31
32
|
end
|
@@ -94,7 +95,7 @@ task :rmgems => ["ruby:clobber_package"]
|
|
94
95
|
desc "reinstall gem"
|
95
96
|
task :reinstall => :gems do
|
96
97
|
sh "gem uninstall pry-stack_explorer" rescue nil
|
97
|
-
sh "gem install #{direc}/pkg/#{PROJECT_NAME}-#{PryStackExplorer::VERSION}.gem"
|
98
|
+
sh "gem install -l #{direc}/pkg/#{PROJECT_NAME}-#{PryStackExplorer::VERSION}.gem"
|
98
99
|
end
|
99
100
|
|
100
101
|
task :install => :reinstall
|
data/lib/pry-stack_explorer.rb
CHANGED
@@ -108,8 +108,8 @@ module PryStackExplorer
|
|
108
108
|
def bindings_equal?(b1, b2)
|
109
109
|
(b1.eval('self').equal?(b2.eval('self'))) &&
|
110
110
|
(b1.eval('__method__') == b2.eval('__method__')) &&
|
111
|
-
(b1.eval('local_variables').map { |v| b1.eval("#{v}") }
|
112
|
-
b2.eval('local_variables').map { |v| b2.eval("#{v}") })
|
111
|
+
(b1.eval('local_variables').map { |v| b1.eval("#{v}") }.equal?(
|
112
|
+
b2.eval('local_variables').map { |v| b2.eval("#{v}") }))
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -5,33 +5,13 @@ module PryStackExplorer
|
|
5
5
|
def caller_bindings(target)
|
6
6
|
bindings = binding.callers
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
safe_send(b.eval("__method__"), :==, :start)
|
12
|
-
end
|
13
|
-
|
14
|
-
start_frame_index = start_frames.first.last
|
15
|
-
|
16
|
-
if start_frames.size >= 2
|
17
|
-
idx1, idx2 = start_frames.take(2).map(&:last)
|
18
|
-
|
19
|
-
is_nested_session = bindings[idx1..idx2].detect do |b|
|
20
|
-
safe_send(b.eval("__method__"), :==, :re) &&
|
21
|
-
safe_send(b.eval("self.class"), :equal?, Pry)
|
22
|
-
end
|
23
|
-
|
24
|
-
start_frame_index = idx2 if !is_nested_session
|
25
|
-
end
|
26
|
-
|
27
|
-
bindings = bindings.drop(start_frame_index + 1)
|
28
|
-
bindings = bindings.drop_while { |b| b.eval("__FILE__") =~ /pry-(?:nav|debugger)/ }
|
29
|
-
bindings = bindings.drop(1) if safe_send(bindings.first.eval("__method__"), :==, :pry)
|
8
|
+
bindings = remove_internal_frames(bindings)
|
9
|
+
bindings = remove_debugger_frames(bindings)
|
10
|
+
bindings = bindings.drop(1) if pry_method_frame?(bindings.first)
|
30
11
|
|
31
12
|
# Use the binding returned by #of_caller if possible (as we get
|
32
13
|
# access to frame_type).
|
33
14
|
# Otherwise stick to the given binding (target).
|
34
|
-
|
35
15
|
if !PryStackExplorer.bindings_equal?(target, bindings.first)
|
36
16
|
bindings.shift
|
37
17
|
bindings.unshift(target)
|
@@ -51,7 +31,7 @@ module PryStackExplorer
|
|
51
31
|
if options[:call_stack].is_a?(Array)
|
52
32
|
bindings = options[:call_stack]
|
53
33
|
|
54
|
-
if
|
34
|
+
if !valid_call_stack?(bindings)
|
55
35
|
raise ArgumentError, ":call_stack must be an array of bindings"
|
56
36
|
end
|
57
37
|
else
|
@@ -60,5 +40,54 @@ module PryStackExplorer
|
|
60
40
|
|
61
41
|
PryStackExplorer.create_and_push_frame_manager bindings, _pry_, :initial_frame => options[:initial_frame]
|
62
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# remove internal frames related to setting up the session
|
47
|
+
def remove_internal_frames(bindings)
|
48
|
+
start_frames = internal_frames_with_indices(bindings)
|
49
|
+
start_frame_index = start_frames.first.last
|
50
|
+
|
51
|
+
if start_frames.size >= 2
|
52
|
+
# god knows what's going on in here
|
53
|
+
idx1, idx2 = start_frames.take(2).map(&:last)
|
54
|
+
start_frame_index = idx2 if !nested_session?(bindings[idx1..idx2])
|
55
|
+
end
|
56
|
+
|
57
|
+
bindings.drop(start_frame_index + 1)
|
58
|
+
end
|
59
|
+
|
60
|
+
# remove pry-nav / pry-debugger frames
|
61
|
+
def remove_debugger_frames(bindings)
|
62
|
+
bindings.drop_while { |b| b.eval("__FILE__") =~ /pry-(?:nav|debugger)/ }
|
63
|
+
end
|
64
|
+
|
65
|
+
# binding.pry frame
|
66
|
+
# @return [Boolean]
|
67
|
+
def pry_method_frame?(binding)
|
68
|
+
safe_send(binding.eval("__method__"), :==, :pry)
|
69
|
+
end
|
70
|
+
|
71
|
+
# When a pry session is started within a pry session
|
72
|
+
# @return [Boolean]
|
73
|
+
def nested_session?(bindings)
|
74
|
+
bindings.detect do |b|
|
75
|
+
safe_send(b.eval("__method__"), :==, :re) &&
|
76
|
+
safe_send(b.eval("self.class"), :equal?, Pry)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Array<Array<Binding, Fixnum>>]
|
81
|
+
def internal_frames_with_indices(bindings)
|
82
|
+
bindings.each_with_index.select do |b, i|
|
83
|
+
b.frame_type == :method &&
|
84
|
+
safe_send(b.eval("self"), :equal?, Pry) &&
|
85
|
+
safe_send(b.eval("__method__"), :==, :start)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def valid_call_stack?(bindings)
|
90
|
+
bindings.any? && bindings.all? { |v| v.is_a?(Binding) }
|
91
|
+
end
|
63
92
|
end
|
64
93
|
end
|
data/pry-stack_explorer.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "pry-stack_explorer"
|
5
|
-
s.version = "0.4.
|
5
|
+
s.version = "0.4.8"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
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 = "2013-
|
9
|
+
s.date = "2013-02-07"
|
10
10
|
s.description = "Walk the stack in a Pry session"
|
11
11
|
s.email = "jrmair@gmail.com"
|
12
12
|
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example.rb", "examples/example2.rb", "examples/example3.rb", "lib/pry-stack_explorer.rb", "lib/pry-stack_explorer/commands.rb", "lib/pry-stack_explorer/frame_manager.rb", "lib/pry-stack_explorer/version.rb", "lib/pry-stack_explorer/when_started_hook.rb", "pry-stack_explorer.gemspec", "test/helper.rb", "test/test_commands.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb", "tester.rb"]
|
13
|
-
s.homepage = "https://github.com/
|
13
|
+
s.homepage = "https://github.com/pry/pry-stack_explorer"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.rubygems_version = "1.8.24"
|
16
16
|
s.summary = "Walk the stack in a Pry session"
|
@@ -21,15 +21,18 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
23
|
s.add_runtime_dependency(%q<binding_of_caller>, ["~> 0.6.8"])
|
24
|
+
s.add_runtime_dependency(%q<pry>, ["~> 0.9.11"])
|
24
25
|
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
|
25
26
|
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
26
27
|
else
|
27
28
|
s.add_dependency(%q<binding_of_caller>, ["~> 0.6.8"])
|
29
|
+
s.add_dependency(%q<pry>, ["~> 0.9.11"])
|
28
30
|
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
29
31
|
s.add_dependency(%q<rake>, ["~> 0.9"])
|
30
32
|
end
|
31
33
|
else
|
32
34
|
s.add_dependency(%q<binding_of_caller>, ["~> 0.6.8"])
|
35
|
+
s.add_dependency(%q<pry>, ["~> 0.9.11"])
|
33
36
|
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
34
37
|
s.add_dependency(%q<rake>, ["~> 0.9"])
|
35
38
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-stack_explorer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.8
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Mair (banisterfiend)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: binding_of_caller
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.6.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pry
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.9.11
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.9.11
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: bacon
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,7 +104,7 @@ files:
|
|
88
104
|
- test/test_frame_manager.rb
|
89
105
|
- test/test_stack_explorer.rb
|
90
106
|
- tester.rb
|
91
|
-
homepage: https://github.com/
|
107
|
+
homepage: https://github.com/pry/pry-stack_explorer
|
92
108
|
licenses: []
|
93
109
|
post_install_message:
|
94
110
|
rdoc_options: []
|
@@ -103,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
120
|
none: false
|
105
121
|
requirements:
|
106
|
-
- - ! '
|
122
|
+
- - ! '>='
|
107
123
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
124
|
+
version: '0'
|
109
125
|
requirements: []
|
110
126
|
rubyforge_project:
|
111
127
|
rubygems_version: 1.8.24
|