pry-stack_explorer 0.2.8pre4 → 0.2.8pre5

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,7 @@
1
+ Makefile
2
+ *.so
3
+ *.o
4
+ *.def
5
+ doc/
6
+ pkg/
7
+ .yardoc/
@@ -0,0 +1,15 @@
1
+ script:
2
+ rake test --trace
3
+
4
+ rvm:
5
+ - 1.9.2
6
+ - 1.9.3
7
+
8
+ notifications:
9
+ irc: "irc.freenode.org#pry"
10
+ recipients:
11
+ - jrmair@gmail.com
12
+
13
+ branches:
14
+ only:
15
+ - master
@@ -0,0 +1 @@
1
+ --markup markdown
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2011 John Mair (banisterfiend)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -23,9 +23,12 @@ 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.1")
26
+ # s.add_dependency("pry","0.9.8.0pre1")
26
27
  s.add_development_dependency("bacon","~>1.1.0")
28
+ s.add_development_dependency('rake', '~> 0.9')
27
29
  s.homepage = "https://github.com/banister"
28
- s.files = Dir["lib/**/*.rb", "test/*.rb", "CHANGELOG", "README.md", "Rakefile"]
30
+ s.files = `git ls-files`.split("\n")
31
+ s.test_files = `git ls-files -- test/*`.split("\n")
29
32
  end
30
33
 
31
34
  desc "run pry with plugin enabled"
@@ -43,9 +46,12 @@ task :version do
43
46
  puts "PryStackExplorer version: #{PryStackExplorer::VERSION}"
44
47
  end
45
48
 
49
+ desc "run tests"
50
+ task :default => :test
51
+
46
52
  desc "run tests"
47
53
  task :test do
48
- sh "bacon -Itest -rubygems -a"
54
+ sh "bacon -Itest -rubygems -a -q"
49
55
  end
50
56
 
51
57
  namespace :ruby do
@@ -0,0 +1,45 @@
1
+ unless Object.const_defined? :PryStackExplorer
2
+ $:.unshift File.expand_path '../../lib', __FILE__
3
+ require 'pry'
4
+ end
5
+
6
+ require 'pry-stack_explorer'
7
+
8
+ def alphabet(y)
9
+ x = 20
10
+ b
11
+ end
12
+
13
+ def b
14
+ x = 30
15
+ proc {
16
+ c
17
+ }.call
18
+ end
19
+
20
+ def c
21
+ u = 50
22
+ J.pry
23
+ end
24
+
25
+ # hello
26
+ def beta
27
+ gamma
28
+ end
29
+
30
+ def gamma
31
+ zeta
32
+ end
33
+
34
+ def zeta
35
+ vitamin = 100
36
+ binding.pry
37
+ end
38
+ #
39
+
40
+ proc {
41
+ class J
42
+ alphabet(22)
43
+ end
44
+ }.call
45
+
@@ -77,7 +77,7 @@ module PryStackExplorer
77
77
  def frame_info(b, verbose = false)
78
78
  meth = b.eval('__method__')
79
79
  b_self = b.eval('self')
80
- meth_obj = Pry::Method.new(b_self.method(meth)) if meth
80
+ meth_obj = Pry::Method.from_binding(b) if meth
81
81
 
82
82
  type = b.frame_type ? "[#{b.frame_type}]" : ""
83
83
  desc = b.frame_description ? "#{b.frame_description} in " : "#{PryStackExplorer.frame_manager(_pry_).frame_info_for(b)} in "
@@ -90,18 +90,22 @@ module PryStackExplorer
90
90
  end
91
91
 
92
92
  def se_signature_with_owner(meth_obj)
