monkey-lib 0.5.1 → 0.5.2

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.
Files changed (3) hide show
  1. data/lib/monkey/backend.rb +1 -1
  2. data/lib/monkey/ext.rb +23 -10
  3. metadata +4 -4
@@ -97,9 +97,9 @@ module Monkey
97
97
 
98
98
  def self.setup!(backend)
99
99
  if backend
100
+ @setup = true
100
101
  @backend = detect_backend(backend)
101
102
  @backend.setup
102
- @setup = true
103
103
  @backend
104
104
  else
105
105
  available_backends.each do |backend|
@@ -1,4 +1,5 @@
1
1
  require "pathname"
2
+ require "monkey/engine"
2
3
 
3
4
  module Monkey
4
5
  module Ext
@@ -25,17 +26,29 @@ module Monkey
25
26
  __send__(meth, *args, &blk)
26
27
  end
27
28
  EOS
28
- unless klass.is_a? Class
29
- # HACK: Don't modify modules while looping through object space.
30
- # JRuby does not like that.
31
- list = []
32
- ObjectSpace.each_object(Class) do |mod|
33
- list << mod if mod.ancestors.include? klass and not mod.ancestors.include? self
34
- end
35
- list.each { |e| e.send :include, klass }
36
- end
29
+ propagate_include
30
+ end
31
+ @core_class
32
+ end
33
+
34
+ if Monkey::Engine.jruby? and JRUBY_VERSION < '1.6.0'
35
+ def each_module(&block)
36
+ list = []
37
+ ObjectSpace.each_object(Class) { |c| list << c }
38
+ list.each(&block)
39
+ end
40
+ else
41
+ def each_module(&block)
42
+ ObjectSpace.each_object(Module, &block)
43
+ end
44
+ end
45
+
46
+ def propagate_include
47
+ return if core_class.is_a? Class
48
+ each_module do |mod|
49
+ next unless mod < core_class and not mod < self
50
+ mod.send(:include, core_class)
37
51
  end
38
- return @core_class
39
52
  end
40
53
 
41
54
  def included(klass)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey-lib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Konstantin Haase
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-15 00:00:00 +02:00
18
+ date: 2010-07-18 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency