pry-stack_explorer 0.2.9pre2 → 0.2.9pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@
4
4
  require "pry-stack_explorer/version"
5
5
  require "pry-stack_explorer/commands"
6
6
  require "pry-stack_explorer/frame_manager"
7
+ require "pry-stack_explorer/when_started_hook"
7
8
  require "pry"
8
9
  require "binding_of_caller"
9
10
 
@@ -78,40 +79,7 @@ Pry.config.hooks.add_hook(:after_session, :delete_frame_manager) do |_, _, _pry_
78
79
  PryStackExplorer.clear_frame_managers(_pry_)
79
80
  end
80
81
 
81
- Pry.config.hooks.add_hook(:when_started, :save_caller_bindings) do |binding_stack, options, _pry_|
82
- options[:call_stack] = true unless options.has_key?(:call_stack)
83
- options[:initial_frame] = 0 unless options.has_key?(:initial_frame)
84
- initial_frame = options[:initial_frame]
85
-
86
- next if !options[:call_stack]
87
-
88
- if options[:call_stack].is_a?(Array)
89
- bindings = options[:call_stack]
90
- raise ArgumentError, ":call_stack must be an array of bindings" if bindings.empty? || !bindings.all? { |v| v.is_a?(Binding) }
91
- else
92
- target = binding_stack.last
93
-
94
- if binding.of_caller(6).eval('__method__') == :pry
95
- drop_number = 7
96
- else
97
- drop_number = 6
98
- end
99
-
100
- bindings = binding.callers.drop(drop_number)
101
-
102
- # Use the binding returned by #of_caller if possible (as we get
103
- # access to frame_type).
104
- # Otherwise stick to the given binding (target).
105
- if !PryStackExplorer.bindings_equal?(target, bindings.first)
106
- bindings.shift
107
- bindings.unshift(target)
108
- end
109
- end
110
-
111
- binding_stack.replace [bindings[initial_frame]]
112
- PryStackExplorer.create_and_push_frame_manager(bindings, _pry_)
113
- PryStackExplorer.frame_manager(_pry_).set_binding_index_safely(initial_frame)
114
- end
82
+ Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, PryStackExplorer::WhenStartedHook.new)
115
83
 
116
84
  # Import the StackExplorer commands
117
85
  Pry.config.commands.import PryStackExplorer::Commands
@@ -1,3 +1,3 @@
1
1
  module PryStackExplorer
2
- VERSION = "0.2.9pre2"
2
+ VERSION = "0.2.9pre3"
3
3
  end
@@ -0,0 +1,45 @@
1
+ module PryStackExplorer
2
+ class WhenStartedHook
3
+
4
+ def caller_bindings(binding_stack)
5
+ target = binding_stack.last
6
+
7
+ if binding.of_caller(6).eval('__method__') == :pry
8
+ drop_number = 8
9
+ else
10
+ drop_number = 7
11
+ end
12
+
13
+ bindings = binding.callers.drop(drop_number)
14
+
15
+ # Use the binding returned by #of_caller if possible (as we get
16
+ # access to frame_type).
17
+ # Otherwise stick to the given binding (target).
18
+ if !PryStackExplorer.bindings_equal?(target, bindings.first)
19
+ bindings.shift
20
+ bindings.unshift(target)
21
+ end
22
+
23
+ bindings
24
+ end
25
+
26
+ def call(binding_stack, options, _pry_)
27
+ options[:call_stack] = true unless options.has_key?(:call_stack)
28
+ options[:initial_frame] = 0 unless options.has_key?(:initial_frame)
29
+ initial_frame = options[:initial_frame]
30
+
31
+ return if !options[:call_stack]
32
+
33
+ if options[:call_stack].is_a?(Array)
34
+ bindings = options[:call_stack]
35
+ raise ArgumentError, ":call_stack must be an array of bindings" if bindings.empty? || !bindings.all? { |v| v.is_a?(Binding) }
36
+ else
37
+ bindings = caller_bindings(binding_stack)
38
+ end
39
+
40
+ binding_stack.replace [bindings[initial_frame]]
41
+ PryStackExplorer.create_and_push_frame_manager(bindings, _pry_)
42
+ PryStackExplorer.frame_manager(_pry_).set_binding_index_safely(initial_frame)
43
+ end
44
+ end
45
+ end
@@ -1,21 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{pry-stack_explorer}
5
- s.version = "0.2.9pre2"
4
+ s.name = "pry-stack_explorer"
5
+ s.version = "0.2.9pre3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
- s.authors = [%q{John Mair (banisterfiend)}]
9
- s.date = %q{2012-01-14}
10
- s.description = %q{Walk the stack in a Pry session}
11
- s.email = %q{jrmair@gmail.com}
12
- s.files = [%q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{Gemfile}, %q{LICENSE}, %q{README.md}, %q{Rakefile}, %q{examples/example.rb}, %q{examples/example2.rb}, %q{lib/pry-stack_explorer.rb}, %q{lib/pry-stack_explorer/commands.rb}, %q{lib/pry-stack_explorer/frame_manager.rb}, %q{lib/pry-stack_explorer/version.rb}, %q{pry-stack_explorer.gemspec}, %q{test/helper.rb}, %q{test/test_commands.rb}, %q{test/test_frame_manager.rb}, %q{test/test_stack_explorer.rb}, %q{tester.rb}]
13
- s.homepage = %q{https://github.com/banister}
14
- s.require_paths = [%q{lib}]
8
+ s.authors = ["John Mair (banisterfiend)"]
9
+ s.date = "2012-01-14"
10
+ s.description = "Walk the stack in a Pry session"
11
+ s.email = "jrmair@gmail.com"
12
+ s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example.rb", "examples/example2.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/banister"
14
+ s.require_paths = ["lib"]
15
15
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
16
- s.rubygems_version = %q{1.8.6}
17
- s.summary = %q{Walk the stack in a Pry session}
18
- s.test_files = [%q{test/helper.rb}, %q{test/test_commands.rb}, %q{test/test_frame_manager.rb}, %q{test/test_stack_explorer.rb}]
16
+ s.rubygems_version = "1.8.11"
17
+ s.summary = "Walk the stack in a Pry session"
18
+ s.test_files = ["test/helper.rb", "test/test_commands.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb"]
19
19
 
20
20
  if s.respond_to? :specification_version then
21
21
  s.specification_version = 3
@@ -29,8 +29,8 @@ class << Pry
29
29
  end
30
30
  end
31
31
 
32
- AfterSessionHook = Pry.config.hooks.get_hook(:after_session, :delete_frame_manager)
33
- WhenStartedHook = Pry.config.hooks.get_hook(:when_started, :save_caller_bindings)
32
+ AfterSessionHook = Pry.config.hooks.get_hook(:after_session, :delete_frame_manager)
33
+ WhenStartedHook = Pry.config.hooks.get_hook(:when_started, :save_caller_bindings)
34
34
 
35
35
  Pry.reset_defaults
36
36
 
@@ -3,8 +3,8 @@ require 'helper'
3
3
  describe PryStackExplorer::Commands do
4
4
 
5
5
  before do
6
- Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, &WhenStartedHook)
7
- Pry.config.hooks.add_hook(:after_session, :delete_frame_manager, &AfterSessionHook)
6
+ Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, WhenStartedHook)
7
+ Pry.config.hooks.add_hook(:after_session, :delete_frame_manager, AfterSessionHook)
8
8
 
