remix 0.3.0-i386-mswin32 → 0.3.4-i386-mswin32
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.
- data/Rakefile +42 -17
- data/ext/remix/remix.c +19 -12
- data/lib/1.8/remix.so +0 -0
- data/lib/1.9/remix.so +0 -0
- data/lib/remix/version.rb +1 -1
- data/test/test.rb +4 -1
- data/test/test_with_object2module.rb +162 -0
- metadata +6 -5
data/Rakefile
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
-
|
1
|
+
dlext = Config::CONFIG['DLEXT']
|
2
|
+
direc = File.dirname(__FILE__)
|
2
3
|
|
3
4
|
require 'rake/clean'
|
4
5
|
require 'rake/gempackagetask'
|
6
|
+
require "#{direc}/lib/remix/version"
|
5
7
|
|
6
|
-
require 'lib/remix/version'
|
7
8
|
|
8
|
-
|
9
|
+
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o", "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "ext/**/*.def", "ext/**/*.pdb")
|
10
|
+
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
9
11
|
|
10
|
-
|
11
|
-
CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
12
|
-
|
13
|
-
specification = Gem::Specification.new do |s|
|
12
|
+
def apply_spec_defaults(s)
|
14
13
|
s.name = "remix"
|
15
14
|
s.summary = "Ruby modules re-mixed and remastered"
|
16
15
|
s.version = Remix::VERSION
|
@@ -19,19 +18,45 @@ specification = Gem::Specification.new do |s|
|
|
19
18
|
s.email = 'jrmair@gmail.com'
|
20
19
|
s.description = s.summary
|
21
20
|
s.require_path = 'lib'
|
22
|
-
#s.platform = Gem::Platform::RUBY
|
23
|
-
s.platform = 'i386-mswin32'
|
24
21
|
s.homepage = "http://banisterfiend.wordpress.com"
|
25
22
|
s.has_rdoc = 'yard'
|
23
|
+
s.files = FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb",
|
24
|
+
"test/*.rb", "CHANGELOG", "README.markdown", "Rakefile"].to_a
|
25
|
+
end
|
26
|
+
|
27
|
+
task :test do
|
28
|
+
sh "bacon -k #{direc}/test/test.rb"
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
[:mingw32, :mswin32].each do |v|
|
32
|
+
task v do
|
33
|
+
spec = Gem::Specification.new do |s|
|
34
|
+
apply_spec_defaults(s)
|
35
|
+
s.platform = "i386-#{v}"
|
36
|
+
s.files += FileList["lib/**/*.#{dlext}"].to_a
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
40
|
+
pkg.need_zip = false
|
41
|
+
pkg.need_tar = false
|
42
|
+
end
|
43
|
+
|
44
|
+
Rake::Task[:gem].invoke
|
45
|
+
end
|
32
46
|
end
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
task :ruby do
|
49
|
+
spec = Gem::Specification.new do |s|
|
50
|
+
apply_spec_defaults(s)
|
51
|
+
s.platform = Gem::Platform::RUBY
|
52
|
+
s.extensions = ["ext/remix/extconf.rb"]
|
53
|
+
end
|
54
|
+
|
55
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
56
|
+
pkg.need_zip = false
|
57
|
+
pkg.need_tar = false
|
58
|
+
end
|
59
|
+
|
60
|
+
Rake::Task[:gem].invoke
|
37
61
|
end
|
62
|
+
|
data/ext/remix/remix.c
CHANGED
@@ -14,16 +14,19 @@ VALUE rb_swap_modules(VALUE self, VALUE mod1, VALUE mod2);
|
|
14
14
|
rb_raise(rb_eTypeError, "Must be a Module or Class type."); \
|
15
15
|
} while(0)
|
16
16
|
|
17
|
+
#define Validate_Type(klass) \
|
18
|
+
do { \
|
19
|
+
if (TYPE(klass) != T_OBJECT && TYPE(klass) != T_CLASS && TYPE(klass) != T_MODULE && TYPE(klass) != T_ICLASS && \
|
20
|
+
TYPE(klass) != T_FALSE) \
|
21
|
+
rb_raise(rb_eTypeError, "Must be a T_MODULE, T_CLASS, T_ICLASS, T_OBJECT, or T_FALSE type."); \
|
22
|
+
} while(0)
|
23
|
+
|
17
24
|
/* a modified version of include_class_new from class.c */
|
18
25
|
static VALUE
|
19
26
|
j_class_new(VALUE module, VALUE sup)
|
20
27
|
{
|
21
28
|
VALUE klass = create_class(T_ICLASS, rb_cClass);
|
22
29
|
|
23
|
-
if (TYPE(module) == T_ICLASS) {
|
24
|
-
// klass = module;
|
25
|
-
}
|
26
|
-
|
27
30
|
if (!RCLASS_IV_TBL(module)) {
|
28
31
|
RCLASS_IV_TBL(module) = (struct st_table *)st_init_numtable();
|
29
32
|
}
|
@@ -106,8 +109,11 @@ get_source_module(VALUE mod)
|
|
106
109
|
case T_MODULE:
|
107
110
|
return mod;
|
108
111
|
break;
|
112
|
+
case T_OBJECT:
|
113
|
+
return rb_singleton_class(mod);
|
114
|
+
break;
|
109
115
|
default:
|
110
|
-
|
116
|
+
Validate_Type(mod);
|
111
117
|
}
|
112
118
|
|
113
119
|
/* never reached */
|
@@ -117,9 +123,8 @@ get_source_module(VALUE mod)
|
|
117
123
|
static VALUE
|
118
124
|
retrieve_before_mod(VALUE m, VALUE before)
|
119
125
|
{
|
120
|
-
|
121
|
-
|
122
|
-
|
126
|
+
Validate_Type(before);
|
127
|
+
|
123
128
|
VALUE k = get_source_module(RCLASS_SUPER(m));
|
124
129
|
while(k != before && m != 0 && m != rb_cObject) {
|
125
130
|
m = RCLASS_SUPER(m);
|
@@ -134,9 +139,8 @@ retrieve_before_mod(VALUE m, VALUE before)
|
|
134
139
|
static VALUE
|
135
140
|
retrieve_mod(VALUE m, VALUE after)
|
136
141
|
{
|
137
|
-
|
138
|
-
|
139
|
-
|
142
|
+
Validate_Type(after);
|
143
|
+
|
140
144
|
VALUE k = get_source_module(m);
|
141
145
|
while(k != after && m != 0 && m != rb_cObject) {
|
142
146
|
m = RCLASS_SUPER(m);
|
@@ -277,7 +281,7 @@ rb_classmod_include_p(VALUE mod, VALUE mod2)
|
|
277
281
|
{
|
278
282
|
VALUE p;
|
279
283
|
|
280
|
-
Enforce_Classmod(
|
284
|
+
Enforce_Classmod(mod);
|
281
285
|
|
282
286
|
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
|
283
287
|
if (BUILTIN_TYPE(p) == T_ICLASS) {
|
@@ -300,6 +304,9 @@ rb_uninclude(int argc, VALUE * argv, VALUE self)
|
|
300
304
|
VALUE mod1, recurse = Qfalse;
|
301
305
|
rb_scan_args(argc, argv, "11", &mod1, &recurse);
|
302
306
|
|
307
|
+
if (TYPE(mod1) == T_OBJECT)
|
308
|
+
mod1 = rb_singleton_class(mod1);
|
309
|
+
|
303
310
|
if (!RTEST(rb_classmod_include_p(self, mod1)))
|
304
311
|
rb_raise(rb_eArgError, "Module not found");
|
305
312
|
|
data/lib/1.8/remix.so
CHANGED
Binary file
|
data/lib/1.9/remix.so
CHANGED
Binary file
|
data/lib/remix/version.rb
CHANGED
data/test/test.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
direc = File.dirname(__FILE__)
|
1
2
|
require 'rubygems'
|
2
|
-
require
|
3
|
+
require "#{direc}/../lib/remix"
|
3
4
|
require 'bacon'
|
4
5
|
|
5
6
|
class Module
|
6
7
|
public :include, :remove_const
|
7
8
|
end
|
8
9
|
|
10
|
+
puts "testing Remix version #{Remix::VERSION}..."
|
11
|
+
|
9
12
|
describe 'Test basic remix functionality' do
|
10
13
|
before do
|
11
14
|
A = Module.new
|
@@ -0,0 +1,162 @@
|
|
1
|
+
direc = File.dirname(__FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bacon'
|
4
|
+
require 'object2module'
|
5
|
+
require "#{direc}/../lib/remix"
|
6
|
+
|
7
|
+
class Module
|
8
|
+
public :include, :remove_const
|
9
|
+
end
|
10
|
+
|
11
|
+
puts "testing Remix version #{Remix::VERSION} with Object2module version #{Object2module::VERSION}..."
|
12
|
+
|
13
|
+
describe Remix do
|
14
|
+
before do
|
15
|
+
class A
|
16
|
+
def hello
|
17
|
+
:a
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class B
|
22
|
+
def hello
|
23
|
+
:b
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module M
|
28
|
+
def m
|
29
|
+
:m
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
O = Object.new
|
34
|
+
class << O
|
35
|
+
def o
|
36
|
+
:o
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
C = Class.new
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
Object.remove_const(:A)
|
45
|
+
Object.remove_const(:B)
|
46
|
+
Object.remove_const(:C)
|
47
|
+
Object.remove_const(:M)
|
48
|
+
Object.remove_const(:O)
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'gen_include' do
|
52
|
+
it 'includes two classes and swaps them' do
|
53
|
+
C.gen_include A
|
54
|
+
C.gen_include B
|
55
|
+
C.new.hello.should == :b
|
56
|
+
C.swap_modules A, B
|
57
|
+
C.new.hello.should == :a
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'includes a class into a class and swaps them' do
|
61
|
+
A.gen_include B
|
62
|
+
C.gen_include A
|
63
|
+
C.new.hello.should == :a
|
64
|
+
C.swap_modules A, B
|
65
|
+
C.new.hello.should == :b
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'unincludes a gen_included class' do
|
69
|
+
C.gen_include A
|
70
|
+
C.new.hello.should == :a
|
71
|
+
C.uninclude A
|
72
|
+
lambda { C.new.hello }.should.raise NameError
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'recursively unincludes a gen_included class' do
|
76
|
+
A.gen_include B
|
77
|
+
C.gen_include A
|
78
|
+
C.new.hello.should == :a
|
79
|
+
C.ancestors.should[0..2] == [C, A, B]
|
80
|
+
C.uninclude A, true
|
81
|
+
C.ancestors.should[0..1] == [C, Object]
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'unincludes a singleton class' do
|
85
|
+
o = Object.new
|
86
|
+
class << o
|
87
|
+
def hello
|
88
|
+
:o
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
C.gen_include o
|
93
|
+
C.new.hello.should == :o
|
94
|
+
C.uninclude C.ancestors[1]
|
95
|
+
lambda { C.new.hello }.should.raise NameError
|
96
|
+
C.ancestors[1].should == Object
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'gen_extend' do
|
101
|
+
it 'extends two classes into an object and swaps them' do
|
102
|
+
o = Object.new
|
103
|
+
o.gen_extend A, B
|
104
|
+
o.hello.should == :a
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'unextends a class from an object' do
|
108
|
+
o = Object.new
|
109
|
+
o.gen_extend A
|
110
|
+
o.hello.should == :a
|
111
|
+
o.singleton_class.ancestors[0].should == A
|
112
|
+
o.unextend A
|
113
|
+
lambda { o.hello }.should.raise NameError
|
114
|
+
o.singleton_class.ancestors[0].should == Object
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'recursively unextends a class from an object' do
|
118
|
+
o = Object.new
|
119
|
+
A.gen_include B
|
120
|
+
o.gen_extend A
|
121
|
+
o.singleton_class.ancestors[0..2].should == [A, B, Object]
|
122
|
+
o.unextend A, true
|
123
|
+
o.singleton_class.ancestors.first.should == Object
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'unextends an object by object (not by singleton)' do
|
127
|
+
o = Object.new
|
128
|
+
def o.hello
|
129
|
+
:o
|
130
|
+
end
|
131
|
+
|
132
|
+
n = Object.new
|
133
|
+
n.gen_extend o
|
134
|
+
n.hello.should == :o
|
135
|
+
n.unextend o
|
136
|
+
lambda { n.hello }.should.raise NameError
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
it 'recursively unextends a singleton class gen_extended into another singleton class' do
|
141
|
+
o = Object.new
|
142
|
+
def o.hello
|
143
|
+
:o
|
144
|
+
end
|
145
|
+
|
146
|
+
n = Object.new
|
147
|
+
def n.hello
|
148
|
+
:n
|
149
|
+
end
|
150
|
+
|
151
|
+
n.gen_extend o
|
152
|
+
|
153
|
+
v = Object.new
|
154
|
+
v.gen_extend n
|
155
|
+
|
156
|
+
v.hello.should == :n
|
157
|
+
v.unextend n.singleton_class, true
|
158
|
+
lambda { v.hello }.should.raise NameError
|
159
|
+
v.singleton_class.ancestors.first.should == Object
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
10
10
|
platform: i386-mswin32
|
11
11
|
authors:
|
12
12
|
- John Mair (banisterfiend)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-01 00:00:00 +13:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -27,8 +27,6 @@ extensions: []
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
-
- lib/1.9/remix.so
|
31
|
-
- lib/1.8/remix.so
|
32
30
|
- ext/remix/extconf.rb
|
33
31
|
- ext/remix/compat.h
|
34
32
|
- ext/remix/remix.c
|
@@ -36,9 +34,12 @@ files:
|
|
36
34
|
- lib/remix/version.rb
|
37
35
|
- lib/remix.rb
|
38
36
|
- test/test.rb
|
37
|
+
- test/test_with_object2module.rb
|
39
38
|
- CHANGELOG
|
40
39
|
- README.markdown
|
41
40
|
- Rakefile
|
41
|
+
- lib/1.8/remix.so
|
42
|
+
- lib/1.9/remix.so
|
42
43
|
has_rdoc: yard
|
43
44
|
homepage: http://banisterfiend.wordpress.com
|
44
45
|
licenses: []
|