93
- args = meth_obj.parameters.inject([]) do |arr, (type, name)|
94
- name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
95
- arr << case type
96
- when :req then name.to_s
97
- when :opt then "#{name}=?"
98
- when :rest then "*#{name}"
99
- when :block then "&#{name}"
100
- else '?'
101
- end
93
+ if !meth_obj.undefined?
94
+ args = meth_obj.parameters.inject([]) do |arr, (type, name)|
95
+ name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
96
+ arr << case type
97
+ when :req then name.to_s
98
+ when :opt then "#{name}=?"
99
+ when :rest then "*#{name}"
100
+ when :block then "&#{name}"
101
+ else '?'
102
+ end
103
+ end
104
+ "#{meth_obj.name_with_owner}(#{args.join(', ')})"
105
+ else
106
+ "#{meth_obj.name_with_owner}(UNKNOWN) (undefined method)"
102
107
  end
103
108
 
104
- "#{meth_obj.name_with_owner}(#{args.join(', ')})"
105
109
  end
106
110
  end
107
111
 
@@ -1,3 +1,3 @@
1
1
  module PryStackExplorer
2
- VERSION = "0.2.8pre4"
2
+ VERSION = "0.2.8pre5"
3
3
  end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "pry-stack_explorer"
5
+ s.version = "0.2.8pre5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["John Mair (banisterfiend)"]
9
+ s.date = "2011-12-21"
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", "LICENSE", "README.md", "Rakefile", "examples/example.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", "pry-stack_explorer.gemspec", "test/helper.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
+ s.rubygems_version = "1.8.10"
16
+ s.summary = "Walk the stack in a Pry session"
17
+ s.test_files = ["test/helper.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb"]
18
+
19
+ if s.respond_to? :specification_version then
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
+ s.add_runtime_dependency(%q<binding_of_caller>, ["~> 0.6.1"])
24
+ s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
25
+ s.add_development_dependency(%q<rake>, ["~> 0.9"])
26
+ else
27
+ s.add_dependency(%q<binding_of_caller>, ["~> 0.6.1"])
28
+ s.add_dependency(%q<bacon>, ["~> 1.1.0"])
29
+ s.add_dependency(%q<rake>, ["~> 0.9"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<binding_of_caller>, ["~> 0.6.1"])
33
+ s.add_dependency(%q<bacon>, ["~> 1.1.0"])
34
+ s.add_dependency(%q<rake>, ["~> 0.9"])
35
+ end
36
+ end
@@ -0,0 +1,65 @@
1
+ require 'helper'
2
+
3
+ Pry.config.output = StringIO.new
4
+
5
+ describe PryStackExplorer::FrameManager do
6
+
7
+ before do
8
+ @pry_instance = Pry.new
9
+ @bindings = [binding, binding, binding, binding]
10
+ @bindings.each_with_index { |v, i| v.eval("x = #{i}") }
11
+ @pry_instance.binding_stack.push @bindings.last
12
+ @frame_manager = PE::FrameManager.new(@bindings, @pry_instance)
13
+ end
14
+
15
+ describe "creation" do
16
+ it "should make bindings accessible via 'bindings' method" do
17
+ @frame_manager.bindings.should == @bindings
18
+ end
19
+
20
+ it "should set binding_index to 0" do
21
+ @frame_manager.binding_index.should == 0
22
+ end
23
+
24
+ it "should set current_frame to first frame" do
25
+ @frame_manager.current_frame.should == @bindings.first
26
+ end
27
+ end
28
+
29
+ describe "FrameManager#change_frame_to" do
30
+ it 'should change the frame to the given one' do
31
+ @frame_manager.change_frame_to(1)
32
+
33
+ @frame_manager.binding_index.should == 1
34
+ @frame_manager.current_frame.should == @bindings[1]
35
+ @pry_instance.binding_stack.last.should == @frame_manager.current_frame
36
+ end
37
+
38
+ it 'should accept negative indices when specifying frame' do
39
+ @frame_manager.change_frame_to(-1)
40
+
41
+ # negative index is converted to a positive one inside change_frame_to
42
+ @frame_manager.binding_index.should == @bindings.size - 1
43
+
44
+ @frame_manager.current_frame.should == @bindings[-1]
45
+ @pry_instance.binding_stack.last.should == @frame_manager.current_frame
46
+ end
47
+ end
48
+
49
+ describe "FrameManager#refresh_frame" do
50
+ it 'should change the Pry frame to the active one in the FrameManager' do
51
+ @frame_manager.binding_index = 2
52
+ @frame_manager.refresh_frame
53
+
54
+ @pry_instance.binding_stack.last.should == @frame_manager.current_frame
55
+ end
56
+ end
57
+
58
+ describe "FrameManager is Enumerable" do
59
+ it 'should perform an Enumerable#map on the frames' do
60
+ @frame_manager.map { |v| v.eval("x") }.should == (0..(@bindings.size - 1)).to_a
61
+ end
62
+ end
63
+
64
+ end
65
+
@@ -11,29 +11,95 @@ describe PryStackExplorer do
11
11
  PE.clear_frame_managers(@pry_instance)
12
12
  end
13
13
 
14
- it "should create and push one new FrameManager" do
15
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
16
- PE.frame_manager(@pry_instance).is_a?(PE::FrameManager).should == true
17
- PE.all_frame_managers(@pry_instance).count.should == 1
14
+ describe "PryStackExplorer.create_and_push_frame_manager" do
15
+ it "should create and push one new FrameManager" do
16
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
17
+ PE.frame_manager(@pry_instance).is_a?(PE::FrameManager).should == true
18
+ PE.all_frame_managers(@pry_instance).count.should == 1
19
+ end
20
+
21
+ it "should create and push multiple FrameManagers" do
22
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
23
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
24
+ PE.all_frame_managers(@pry_instance).count.should == 2
25
+ end
26
+
27
+ it 'should push FrameManagers to stacks based on Pry instance' do
28
+ p2 = Pry.new
29
+ bindings = [binding, binding]
30
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
31
+ PE.create_and_push_frame_manager(bindings, p2)
32
+ PE.all_frame_managers(@pry_instance).count.should == 1
33
+ PE.all_frame_managers(p2).count.should == 1
34
+ end
18
35
  end
19
36
 
20
- it "should have the correct bindings" do
21
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
22
- PE.frame_manager(@pry_instance).bindings.should == @bindings
37
+ describe "PryStackExplorer.frame_manager" do
38
+ it "should have the correct bindings" do
39
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
40
+ PE.frame_manager(@pry_instance).bindings.should == @bindings
41
+ end
42
+
43
+ it "should return the last pushed FrameManager" do
44
+ bindings = [binding, binding]
45
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
46
+ PE.create_and_push_frame_manager(bindings, @pry_instance)
47
+ PE.frame_manager(@pry_instance).bindings.should == bindings
48
+ end
49
+
50
+ it "should return the correct FrameManager for the given Pry instance" do
51
+ bindings = [binding, binding]
52
+ p2 = Pry.new
53
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
54
+ PE.create_and_push_frame_manager(bindings, p2)
55
+ PE.frame_manager(@pry_instance).bindings.should == @bindings
56
+ PE.frame_manager(p2).bindings.should == bindings
57
+ end
23
58
  end
24
59
 
25
- it "should pop a FrameManager" do
26
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
27
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
28
- PE.pop_frame_manager(@pry_instance)
29
- PE.all_frame_managers(@pry_instance).count.should == 1
60
+ describe "PryStackExplorer.pop_frame_manager" do
61
+ it "should remove FrameManager from stack" do
62
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
63
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
64
+ PE.pop_frame_manager(@pry_instance)
65
+ PE.all_frame_managers(@pry_instance).count.should == 1
66
+ end
67
+
68
+ it "should return the most recently added FrameManager" do
69
+ bindings = [binding, binding]
70
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
71
+ PE.create_and_push_frame_manager(bindings, @pry_instance)
72
+ PE.pop_frame_manager(@pry_instance).bindings.should == bindings
73
+ end
74
+
75
+ it "should remove FrameManager from the appropriate stack based on Pry instance" do
76
+ p2 = Pry.new
77
+ bindings = [binding, binding]
78
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
79
+ PE.create_and_push_frame_manager(bindings, p2)
80
+ PE.pop_frame_manager(@pry_instance)
81
+ PE.all_frame_managers(@pry_instance).count.should == 0
82
+ PE.all_frame_managers(p2).count.should == 1
83
+ end
30
84
  end
31
85
 
32
- it "should clear all FrameManagers for a Pry instance" do
33
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
34
- PE.create_and_push_frame_manager(@bindings, @pry_instance)
35
- PE.clear_frame_managers(@pry_instance)
36
- PE.all_frame_managers(@pry_instance).count.should == 0
86
+ describe "PryStackExplorer.clear_frame_managers" do
87
+ it "should clear all FrameManagers for a Pry instance" do
88
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
89
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
90
+ PE.clear_frame_managers(@pry_instance)
91
+ PE.all_frame_managers(@pry_instance).count.should == 0
92
+ end
93
+
94
+ it "should clear all FrameManagers for a Pry instance" do
95
+ p2 = Pry.new
96
+ bindings = [binding, binding]
97
+ PE.create_and_push_frame_manager(@bindings, @pry_instance)
98
+ PE.create_and_push_frame_manager(bindings, p2)
99
+ PE.clear_frame_managers(@pry_instance)
100
+ PE.all_frame_managers(p2).count.should == 1
101
+ PE.all_frame_managers(@pry_instance).count.should == 0
102
+ end
37
103
  end
38
104
  end
39
105
 
@@ -0,0 +1,27 @@
1
+ def a
2
+ x = 20
3
+ b
4
+ end
5
+
6
+ def b
7
+ x = 30
8
+ c
9
+ end
10
+
11
+ def c
12
+ u = 50
13
+ binding.pry
14
+ puts "hi"
15
+ puts "bye"
16
+ v = 20
17
+ puts v
18
+ k
19
+ end
20
+
21
+ def k
22
+ puts "lovely girl"
23
+ james = "hello"
24
+ puts james
25
+ end
26
+
27
+ a
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.8pre4
4
+ version: 0.2.8pre5
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-20 00:00:00.000000000 Z
12
+ date: 2011-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: binding_of_caller
16
- requirement: &70241510740720 !ruby/object:Gem::Requirement
16
+ requirement: &70302726218440 !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: *70241510740720
24
+ version_requirements: *70302726218440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bacon
27
- requirement: &70241510738600 !ruby/object:Gem::Requirement
27
+ requirement: &70302726217820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,22 +32,42 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70241510738600
35
+ version_requirements: *70302726217820
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70302726217160 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70302726217160
36
47
  description: Walk the stack in a Pry session
37
48
  email: jrmair@gmail.com
38
49
  executables: []
39
50
  extensions: []
40
51
  extra_rdoc_files: []
41
52
  files:
53
+ - .gemtest
54
+ - .gitignore
55
+ - .travis.yml
56
+ - .yardopts
57
+ - CHANGELOG
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - examples/example.rb
62
+ - lib/pry-stack_explorer.rb
42
63
  - lib/pry-stack_explorer/commands.rb
43
64
  - lib/pry-stack_explorer/frame_manager.rb
44
65
  - lib/pry-stack_explorer/version.rb
45
- - lib/pry-stack_explorer.rb
66
+ - pry-stack_explorer.gemspec
46
67
  - test/helper.rb
68
+ - test/test_frame_manager.rb
47
69
  - test/test_stack_explorer.rb
48
- - CHANGELOG
49
- - README.md
50
- - Rakefile
70
+ - tester.rb
51
71
  homepage: https://github.com/banister
52
72
  licenses: []
53
73
  post_install_message:
@@ -72,4 +92,7 @@ rubygems_version: 1.8.10
72
92
  signing_key:
73
93
  specification_version: 3
74
94
  summary: Walk the stack in a Pry session
75
- test_files: []
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/test_frame_manager.rb
98
+ - test/test_stack_explorer.rb