binding_of_caller 0.4.0 → 0.8.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ca118584b33771699ce8297cafc573b9f1d2d80
4
+ data.tar.gz: cdfcd664fd08599e4f4826862fb49f8d4eecc992
5
+ SHA512:
6
+ metadata.gz: 21766025ccac08d6f79ba1e5bbef018116b765ca44b98f4fb269e494cf52dfb1066c4deb305eb30ddcdac2edc9e4f041926fe0e77767eb40a7cbd3ac866c00a7
7
+ data.tar.gz: 3b23f40eca0b622e89af12c443c54eed869441da9e3f2042b7d57acc77ffee2cd971ac8ee7e3beb9efcd58ce5b33003948f3705f711d928af1eeef3ee370fe3f
data/.gemtest CHANGED
File without changes
data/.gitignore CHANGED
@@ -1,7 +1,8 @@
1
- Makefile
2
- *.so
3
- *.o
4
- *.def
5
- doc/
6
- pkg/
7
- .yardoc/
1
+ Makefile
2
+ *.so
3
+ *.o
4
+ *.def
5
+ doc/
6
+ pkg/
7
+ .yardoc/
8
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,35 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.6
7
+ - 2.3.0
8
+ - 2.4.0
9
+ - 2.5.0
10
+
11
+ notifications:
12
+ irc: "irc.freenode.org#pry"
13
+ recipients:
14
+ - jrmair@gmail.com
15
+
16
+ branches:
17
+ only:
18
+ - master
19
+
20
+ matrix:
21
+ include:
22
+ - rvm: jruby
23
+ env: JRUBY_OPTS=-X-C
24
+ allow_failures:
25
+ - rvm: jruby
26
+ - rvm: 1.9.3
27
+
28
+ #script: rake test --trace
29
+ #
30
+ before_install:
31
+ - gem update --system
32
+ # - gem --version
33
+ # - gem install rake bacon
34
+ # - rake gem
35
+ # - gem install pkg/*.gem
data/.yardopts CHANGED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/HISTORY CHANGED
@@ -0,0 +1,35 @@
1
+ ## 0.7.3.pre1 / 2014-08-20
2
+
3
+ This release includes compatibility fixes for different ruby versions
4
+ and some minor enhancements.
5
+
6
+ * C Extensions are only compiled on MRI 1.9.x.
7
+
8
+ For MRI >= 2 the native API is used, so this should speedup
9
+ installation.
10
+
11
+ For JRuby this will avoid crashes on gem installation.
12
+
13
+ This was alredy being checked for Rubinius.
14
+
15
+ *Amadeus Folego*
16
+
17
+ * Added experimental JRuby support for 1.7.x series.
18
+
19
+ Only the main API is implemented and `Binding#eval` is
20
+ monkey-patched as it is private on JRuby.
21
+
22
+ This requires the compiler to be run on interpreted mode,
23
+ otherwise an exception will be thrown when `of_caller` is called.
24
+
25
+ *Charles Nutter*
26
+
27
+ * Remove executability from non-executable files.
28
+
29
+ *David Celis*
30
+
31
+ * Test and notice MRI 2.1 as a working Ruby implementation.
32
+
33
+ *Lennart Fridén*
34
+
35
+ ## 0.7.2 / 2013-06-07
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
+ [![Build Status](https://secure.travis-ci.org/banister/binding_of_caller.png)](http://travis-ci.org/banister/binding_of_caller)
2
+
1
3
  binding_of_caller
2
4
  ===========
3
5
 
4
- (C) John Mair (banisterfiend) 2011
6
+ (C) John Mair (banisterfiend) 2012
5
7
 
6
- _Retrieve the binding of a method's caller in MRI 1.9.2_
8
+ _Retrieve the binding of a method's caller in MRI (>= 1.9.2) and RBX (Rubinius)_
7
9
 
8
10
  The `binding_of_caller` gem provides the `Binding#of_caller` method.
9
11
 
@@ -13,7 +15,7 @@ call stack, not limited to just the immediate caller.
13
15
 
14
16
  **Recommended for use only in debugging situations. Do not use this in production apps.**
15
17
 
16
- **Only works in MRI Ruby 1.9.2**
18
+ **Works in MRI Ruby (>= 1.9.2) and RBX (Rubinius)**
17
19
 
18
20
  * Install the [gem](https://rubygems.org/gems/binding_of_caller): `gem install binding_of_caller`
19
21
  * See the [source code](http://github.com/banister/binding_of_caller)
@@ -50,9 +52,11 @@ This project is a spinoff from the [Pry REPL project.](http://pry.github.com)
50
52
  Features and limitations
51
53
  -------------------------
52
54
 
53
- * Only works with MRI 1.9.2
54
- * Broken in 1.9.3, support will hopefully be provided in the near future.
55
+ * Works in MRI (>= 1.9.2) and RBX (Rubinius)
55
56
  * Does not work in 1.8.7, but there is a well known (continuation-based) hack to get a `Binding#of_caller` there.
57
+ * There is experimental support for jruby 1.7.x, but it only works in interpreted
58
+ mode (i.e. use the option `-Djruby.compile.mode=OFF` or append
59
+ `compile.mode=OFF` to your `.jrubyrc`)
56
60
 
57
61
  Contact
58
62
  -------
@@ -65,7 +69,7 @@ License
65
69
 
66
70
  (The MIT License)
67
71
 
68
- Copyright (c) 2011 (John Mair)
72
+ Copyright (c) 2012 (John Mair)
69
73
 
70
74
  Permission is hereby granted, free of charge, to any person obtaining
71
75
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,80 +1,134 @@
1
- dlext = Config::CONFIG['DLEXT']
2
-
3
- $:.unshift 'lib'
4
-
5
- PROJECT_NAME = "binding_of_caller"
6
-
7
- require 'rake/clean'
8
- require 'rake/gempackagetask'
9
- require "#{PROJECT_NAME}/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")
15
-
16
- def apply_spec_defaults(s)
17
- s.name = PROJECT_NAME
18
- s.summary = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack. Currently only works for MRI 1.9.2."
19
- s.version = BindingOfCaller::VERSION
20
- s.date = Time.now.strftime '%Y-%m-%d'
21
- s.author = "John Mair (banisterfiend)"
22
- s.email = 'jrmair@gmail.com'
23
- s.description = s.summary
24
- s.require_path = 'lib'
25
- s.add_development_dependency("bacon","~>1.1.0")
26
- s.homepage = "http://github.com/banister/binding_of_caller"
27
- s.has_rdoc = 'yard'
28
- s.files = `git ls-files`.split("\n")
29
- s.test_files = `git ls-files -- test/*`.split("\n")
30
- end
31
-
32
- desc "Run tests"
33
- task :test do
34
- sh "bacon -Itest -rubygems test.rb -q"
35
- end
36
-
37
- task :pry do
38
- puts "loading binding_of_caller into pry"
39
- sh "pry -r ./lib/binding_of_caller"
40
- end
41
-
42
- namespace :ruby do
43
- spec = Gem::Specification.new do |s|
44
- apply_spec_defaults(s)
45
- s.platform = Gem::Platform::RUBY
46
- s.extensions = ["ext/#{PROJECT_NAME}/extconf.rb"]
47
- end
48
-
49
- Rake::GemPackageTask.new(spec) do |pkg|
50
- pkg.need_zip = false
51
- pkg.need_tar = false
52
- end
53
- end
54
-
55
- desc "build the binaries"
56
- task :compile do
57
- chdir "./ext/#{PROJECT_NAME}/" do
58
- sh "ruby extconf.rb"
59
- sh "make clean"
60
- sh "make"
61
- sh "cp *.#{dlext} ../../lib/"
62
- end
63
- end
64
-
65
- desc "build all platform gems at once"
66
- task :gems => [:clean, :rmgems, "ruby:gem"]
67
-
68
- task :gem => [:gems]
69
-
70
- desc "remove all platform gems"
71
- task :rmgems => ["ruby:clobber_package"]
72
-
73
- desc "build and push latest gems"
74
- task :pushgems => :gems do
75
- chdir("./pkg") do
76
- Dir["*.gem"].each do |gemfile|
77
- sh "gem push #{gemfile}"
78
- end
79
- end
80
- 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) or defined?(JRuby)
50
+ Rake::Task['compile'].execute
51
+ end
52
+
53
+ $stdout.puts("\033[33m")
54
+ sh "bacon -Itest -r 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,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # stub: binding_of_caller 0.8.0 ruby lib
3
+ # stub: ext/binding_of_caller/extconf.rb
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "binding_of_caller".freeze
7
+ s.version = "0.8.0"
8
+
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
10
+ s.require_paths = ["lib".freeze]
11
+ s.authors = ["John Mair (banisterfiend)".freeze]
12
+ s.date = "2018-01-10"
13
+ s.description = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack.".freeze
14
+ s.email = "jrmair@gmail.com".freeze
15
+ s.extensions = ["ext/binding_of_caller/extconf.rb".freeze]
16
+ s.files = [".gemtest".freeze, ".gitignore".freeze, ".travis.yml".freeze, ".yardopts".freeze, "Gemfile".freeze, "HISTORY".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "binding_of_caller.gemspec".freeze, "examples/benchmark.rb".freeze, "examples/example.rb".freeze, "ext/binding_of_caller/binding_of_caller.c".freeze, "ext/binding_of_caller/extconf.rb".freeze, "ext/binding_of_caller/ruby_headers/192/debug.h".freeze, "ext/binding_of_caller/ruby_headers/192/dln.h".freeze, "ext/binding_of_caller/ruby_headers/192/eval_intern.h".freeze, "ext/binding_of_caller/ruby_headers/192/id.h".freeze, "ext/binding_of_caller/ruby_headers/192/iseq.h".freeze, "ext/binding_of_caller/ruby_headers/192/method.h".freeze, "ext/binding_of_caller/ruby_headers/192/node.h".freeze, "ext/binding_of_caller/ruby_headers/192/regenc.h".freeze, "ext/binding_of_caller/ruby_headers/192/regint.h".freeze, "ext/binding_of_caller/ruby_headers/192/regparse.h".freeze, "ext/binding_of_caller/ruby_headers/192/rubys_gc.h".freeze, "ext/binding_of_caller/ruby_headers/192/thread_pthread.h".freeze, "ext/binding_of_caller/ruby_headers/192/thread_win32.h".freeze, "ext/binding_of_caller/ruby_headers/192/timev.h".freeze, "ext/binding_of_caller/ruby_headers/192/transcode_data.h".freeze, "ext/binding_of_caller/ruby_headers/192/version.h".freeze, "ext/binding_of_caller/ruby_headers/192/vm_core.h".freeze, "ext/binding_of_caller/ruby_headers/192/vm_exec.h".freeze, "ext/binding_of_caller/ruby_headers/192/vm_insnhelper.h".freeze, "ext/binding_of_caller/ruby_headers/192/vm_opts.h".freeze, "ext/binding_of_caller/ruby_headers/193/addr2line.h".freeze, "ext/binding_of_caller/ruby_headers/193/atomic.h".freeze, "ext/binding_of_caller/ruby_headers/193/constant.h".freeze, "ext/binding_of_caller/ruby_headers/193/debug.h".freeze, "ext/binding_of_caller/ruby_headers/193/dln.h".freeze, "ext/binding_of_caller/ruby_headers/193/encdb.h".freeze, "ext/binding_of_caller/ruby_headers/193/eval_intern.h".freeze, "ext/binding_of_caller/ruby_headers/193/id.h".freeze, "ext/binding_of_caller/ruby_headers/193/internal.h".freeze, "ext/binding_of_caller/ruby_headers/193/iseq.h".freeze, "ext/binding_of_caller/ruby_headers/193/method.h".freeze, "ext/binding_of_caller/ruby_headers/193/node.h".freeze, "ext/binding_of_caller/ruby_headers/193/parse.h".freeze, "ext/binding_of_caller/ruby_headers/193/regenc.h".freeze, "ext/binding_of_caller/ruby_headers/193/regint.h".freeze, "ext/binding_of_caller/ruby_headers/193/regparse.h".freeze, "ext/binding_of_caller/ruby_headers/193/revision.h".freeze, "ext/binding_of_caller/ruby_headers/193/rubys_gc.h".freeze, "ext/binding_of_caller/ruby_headers/193/thread_pthread.h".freeze, "ext/binding_of_caller/ruby_headers/193/thread_win32.h".freeze, "ext/binding_of_caller/ruby_headers/193/timev.h".freeze, "ext/binding_of_caller/ruby_headers/193/transcode_data.h".freeze, "ext/binding_of_caller/ruby_headers/193/transdb.h".freeze, "ext/binding_of_caller/ruby_headers/193/version.h".freeze, "ext/binding_of_caller/ruby_headers/193/vm_core.h".freeze, "ext/binding_of_caller/ruby_headers/193/vm_exec.h".freeze, "ext/binding_of_caller/ruby_headers/193/vm_insnhelper.h".freeze, "ext/binding_of_caller/ruby_headers/193/vm_opts.h".freeze, "lib/binding_of_caller.rb".freeze, "lib/binding_of_caller/jruby_interpreted.rb".freeze, "lib/binding_of_caller/mri2.rb".freeze, "lib/binding_of_caller/rubinius.rb".freeze, "lib/binding_of_caller/version.rb".freeze, "test/test_binding_of_caller.rb".freeze]
17
+ s.homepage = "http://github.com/banister/binding_of_caller".freeze
18
+ s.rubygems_version = "2.6.14".freeze
19
+ s.summary = "Retrieve the binding of a method's caller. Can also retrieve bindings even further up the stack.".freeze
20
+ s.test_files = ["test/test_binding_of_caller.rb".freeze]
21
+
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 4
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<debug_inspector>.freeze, [">= 0.0.1"])
27
+ s.add_development_dependency(%q<bacon>.freeze, [">= 0"])
28
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
29
+ else
30
+ s.add_dependency(%q<debug_inspector>.freeze, [">= 0.0.1"])
31
+ s.add_dependency(%q<bacon>.freeze, [">= 0"])
32
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<debug_inspector>.freeze, [">= 0.0.1"])
36
+ s.add_dependency(%q<bacon>.freeze, [">= 0"])
37
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
38
+ end
39
+ end
@@ -0,0 +1,63 @@
1
+ require 'benchmark'
2
+
3
+ unless Object.const_defined? :BindingOfCaller
4
+ $:.unshift File.expand_path '../../lib', __FILE__
5
+ require 'binding_of_caller'
6
+ require 'binding_of_caller/version'
7
+ end
8
+
9
+
10
+ n = 250000
11
+
12
+ Benchmark.bm(10) do |x|
13
+ x.report("#of_caller") do
14
+ 1.upto(n) do
15
+ 1.times do
16
+ 1.times do
17
+ binding.of_caller(2)
18
+ binding.of_caller(1)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ x.report("#frame_count") do
25
+ 1.upto(n) do
26
+ 1.times do
27
+ 1.times do
28
+ binding.frame_count
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ x.report("#callers") do
35
+ 1.upto(n) do
36
+ 1.times do
37
+ 1.times do
38
+ binding.callers
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ x.report("#frame_description") do
45
+ 1.upto(n) do
46
+ 1.times do
47
+ 1.times do
48
+ binding.of_caller(1).frame_description
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ x.report("#frame_type") do
55
+ 1.upto(n) do
56
+ 1.times do
57
+ 1.times do
58
+ binding.of_caller(1).frame_type
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end