binding_ninja 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1c7723d881ecc904a3b67b20881a9be6d6fac52
4
+ data.tar.gz: bde453b73c9ffee4d969579d7019ffe468e0a5a5
5
+ SHA512:
6
+ metadata.gz: 23871995930d39725660c653138eb9069598efa27530539ba213db193e7de118792316252d4e7e8e658c84491e1b959a34c2af0da6afcbf2663922f3b5d7f587
7
+ data.tar.gz: a2e3f3dac226dd124805fb289a1db3d8af137cc422282eb761fcb7b87f62af71b80c31ed7fc3a9c01f87c73f552f6344698831bd0c7f965df8a6d04198f92aaa
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in binding_ninja.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # BindingNinja
2
+
3
+ This is method wrapper for passing binding of method caller implcitly.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'binding_ninja'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install binding_ninja
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ class Foo
25
+ extend BindingNinja
26
+
27
+ def foo(binding, arg1, arg2)
28
+ p binding
29
+ p arg1
30
+ p arg2
31
+ end
32
+ auto_inject_binding :foo
33
+ end
34
+
35
+ Foo.new.foo(1, 2)
36
+ # => <Binding of toplevel>
37
+ # => 1
38
+ # => 2
39
+ ```
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joker1007/binding_ninja.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rake/extensiontask"
7
+
8
+ task :build => :compile
9
+
10
+ Rake::ExtensionTask.new("binding_ninja") do |ext|
11
+ ext.lib_dir = "lib/binding_ninja"
12
+ end
13
+
14
+ task :default => [:clobber, :compile, :spec]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "binding_ninja"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "binding_ninja/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "binding_ninja"
8
+ spec.version = BindingNinja::VERSION
9
+ spec.authors = ["joker1007"]
10
+ spec.email = ["kakyoin.hierophant@gmail.com"]
11
+
12
+ spec.summary = %q{pass binding of method caller implicitly}
13
+ spec.description = %q{pass binding of method caller implicitly}
14
+ spec.homepage = "https://github.com/joker1007/binding_ninja"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+ spec.extensions = ["ext/binding_ninja/extconf.rb"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rake-compiler"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
@@ -0,0 +1,52 @@
1
+ #include "binding_ninja.h"
2
+
3
+ VALUE rb_mBindingNinja;
4
+ static VALUE auto_inject_binding_invoke(int argc, VALUE *argv, VALUE self);
5
+
6
+ static VALUE
7
+ auto_inject_binding(VALUE mod, VALUE method_sym)
8
+ {
9
+ ID mid;
10
+ VALUE mod_name, extensions, ext_mod;
11
+
12
+ mid = SYM2ID(method_sym);
13
+ int arity = rb_mod_method_arity(mod, mid);
14
+ if (abs(arity) < 1) {
15
+ rb_raise(rb_eArgError, "target method receives 1 or more arguments");
16
+ }
17
+
18
+ mod_name = rb_mod_name(mod);
19
+ extensions = rb_ivar_get(rb_mBindingNinja, rb_intern("@auto_inject_binding_extensions"));
20
+ ext_mod = rb_hash_aref(extensions, mod_name);
21
+ if (ext_mod == Qnil) {
22
+ ext_mod = rb_module_new();
23
+ rb_hash_aset(extensions, mod_name, ext_mod);
24
+ }
25
+ if (rb_mod_include_p(mod, ext_mod) == Qfalse) {
26
+ rb_prepend_module(mod, ext_mod);
27
+ }
28
+
29
+ rb_define_method_id(ext_mod, SYM2ID(method_sym), auto_inject_binding_invoke, -1);
30
+
31
+ return method_sym;
32
+ }
33
+
34
+ static VALUE
35
+ auto_inject_binding_invoke(int argc, VALUE *argv, VALUE self)
36
+ {
37
+ VALUE binding, args_ary;
38
+
39
+ binding = rb_binding_new();
40
+ args_ary = rb_ary_new_from_values(argc, argv);
41
+ rb_ary_unshift(args_ary, binding);
42
+
43
+ return rb_call_super(argc + 1, RARRAY_CONST_PTR(args_ary));
44
+ }
45
+
46
+ void
47
+ Init_binding_ninja(void)
48
+ {
49
+ rb_mBindingNinja = rb_define_module("BindingNinja");
50
+ rb_ivar_set(rb_mBindingNinja, rb_intern("@auto_inject_binding_extensions"), rb_hash_new());
51
+ rb_define_private_method(rb_mBindingNinja, "auto_inject_binding", auto_inject_binding, 1);
52
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef BINDING_NINJA_H
2
+ #define BINDING_NINJA_H 1
3
+
4
+ #include "ruby.h"
5
+
6
+ #endif /* BINDING_NINJA_H */
@@ -0,0 +1,3 @@
1
+ require "mkmf"
2
+
3
+ create_makefile("binding_ninja/binding_ninja")
@@ -0,0 +1,3 @@
1
+ module BindingNinja
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "binding_ninja/version"
2
+ require "binding_ninja/binding_ninja"
3
+
4
+ module BindingNinja
5
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binding_ninja
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - joker1007
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: pass binding of method caller implicitly
70
+ email:
71
+ - kakyoin.hierophant@gmail.com
72
+ executables: []
73
+ extensions:
74
+ - ext/binding_ninja/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - binding_ninja.gemspec
86
+ - ext/binding_ninja/binding_ninja.c
87
+ - ext/binding_ninja/binding_ninja.h
88
+ - ext/binding_ninja/extconf.rb
89
+ - lib/binding_ninja.rb
90
+ - lib/binding_ninja/version.rb
91
+ homepage: https://github.com/joker1007/binding_ninja
92
+ licenses: []
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.12
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: pass binding of method caller implicitly
114
+ test_files: []