binding_of_caller 0.2.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.gitignore +8 -0
- data/.travis.yml +23 -0
- data/.yardopts +1 -0
- data/Gemfile +2 -0
- data/LICENSE +25 -0
- data/README.md +42 -10
- data/Rakefile +134 -99
- data/binding_of_caller.gemspec +37 -0
- data/examples/example.rb +41 -0
- data/ext/binding_of_caller/binding_of_caller.c +138 -37
- data/ext/binding_of_caller/extconf.rb +29 -10
- data/ext/binding_of_caller/ruby_headers/192/version.h +0 -8
- data/lib/binding_of_caller/mri2.rb +69 -0
- data/lib/binding_of_caller/rubinius.rb +74 -0
- data/lib/binding_of_caller/version.rb +3 -3
- data/lib/binding_of_caller.rb +11 -19
- data/test/test_binding_of_caller.rb +161 -0
- metadata +86 -52
- data/ext/binding_of_caller/compat.h +0 -57
- data/test/test.rb +0 -12
- /data/ext/binding_of_caller/ruby_headers/192/{gc.h → rubys_gc.h} +0 -0
- /data/ext/binding_of_caller/ruby_headers/193/{gc.h → rubys_gc.h} +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f3fb3c7ee20b9b9ca1237d0540c2768efc657111
|
|
4
|
+
data.tar.gz: be4845aeca79432000b44be789993c23c1955715
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3fd5d2a9ffbda43fcc2d8afa739ec51052f5dacc8632c3e88b60b7be90c2bd67c8a813156dab341e9f3399e46db667f3a1246043d50f1f60b6654d5c07e4e93c
|
|
7
|
+
data.tar.gz: 13fe3b6ab87052403c99be357fb91ea3ed2c9e9e5a8bafadc3123293bbb0a47bd7a235c67f7d25adb020f07bef0dee6d5a00424c7f59bf4c8b59dfc1f691d5c8
|
data/.gemtest
ADDED
|
File without changes
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
rvm:
|
|
2
|
+
- 1.9.2
|
|
3
|
+
- 1.9.3
|
|
4
|
+
- 2.0.0
|
|
5
|
+
- rbx-19mode
|
|
6
|
+
|
|
7
|
+
notifications:
|
|
8
|
+
irc: "irc.freenode.org#pry"
|
|
9
|
+
recipients:
|
|
10
|
+
- jrmair@gmail.com
|
|
11
|
+
|
|
12
|
+
branches:
|
|
13
|
+
only:
|
|
14
|
+
- master
|
|
15
|
+
|
|
16
|
+
#script: rake test --trace
|
|
17
|
+
#
|
|
18
|
+
#before_install:
|
|
19
|
+
# - gem update --system
|
|
20
|
+
# - gem --version
|
|
21
|
+
# - gem install rake bacon
|
|
22
|
+
# - rake gem
|
|
23
|
+
# - gem install pkg/*.gem
|
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--markup markdown
|
data/Gemfile
ADDED
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/README.md
CHANGED
|
@@ -1,27 +1,59 @@
|
|
|
1
|
+
[](http://travis-ci.org/banister/binding_of_caller)
|
|
2
|
+
|
|
1
3
|
binding_of_caller
|
|
2
4
|
===========
|
|
3
5
|
|
|
4
|
-
(C) John Mair (banisterfiend)
|
|
6
|
+
(C) John Mair (banisterfiend) 2012
|
|
7
|
+
|
|
8
|
+
_Retrieve the binding of a method's caller in MRI 1.9.2+, MRI 2.0 and RBX (Rubinius)_
|
|
9
|
+
|
|
10
|
+
The `binding_of_caller` gem provides the `Binding#of_caller` method.
|
|
5
11
|
|
|
6
|
-
|
|
12
|
+
Using `binding_of_caller` we can grab bindings from higher up the call
|
|
13
|
+
stack and evaluate code in that context. Allows access to bindings arbitrarily far up the
|
|
14
|
+
call stack, not limited to just the immediate caller.
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
**Recommended for use only in debugging situations. Do not use this in production apps.**
|
|
17
|
+
|
|
18
|
+
**Only works in MRI Ruby 1.9.2, 1.9.3, 2.0 and RBX (Rubinius)**
|
|
9
19
|
|
|
10
20
|
* Install the [gem](https://rubygems.org/gems/binding_of_caller): `gem install binding_of_caller`
|
|
11
|
-
* Read the [documentation](http://rdoc.info/github/banister/binding_of_caller/master/file/README.markdown)
|
|
12
21
|
* See the [source code](http://github.com/banister/binding_of_caller)
|
|
13
22
|
|
|
14
|
-
Example:
|
|
23
|
+
Example: Modifying a local inside the caller of a caller
|
|
15
24
|
--------
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
```ruby
|
|
27
|
+
def a
|
|
28
|
+
var = 10
|
|
29
|
+
b
|
|
30
|
+
puts var
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def b
|
|
34
|
+
c
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def c
|
|
38
|
+
binding.of_caller(2).eval('var = :hello')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
a()
|
|
42
|
+
|
|
43
|
+
# OUTPUT
|
|
44
|
+
# => hello
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Spinoff project
|
|
48
|
+
-------
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
This project is a spinoff from the [Pry REPL project.](http://pry.github.com)
|
|
20
51
|
|
|
21
52
|
Features and limitations
|
|
22
53
|
-------------------------
|
|
23
54
|
|
|
24
|
-
|
|
55
|
+
* Only works with MRI 1.9.2, 1.9.3, 2.0 and RBX (Rubinius)
|
|
56
|
+
* Does not work in 1.8.7, but there is a well known (continuation-based) hack to get a `Binding#of_caller` there.
|
|
25
57
|
|
|
26
58
|
Contact
|
|
27
59
|
-------
|
|
@@ -32,9 +64,9 @@ Problems or questions contact me at [github](http://github.com/banister)
|
|
|
32
64
|
License
|
|
33
65
|
-------
|
|
34
66
|
|
|
35
|
-
(The MIT License)
|
|
67
|
+
(The MIT License)
|
|
36
68
|
|
|
37
|
-
Copyright (c)
|
|
69
|
+
Copyright (c) 2012 (John Mair)
|
|
38
70
|
|
|
39
71
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
40
72
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
|
@@ -1,99 +1,134 @@
|
|
|
1
|
-
dlext =
|
|
2
|
-
direc = File.dirname(__FILE__)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require 'rake/clean'
|
|
7
|
-
require '
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"ext
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
s.
|
|
23
|
-
s.
|
|
24
|
-
s.
|
|
25
|
-
s.
|
|
26
|
-
s.
|
|
27
|
-
s.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
desc "
|
|
68
|
-
task :
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
sh "
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
1
|
+
dlext = RbConfig::CONFIG['DLEXT']
|
|
2
|
+
direc = File.dirname(__FILE__)
|
|
3
|
+
|
|
4
|
+
$:.unshift 'lib'
|
|
5
|
+
|
|
6
|
+
require 'rake/clean'
|
|
7
|
+
require 'rubygems/package_task'
|
|
8
|
+
|
|
9
|
+
require "binding_of_caller/version"
|
|
10
|
+
|
|
11
|
+
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
|
12
|
+
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
|
|
13
|
+
"ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
|
|
14
|
+
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
|
|
15
|
+
|
|
16
|
+
def mri_2?
|
|
17
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
|
|
18
|
+
RUBY_VERSION =~ /^2/
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def apply_spec_defaults(s)
|
|
22
|
+
s.name = "binding_of_caller"
|
|
23
|
+
s.summary = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack."
|
|
24
|
+
s.version = BindingOfCaller::VERSION
|
|
25
|
+
s.date = Time.now.strftime '%Y-%m-%d'
|
|
26
|
+
s.author = "John Mair (banisterfiend)"
|
|
27
|
+
s.email = 'jrmair@gmail.com'
|
|
28
|
+
s.description = s.summary
|
|
29
|
+
s.require_path = 'lib'
|
|
30
|
+
s.add_dependency 'debug_inspector', '>= 0.0.1'
|
|
31
|
+
s.add_development_dependency 'bacon'
|
|
32
|
+
s.add_development_dependency 'rake'
|
|
33
|
+
s.homepage = "http://github.com/banister/binding_of_caller"
|
|
34
|
+
s.has_rdoc = 'yard'
|
|
35
|
+
s.files = `git ls-files`.split("\n")
|
|
36
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc "Show version"
|
|
40
|
+
task :version do
|
|
41
|
+
puts "BindingOfCaller version: #{BindingOfCaller::VERSION}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "run tests"
|
|
45
|
+
task :default => [:test]
|
|
46
|
+
|
|
47
|
+
desc "Run tests"
|
|
48
|
+
task :test do
|
|
49
|
+
unless defined?(Rubinius)
|
|
50
|
+
Rake::Task['compile'].execute
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
$stdout.puts("\033[33m")
|
|
54
|
+
sh "bacon -Itest -rubygems -a -q"
|
|
55
|
+
$stdout.puts("\033[0m")
|
|
56
|
+
|
|
57
|
+
unless defined?(Rubinius)
|
|
58
|
+
Rake::Task['cleanup'].execute
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
task :pry do
|
|
63
|
+
puts "loading binding_of_caller into pry"
|
|
64
|
+
sh "pry -r ./lib/binding_of_caller"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc "generate gemspec"
|
|
68
|
+
task :gemspec => "ruby:gemspec"
|
|
69
|
+
|
|
70
|
+
namespace :ruby do
|
|
71
|
+
spec = Gem::Specification.new do |s|
|
|
72
|
+
apply_spec_defaults(s)
|
|
73
|
+
s.platform = Gem::Platform::RUBY
|
|
74
|
+
s.extensions = ["ext/binding_of_caller/extconf.rb"]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Gem::PackageTask.new(spec) do |pkg|
|
|
78
|
+
pkg.need_zip = false
|
|
79
|
+
pkg.need_tar = false
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
desc "Generate gemspec file"
|
|
83
|
+
task :gemspec do
|
|
84
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
|
85
|
+
f << spec.to_ruby
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
desc "build the binaries"
|
|
91
|
+
task :compile => :cleanup do
|
|
92
|
+
if !mri_2?
|
|
93
|
+
chdir "./ext/binding_of_caller/" do
|
|
94
|
+
sh "ruby extconf.rb"
|
|
95
|
+
sh "make"
|
|
96
|
+
sh "cp *.#{dlext} ../../lib/"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
desc 'cleanup the extensions'
|
|
102
|
+
task :cleanup do
|
|
103
|
+
if !mri_2?
|
|
104
|
+
sh 'rm -rf lib/binding_of_caller.so'
|
|
105
|
+
chdir "./ext/binding_of_caller/" do
|
|
106
|
+
sh 'make clean'
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
desc "reinstall gem"
|
|
112
|
+
task :reinstall => :gems do
|
|
113
|
+
sh "gem uninstall binding_of_caller" rescue nil
|
|
114
|
+
sh "gem install #{direc}/pkg/binding_of_caller-#{BindingOfCaller::VERSION}.gem"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
task :install => :reinstall
|
|
118
|
+
|
|
119
|
+
desc "build all platform gems at once"
|
|
120
|
+
task :gems => [:clean, :rmgems, "ruby:gem"]
|
|
121
|
+
|
|
122
|
+
task :gem => [:gems]
|
|
123
|
+
|
|
124
|
+
desc "remove all platform gems"
|
|
125
|
+
task :rmgems => ["ruby:clobber_package"]
|
|
126
|
+
|
|
127
|
+
desc "build and push latest gems"
|
|
128
|
+
task :pushgems => :gems do
|
|
129
|
+
chdir("./pkg") do
|
|
130
|
+
Dir["*.gem"].each do |gemfile|
|
|
131
|
+
sh "gem push #{gemfile}"
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = "binding_of_caller"
|
|
5
|
+
s.version = "0.7.2"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["John Mair (banisterfiend)"]
|
|
9
|
+
s.date = "2013-06-07"
|
|
10
|
+
s.description = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack."
|
|
11
|
+
s.email = "jrmair@gmail.com"
|
|
12
|
+
s.extensions = ["ext/binding_of_caller/extconf.rb"]
|
|
13
|
+
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "Gemfile", "HISTORY", "LICENSE", "README.md", "Rakefile", "binding_of_caller.gemspec", "examples/example.rb", "ext/binding_of_caller/binding_of_caller.c", "ext/binding_of_caller/extconf.rb", "ext/binding_of_caller/ruby_headers/192/debug.h", "ext/binding_of_caller/ruby_headers/192/dln.h", "ext/binding_of_caller/ruby_headers/192/eval_intern.h", "ext/binding_of_caller/ruby_headers/192/id.h", "ext/binding_of_caller/ruby_headers/192/iseq.h", "ext/binding_of_caller/ruby_headers/192/method.h", "ext/binding_of_caller/ruby_headers/192/node.h", "ext/binding_of_caller/ruby_headers/192/regenc.h", "ext/binding_of_caller/ruby_headers/192/regint.h", "ext/binding_of_caller/ruby_headers/192/regparse.h", "ext/binding_of_caller/ruby_headers/192/rubys_gc.h", "ext/binding_of_caller/ruby_headers/192/thread_pthread.h", "ext/binding_of_caller/ruby_headers/192/thread_win32.h", "ext/binding_of_caller/ruby_headers/192/timev.h", "ext/binding_of_caller/ruby_headers/192/transcode_data.h", "ext/binding_of_caller/ruby_headers/192/version.h", "ext/binding_of_caller/ruby_headers/192/vm_core.h", "ext/binding_of_caller/ruby_headers/192/vm_exec.h", "ext/binding_of_caller/ruby_headers/192/vm_insnhelper.h", "ext/binding_of_caller/ruby_headers/192/vm_opts.h", "ext/binding_of_caller/ruby_headers/193/addr2line.h", "ext/binding_of_caller/ruby_headers/193/atomic.h", "ext/binding_of_caller/ruby_headers/193/constant.h", "ext/binding_of_caller/ruby_headers/193/debug.h", "ext/binding_of_caller/ruby_headers/193/dln.h", "ext/binding_of_caller/ruby_headers/193/encdb.h", "ext/binding_of_caller/ruby_headers/193/eval_intern.h", "ext/binding_of_caller/ruby_headers/193/id.h", "ext/binding_of_caller/ruby_headers/193/internal.h", "ext/binding_of_caller/ruby_headers/193/iseq.h", "ext/binding_of_caller/ruby_headers/193/method.h", "ext/binding_of_caller/ruby_headers/193/node.h", "ext/binding_of_caller/ruby_headers/193/parse.h", "ext/binding_of_caller/ruby_headers/193/regenc.h", "ext/binding_of_caller/ruby_headers/193/regint.h", "ext/binding_of_caller/ruby_headers/193/regparse.h", "ext/binding_of_caller/ruby_headers/193/revision.h", "ext/binding_of_caller/ruby_headers/193/rubys_gc.h", "ext/binding_of_caller/ruby_headers/193/thread_pthread.h", "ext/binding_of_caller/ruby_headers/193/thread_win32.h", "ext/binding_of_caller/ruby_headers/193/timev.h", "ext/binding_of_caller/ruby_headers/193/transcode_data.h", "ext/binding_of_caller/ruby_headers/193/transdb.h", "ext/binding_of_caller/ruby_headers/193/version.h", "ext/binding_of_caller/ruby_headers/193/vm_core.h", "ext/binding_of_caller/ruby_headers/193/vm_exec.h", "ext/binding_of_caller/ruby_headers/193/vm_insnhelper.h", "ext/binding_of_caller/ruby_headers/193/vm_opts.h", "lib/binding_of_caller.rb", "lib/binding_of_caller/mri2.rb", "lib/binding_of_caller/rubinius.rb", "lib/binding_of_caller/version.rb", "test/test_binding_of_caller.rb"]
|
|
14
|
+
s.homepage = "http://github.com/banister/binding_of_caller"
|
|
15
|
+
s.require_paths = ["lib"]
|
|
16
|
+
s.rubygems_version = "2.0.3"
|
|
17
|
+
s.summary = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack."
|
|
18
|
+
s.test_files = ["test/test_binding_of_caller.rb"]
|
|
19
|
+
|
|
20
|
+
if s.respond_to? :specification_version then
|
|
21
|
+
s.specification_version = 4
|
|
22
|
+
|
|
23
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
24
|
+
s.add_runtime_dependency(%q<debug_inspector>, [">= 0.0.1"])
|
|
25
|
+
s.add_development_dependency(%q<bacon>, [">= 0"])
|
|
26
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
|
27
|
+
else
|
|
28
|
+
s.add_dependency(%q<debug_inspector>, [">= 0.0.1"])
|
|
29
|
+
s.add_dependency(%q<bacon>, [">= 0"])
|
|
30
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
s.add_dependency(%q<debug_inspector>, [">= 0.0.1"])
|
|
34
|
+
s.add_dependency(%q<bacon>, [">= 0"])
|
|
35
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
|
36
|
+
end
|
|
37
|
+
end
|
data/examples/example.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
unless Object.const_defined? :BindingOfCaller
|
|
2
|
+
$:.unshift File.expand_path '../../lib', __FILE__
|
|
3
|
+
require 'binding_of_caller'
|
|
4
|
+
require 'binding_of_caller/version'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
outer = 10
|
|
8
|
+
|
|
9
|
+
class Z
|
|
10
|
+
def z
|
|
11
|
+
u = 10
|
|
12
|
+
A.new.a
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class A
|
|
17
|
+
def a
|
|
18
|
+
y = 10
|
|
19
|
+
B.new.b
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class B
|
|
24
|
+
def b
|
|
25
|
+
x = 10
|
|
26
|
+
puts binding.of_caller(0).eval('local_variables')
|
|
27
|
+
puts binding.of_caller(1).eval('local_variables')
|
|
28
|
+
puts binding.of_caller(2).eval('local_variables')
|
|
29
|
+
puts binding.of_caller(3).eval('local_variables')
|
|
30
|
+
puts binding.of_caller(400).eval('local_variables')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Z.new.z
|
|
35
|
+
|
|
36
|
+
# output:
|
|
37
|
+
# => x
|
|
38
|
+
# => y
|
|
39
|
+
# => u
|
|
40
|
+
# => outer
|
|
41
|
+
# Exception
|