callbacks_attachable 2.3.0 → 2.3.1
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 +4 -4
- data/.rspec +2 -0
- data/callbacks_attachable.gemspec +2 -2
- data/ext/mruby/class.c +20 -0
- data/lib/CRuby/callbacks_attachable.rb +3 -0
- data/{mrblib → lib/all}/callback.rb +0 -0
- data/{mrblib → lib/all}/callback_registry.rb +3 -3
- data/{mrblib → lib/all}/callbacks_attachable.rb +0 -0
- data/{mrblib → lib/all}/error.rb +0 -0
- data/{mrblib → lib/all}/version.rb +1 -1
- data/mrbgem.rake +8 -1
- metadata +11 -11
- data/lib/callbacks_attachable.rb +0 -2
- data/mrblib/_ext_module_m.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7091bf08cc2a80db2eeb18a8f79e183a0d994dad
|
4
|
+
data.tar.gz: 6d2ae70d5b6dcbe5c884eeecec9aa9144d90f616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f3810baf82fc729a726b66cc301a9b5161d98801efe4331414844d98d922c0a619fcd759110af154ad19928350dbddc8675b4e3f4d6d12a45edfcac86635f0
|
7
|
+
data.tar.gz: 98278e8fb7e882e48829a1328b4f83a0bb05ac739203fed142b4bc972d8d81e36efaefe8913d874c801cc2cb81640c577991cba512274da347aaa946483641b3
|
data/.rspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'lib/all/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "callbacks_attachable"
|
@@ -16,5 +16,5 @@ to an individual instance to be triggered only for this instance.
|
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
19
|
+
spec.require_paths = ["lib/CRuby"]
|
20
20
|
end
|
data/ext/mruby/class.c
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#include "mruby.h"
|
2
|
+
#include "mruby/class.h"
|
3
|
+
|
4
|
+
static mrb_value
|
5
|
+
mrb_mod_singleton_class_p(mrb_state *mrb, mrb_value self)
|
6
|
+
{
|
7
|
+
return mrb_bool_value(mrb_type(self) == MRB_TT_SCLASS);
|
8
|
+
}
|
9
|
+
|
10
|
+
void
|
11
|
+
mrb_mruby_callbacks_attachable_gem_init(mrb_state *mrb)
|
12
|
+
{
|
13
|
+
struct RClass *mod = mrb->module_class;
|
14
|
+
mrb_define_method(mrb, mod, "singleton_class?", mrb_mod_singleton_class_p, MRB_ARGS_NONE());
|
15
|
+
}
|
16
|
+
|
17
|
+
void
|
18
|
+
mrb_mruby_callbacks_attachable_gem_final(mrb_state *mrb)
|
19
|
+
{
|
20
|
+
}
|
File without changes
|
@@ -13,7 +13,7 @@ module CallbacksAttachable
|
|
13
13
|
callback = Callback.new(self, events, opts, !@singleton_owner, callback)
|
14
14
|
events.each do |event|
|
15
15
|
@callbacks[event] ||= {}
|
16
|
-
@callbacks[event][callback] =
|
16
|
+
@callbacks[event][callback.__id__] = callback
|
17
17
|
end
|
18
18
|
callback
|
19
19
|
end
|
@@ -23,11 +23,11 @@ module CallbacksAttachable
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def trigger(instance, event, args)
|
26
|
-
@callbacks[event] and @callbacks[event].
|
26
|
+
@callbacks[event] and @callbacks[event].each_value{ |callback| callback.call(instance, args) }
|
27
27
|
end
|
28
28
|
|
29
29
|
def deregister(event, callback)
|
30
|
-
@callbacks[event].delete
|
30
|
+
@callbacks[event].delete callback.__id__
|
31
31
|
@callbacks.delete(event) if @callbacks[event].empty?
|
32
32
|
end
|
33
33
|
end
|
File without changes
|
data/{mrblib → lib/all}/error.rb
RENAMED
File without changes
|
data/mrbgem.rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'lib/all/version'
|
2
2
|
|
3
3
|
MRuby::Gem::Specification.new('mruby-callbacks_attachable') do |spec|
|
4
4
|
spec.version = CallbacksAttachable::VERSION
|
@@ -14,4 +14,11 @@ DESC
|
|
14
14
|
|
15
15
|
spec.add_dependency 'mruby-objectspace', :core => 'mruby-objectspace'
|
16
16
|
spec.add_dependency 'mruby-object-ext', :core => 'mruby-object-ext'
|
17
|
+
|
18
|
+
spec.objs = Dir["#{spec.dir}/ext/mruby/**/*.c"].sort.map do |f|
|
19
|
+
objfile(f.relative_path_from(spec.dir).to_s.pathmap("#{build_dir}/%X"))
|
20
|
+
end
|
21
|
+
spec.rbfiles =
|
22
|
+
Dir["#{spec.dir}/lib/all/**/*.rb"].sort +
|
23
|
+
Dir["#{spec.dir}/lib/mruby/**/*.rb"].sort
|
17
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: callbacks_attachable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Aue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Attach callbacks to classes to be triggered for all instances or attach them
|
@@ -25,14 +25,14 @@ files:
|
|
25
25
|
- LICENSE.txt
|
26
26
|
- README.md
|
27
27
|
- callbacks_attachable.gemspec
|
28
|
-
-
|
28
|
+
- ext/mruby/class.c
|
29
|
+
- lib/CRuby/callbacks_attachable.rb
|
30
|
+
- lib/all/callback.rb
|
31
|
+
- lib/all/callback_registry.rb
|
32
|
+
- lib/all/callbacks_attachable.rb
|
33
|
+
- lib/all/error.rb
|
34
|
+
- lib/all/version.rb
|
29
35
|
- mrbgem.rake
|
30
|
-
- mrblib/_ext_module_m.rb
|
31
|
-
- mrblib/callback.rb
|
32
|
-
- mrblib/callback_registry.rb
|
33
|
-
- mrblib/callbacks_attachable.rb
|
34
|
-
- mrblib/error.rb
|
35
|
-
- mrblib/version.rb
|
36
36
|
homepage: https://github.com/christopheraue/m-ruby-callbacks_attachable
|
37
37
|
licenses:
|
38
38
|
- MIT
|
@@ -40,7 +40,7 @@ metadata: {}
|
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|
43
|
-
- lib
|
43
|
+
- lib/CRuby
|
44
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.6.
|
56
|
+
rubygems_version: 2.6.13
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Attach callbacks to classes or individual instances.
|
data/lib/callbacks_attachable.rb
DELETED
data/mrblib/_ext_module_m.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Module.class_eval do
|
2
|
-
def singleton_class?
|
3
|
-
# The object id of a module is its pointer address shifted 5 to the left
|
4
|
-
# and adding its type id:
|
5
|
-
# https://github.com/mruby/mruby/blob/2e8ed9514feb74f4137e5835e74f256d52d6f191/src/etc.c#L108
|
6
|
-
#
|
7
|
-
# The type id of a singleton class is 0xc
|
8
|
-
# https://github.com/mruby/mruby/blob/a0fbc46ccd3e129532b05a9fe4f13f42a3c349b2/include/mruby/value.h#L107
|
9
|
-
|
10
|
-
__id__ & 0x1f == 0xc
|
11
|
-
end
|
12
|
-
end
|