callbacks_attachable 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5704f2e0b5be12b67d21705fd058832d8b43c768
4
- data.tar.gz: af96252e63b77c3d83b99f9c0b1df8d75144e916
3
+ metadata.gz: 7091bf08cc2a80db2eeb18a8f79e183a0d994dad
4
+ data.tar.gz: 6d2ae70d5b6dcbe5c884eeecec9aa9144d90f616
5
5
  SHA512:
6
- metadata.gz: 908846d84dcba7ffa75ee38efd635e6c600015cfd029d39cc83b08ece263a80ec2b66c87c916d5d534aeff5e75d5684e34126109d8374a18e8b5763a9a7067c4
7
- data.tar.gz: 619ad1b6ea59e844fb2e54bd2835ca7b1637b662a1dec721cfa84efb06ecca1b973e2e1a984c7afee60f05be34c55326dd3989969be5586837c3c6a079f2fe75
6
+ metadata.gz: 94f3810baf82fc729a726b66cc301a9b5161d98801efe4331414844d98d922c0a619fcd759110af154ad19928350dbddc8675b4e3f4d6d12a45edfcac86635f0
7
+ data.tar.gz: 98278e8fb7e882e48829a1328b4f83a0bb05ac739203fed142b4bc972d8d81e36efaefe8913d874c801cc2cb81640c577991cba512274da347aaa946483641b3
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --format documentation
2
2
  --color
3
+ --default-path spec/CRuby
4
+ --require spec_helper.rb
@@ -1,4 +1,4 @@
1
- require_relative 'mrblib/version'
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
+ }
@@ -0,0 +1,3 @@
1
+ dir = File.dirname File.dirname __FILE__
2
+ Dir[File.join(dir, 'all', '**', '*.rb')].sort.each{ |f| require f }
3
+ Dir[File.join(dir, 'CRuby', '**', '*.rb')].sort.each{ |f| require f }
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] = true
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].keys.each{ |callback| callback.call(instance, args) }
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(callback)
30
+ @callbacks[event].delete callback.__id__
31
31
  @callbacks.delete(event) if @callbacks[event].empty?
32
32
  end
33
33
  end
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module CallbacksAttachable
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
3
3
  end
data/mrbgem.rake CHANGED
@@ -1,4 +1,4 @@
1
- require_relative 'mrblib/version'
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.0
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-07-07 00:00:00.000000000 Z
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
- - lib/callbacks_attachable.rb
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.11
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.
@@ -1,2 +0,0 @@
1
- dir = File.dirname File.dirname __FILE__
2
- Dir[File.join(dir, 'mrblib', '*.rb')].reject{ |f| f.end_with? '_m.rb' }.sort.each{ |f| require f }
@@ -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