9
9
  @o = Object.new
10
10
  class << @o; attr_accessor :first_method, :second_method, :third_method; end
@@ -4,8 +4,8 @@ describe PryStackExplorer do
4
4
 
5
5
  describe "Pry.start" do
6
6
  before do
7
- Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, &WhenStartedHook)
8
- Pry.config.hooks.add_hook(:after_session, :delete_frame_manager, &AfterSessionHook)
7
+ Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, WhenStartedHook)
8
+ Pry.config.hooks.add_hook(:after_session, :delete_frame_manager, AfterSessionHook)
9
9
 
10
10
  @o = Object.new
11
11
  class << @o; attr_reader :frame; end
metadata CHANGED
@@ -1,66 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pry-stack_explorer
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.9pre2
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease: 5
5
+ version: 0.2.9pre3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-14 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2012-01-14 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: binding_of_caller
16
- requirement: &70272934305720 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
20
+ requirements:
19
21
  - - ~>
20
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
21
23
  version: 0.6.1
22
24
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70272934305720
25
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
26
27
  name: pry
27
- requirement: &70272934305080 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
28
30
  none: false
29
- requirements:
30
- - - =
31
- - !ruby/object:Gem::Version
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
32
34
  version: 0.9.8pre4
33
35
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70272934305080
36
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
37
38
  name: bacon
38
- requirement: &70272934304360 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
39
41
  none: false
40
- requirements:
42
+ requirements:
41
43
  - - ~>
42
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
43
45
  version: 1.1.0
44
46
  type: :development
45
- prerelease: false
46
- version_requirements: *70272934304360
47
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
48
49
  name: rake
49
- requirement: &70272934303560 !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
50
52
  none: false
51
- requirements:
53
+ requirements:
52
54
  - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '0.9'
55
+ - !ruby/object:Gem::Version
56
+ version: "0.9"
55
57
  type: :development
56
- prerelease: false
57
- version_requirements: *70272934303560
58
+ version_requirements: *id004
58
59
  description: Walk the stack in a Pry session
59
60
  email: jrmair@gmail.com
60
61
  executables: []
62
+
61
63
  extensions: []
64
+
62
65
  extra_rdoc_files: []
63
- files:
66
+
67
+ files:
64
68
  - .gemtest
65
69
  - .gitignore
66
70
  - .travis.yml
@@ -76,6 +80,7 @@ files:
76
80
  - lib/pry-stack_explorer/commands.rb
77
81
  - lib/pry-stack_explorer/frame_manager.rb
78
82
  - lib/pry-stack_explorer/version.rb
83
+ - lib/pry-stack_explorer/when_started_hook.rb
79
84
  - pry-stack_explorer.gemspec
80
85
  - test/helper.rb
81
86
  - test/test_commands.rb
@@ -84,29 +89,32 @@ files:
84
89
  - tester.rb
85
90
  homepage: https://github.com/banister
86
91
  licenses: []
92
+
87
93
  post_install_message:
88
94
  rdoc_options: []
89
- require_paths:
95
+
96
+ require_paths:
90
97
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
98
+ required_ruby_version: !ruby/object:Gem::Requirement
92
99
  none: false
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
96
103
  version: 1.9.2
97
- required_rubygems_version: !ruby/object:Gem::Requirement
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
105
  none: false
99
- requirements:
100
- - - ! '>'
101
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ">"
108
+ - !ruby/object:Gem::Version
102
109
  version: 1.3.1
103
110
  requirements: []
111
+
104
112
  rubyforge_project:
105
- rubygems_version: 1.8.6
113
+ rubygems_version: 1.8.11
106
114
  signing_key:
107
115
  specification_version: 3
108
116
  summary: Walk the stack in a Pry session
109
- test_files:
117
+ test_files:
110
118
  - test/helper.rb
111
119
  - test/test_commands.rb
112
120
  - test/test_frame_manager.rb