real_include 0.1.5-i386-mswin32 → 0.1.6-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ specification = Gem::Specification.new do |s|
25
25
  s.homepage = "http://banisterfiend.wordpress.com"
26
26
  s.has_rdoc = false
27
27
 
28
- #s.extensions = ["ext/real_include/extconf.rb"]
28
+ s.extensions = ["ext/real_include/extconf.rb"]
29
29
  s.files = ["Rakefile", "README.markdown", "CHANGELOG",
30
30
  "lib/real_include.rb", "lib/real_include/version.rb"] +
31
31
  ["lib/1.9/real_include.so", "lib/1.8/real_include.so"] +
@@ -19,12 +19,35 @@ class_alloc(VALUE flags, VALUE klass)
19
19
  }
20
20
  #endif
21
21
 
22
+
23
+ static VALUE
24
+ class_to_s(VALUE self)
25
+ {
26
+ VALUE attached = rb_iv_get(self, "__attached__");
27
+
28
+ if (attached)
29
+ return rb_mod_name(rb_iv_get(attached, "__module__"));
30
+ else
31
+ return rb_mod_name(rb_iv_get(self, "__module__"));
32
+ }
33
+
22
34
  static VALUE
23
35
  include_class_new(VALUE module, VALUE super)
24
36
  {
25
37
  /* base case for recursion */
26
38
  if (module == rb_singleton_class(rb_cModule))
27
39
  return module;
40
+
41
+ if (TYPE(module) == T_ICLASS) {
42
+
43
+ /* real_include */
44
+ if (rb_iv_get(module, "__module__"))
45
+ module = rb_iv_get(module, "__module__");
46
+
47
+ /* ordinary Module#include */
48
+ else
49
+ module = KLASS_OF(module);
50
+ }
28
51
 
29
52
  /* allocate iclass */
30
53
  #ifdef RUBY_19
@@ -40,6 +63,9 @@ include_class_new(VALUE module, VALUE super)
40
63
  RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
41
64
  RCLASS_SUPER(klass) = super;
42
65
 
66
+ if (TYPE(module) == T_MODULE || FL_TEST(module, FL_SINGLETON))
67
+ rb_iv_set(klass, "__module__", module);
68
+
43
69
  /* create IClass for module's singleton */
44
70
  /* if super is 0 then we're including into a module (not a class), so treat as special case */
45
71
  VALUE meta = include_class_new(KLASS_OF(module), super ? KLASS_OF(super) : rb_cModule);
@@ -51,7 +77,10 @@ include_class_new(VALUE module, VALUE super)
51
77
  FL_SET(meta, FL_SINGLETON);
52
78
 
53
79
  /* attach singleton to module */
54
- rb_singleton_class_attached((VALUE)meta, (VALUE)klass);
80
+ rb_iv_set(meta, "__attached__", klass);
81
+
82
+ /* attach the #to_s method to the metaclass (so #ancestors doesn't look weird) */
83
+ rb_define_singleton_method(meta, "to_s", class_to_s, 0);
55
84
  }
56
85
  /* assign the metaclass to module's klass */
57
86
  KLASS_OF(klass) = meta;
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module RealInclude
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: real_include
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: i386-mswin32
12
12
  authors:
13
13
  - John Mair (banisterfiend)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 +13:00
18
+ date: 2010-10-12 00:00:00 +13:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -23,8 +23,8 @@ description: Fixing the limitation in traditional Module#include
23
23
  email: jrmair@gmail.com
24
24
  executables: []
25
25
 
26
- extensions: []
27
-
26
+ extensions:
27
+ - ext/real_include/extconf.rb
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files: