binding_of_caller 0.6.2 → 0.6.3-universal-rubinius
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.
- data/Rakefile +36 -5
- data/lib/binding_of_caller/version.rb +1 -1
- data/lib/binding_of_caller.bundle +0 -0
- data/lib/binding_of_caller.rb +82 -0
- data/lib/tester.rb +15 -0
- metadata +11 -9
data/Rakefile
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
dlext = Config::CONFIG['DLEXT']
|
|
2
|
+
direc = File.dirname(__FILE__)
|
|
2
3
|
|
|
3
4
|
$:.unshift 'lib'
|
|
4
5
|
|
|
5
6
|
PROJECT_NAME = "binding_of_caller"
|
|
6
7
|
|
|
7
8
|
require 'rake/clean'
|
|
8
|
-
require '
|
|
9
|
+
require 'rubygems/package_task'
|
|
10
|
+
|
|
9
11
|
require "#{PROJECT_NAME}/version"
|
|
10
12
|
|
|
11
13
|
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
|
12
14
|
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
|
|
13
15
|
"ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
|
|
14
|
-
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
|
|
16
|
+
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
|
|
15
17
|
|
|
16
18
|
def apply_spec_defaults(s)
|
|
17
19
|
s.name = PROJECT_NAME
|
|
@@ -25,7 +27,6 @@ def apply_spec_defaults(s)
|
|
|
25
27
|
s.add_development_dependency("bacon","~>1.1")
|
|
26
28
|
s.homepage = "http://github.com/banister/binding_of_caller"
|
|
27
29
|
s.has_rdoc = 'yard'
|
|
28
|
-
s.required_ruby_version = '>= 1.9.2'
|
|
29
30
|
s.files = `git ls-files`.split("\n")
|
|
30
31
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
31
32
|
end
|
|
@@ -40,6 +41,9 @@ task :pry do
|
|
|
40
41
|
sh "pry -r ./lib/binding_of_caller"
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
desc "generate gemspec"
|
|
45
|
+
task :gemspec => "ruby:gemspec"
|
|
46
|
+
|
|
43
47
|
namespace :ruby do
|
|
44
48
|
spec = Gem::Specification.new do |s|
|
|
45
49
|
apply_spec_defaults(s)
|
|
@@ -47,7 +51,26 @@ namespace :ruby do
|
|
|
47
51
|
s.extensions = ["ext/#{PROJECT_NAME}/extconf.rb"]
|
|
48
52
|
end
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
Gem::PackageTask.new(spec) do |pkg|
|
|
55
|
+
pkg.need_zip = false
|
|
56
|
+
pkg.need_tar = false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
desc "Generate gemspec file"
|
|
60
|
+
task :gemspec do
|
|
61
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
|
62
|
+
f << spec.to_ruby
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
namespace :rbx do
|
|
68
|
+
spec = Gem::Specification.new do |s|
|
|
69
|
+
apply_spec_defaults(s)
|
|
70
|
+
s.platform = Gem::Platform.new(["universal", "rubinius"])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Gem::PackageTask.new(spec) do |pkg|
|
|
51
74
|
pkg.need_zip = false
|
|
52
75
|
pkg.need_tar = false
|
|
53
76
|
end
|
|
@@ -63,11 +86,19 @@ task :compile do
|
|
|
63
86
|
end
|
|
64
87
|
end
|
|
65
88
|
|
|
89
|
+
desc "reinstall gem"
|
|
90
|
+
task :reinstall => :gems do
|
|
91
|
+
sh "gem uninstall binding_of_caller" rescue nil
|
|
92
|
+
sh "gem install #{direc}/pkg/#{PROJECT_NAME}-#{BindingOfCaller::VERSION}.gem"
|
|
93
|
+
end
|
|
94
|
+
|
|
66
95
|
desc "build all platform gems at once"
|
|
67
|
-
task :gems => [:clean, :rmgems, "ruby:gem"]
|
|
96
|
+
task :gems => [:clean, :rmgems, "ruby:gem", "rbx:gem"]
|
|
68
97
|
|
|
69
98
|
task :gem => [:gems]
|
|
70
99
|
|
|
100
|
+
task :rbxgem => "rbx:gem"
|
|
101
|
+
|
|
71
102
|
desc "remove all platform gems"
|
|
72
103
|
task :rmgems => ["ruby:clobber_package"]
|
|
73
104
|
|
|
Binary file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
dlext = Config::CONFIG['DLEXT']
|
|
2
|
+
|
|
3
|
+
if RUBY_ENGINE && RUBY_ENGINE == "ruby"
|
|
4
|
+
require "binding_of_caller.#{dlext}"
|
|
5
|
+
|
|
6
|
+
elsif defined?(Rubinius)
|
|
7
|
+
module BindingOfCaller
|
|
8
|
+
module BindingExtensions
|
|
9
|
+
|
|
10
|
+
def of_caller(n)
|
|
11
|
+
bt = Rubinius::VM.backtrace(1 + n, true).first
|
|
12
|
+
|
|
13
|
+
b = Binding.setup(
|
|
14
|
+
bt.variables,
|
|
15
|
+
bt.variables.method,
|
|
16
|
+
bt.static_scope,
|
|
17
|
+
bt.variables.self,
|
|
18
|
+
bt
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
b.instance_variable_set(:@frame_description, bt.describe)
|
|
22
|
+
|
|
23
|
+
b
|
|
24
|
+
rescue
|
|
25
|
+
raise RuntimeError, "Invalid frame, gone beyond end of stack!"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def frame_description
|
|
29
|
+
@frame_description
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def callers
|
|
33
|
+
ary = []
|
|
34
|
+
n = 0
|
|
35
|
+
loop {
|
|
36
|
+
begin
|
|
37
|
+
ary << Binding.of_caller(n)
|
|
38
|
+
rescue
|
|
39
|
+
break
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
n += 1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ary
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def frame_count
|
|
49
|
+
ary = []
|
|
50
|
+
n = 1
|
|
51
|
+
loop {
|
|
52
|
+
begin
|
|
53
|
+
Binding.of_caller(n)
|
|
54
|
+
rescue
|
|
55
|
+
break
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
n += 1
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
n
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def frame_type
|
|
65
|
+
case self.variables.method.metadata.to_a.first.to_s
|
|
66
|
+
when /block/
|
|
67
|
+
:block
|
|
68
|
+
when /eval/
|
|
69
|
+
:eval
|
|
70
|
+
else
|
|
71
|
+
:method
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class ::Binding
|
|
79
|
+
include BindingOfCaller::BindingExtensions
|
|
80
|
+
extend BindingOfCaller::BindingExtensions
|
|
81
|
+
end
|
|
82
|
+
end
|
data/lib/tester.rb
ADDED
metadata
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: binding_of_caller
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
prerelease:
|
|
6
|
-
platform:
|
|
6
|
+
platform: universal-rubinius
|
|
7
7
|
authors:
|
|
8
8
|
- John Mair (banisterfiend)
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-02-
|
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bacon
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70210333918260 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,13 +21,12 @@ dependencies:
|
|
|
21
21
|
version: '1.1'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70210333918260
|
|
25
25
|
description: Retrieve the binding of a method's caller. Can also retrieve bindings
|
|
26
26
|
even further up the stack. Currently only works for MRI 1.9.2+
|
|
27
27
|
email: jrmair@gmail.com
|
|
28
28
|
executables: []
|
|
29
|
-
extensions:
|
|
30
|
-
- ext/binding_of_caller/extconf.rb
|
|
29
|
+
extensions: []
|
|
31
30
|
extra_rdoc_files: []
|
|
32
31
|
files:
|
|
33
32
|
- .gemtest
|
|
@@ -88,7 +87,10 @@ files:
|
|
|
88
87
|
- ext/binding_of_caller/ruby_headers/193/vm_exec.h
|
|
89
88
|
- ext/binding_of_caller/ruby_headers/193/vm_insnhelper.h
|
|
90
89
|
- ext/binding_of_caller/ruby_headers/193/vm_opts.h
|
|
90
|
+
- lib/binding_of_caller.bundle
|
|
91
|
+
- lib/binding_of_caller.rb
|
|
91
92
|
- lib/binding_of_caller/version.rb
|
|
93
|
+
- lib/tester.rb
|
|
92
94
|
- test/test.rb
|
|
93
95
|
homepage: http://github.com/banister/binding_of_caller
|
|
94
96
|
licenses: []
|
|
@@ -101,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
101
103
|
requirements:
|
|
102
104
|
- - ! '>='
|
|
103
105
|
- !ruby/object:Gem::Version
|
|
104
|
-
version:
|
|
106
|
+
version: '0'
|
|
105
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
none: false
|
|
107
109
|
requirements:
|
|
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
112
|
version: '0'
|
|
111
113
|
requirements: []
|
|
112
114
|
rubyforge_project:
|
|
113
|
-
rubygems_version: 1.8.
|
|
115
|
+
rubygems_version: 1.8.16
|
|
114
116
|
signing_key:
|
|
115
117
|
specification_version: 3
|
|
116
118
|
summary: Retrieve the binding of a method's caller. Can also retrieve bindings even
|