prepend 0.1.0-i386-mswin32 → 0.1.5-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -1
- data/Rakefile +2 -2
- data/ext/prepend/prepend.c +14 -2
- data/lib/1.8/prepend.so +0 -0
- data/lib/1.9/prepend.so +0 -0
- data/lib/prepend/version.rb +1 -1
- data/test/test.rb +45 -0
- metadata +5 -7
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ specification = Gem::Specification.new do |s|
|
|
21
21
|
s.email = 'jrmair@gmail.com'
|
22
22
|
s.description = s.summary
|
23
23
|
s.require_path = 'lib'
|
24
|
-
s.platform = Gem::Platform::RUBY
|
24
|
+
# s.platform = Gem::Platform::RUBY
|
25
25
|
s.platform = 'i386-mswin32'
|
26
26
|
s.homepage = "http://banisterfiend.wordpress.com"
|
27
27
|
s.has_rdoc = false
|
@@ -30,7 +30,7 @@ specification = Gem::Specification.new do |s|
|
|
30
30
|
s.files = ["Rakefile", "README.markdown", "CHANGELOG",
|
31
31
|
"lib/prepend.rb", "lib/prepend/version.rb"] +
|
32
32
|
["lib/1.9/prepend.so", "lib/1.8/prepend.so"] +
|
33
|
-
FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c"].to_a
|
33
|
+
FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "test/*.rb"].to_a
|
34
34
|
end
|
35
35
|
|
36
36
|
Rake::GemPackageTask.new(specification) do |package|
|
data/ext/prepend/prepend.c
CHANGED
@@ -12,7 +12,13 @@ class_mod_wrapper_to_s(VALUE self)
|
|
12
12
|
static VALUE
|
13
13
|
klass_to_s(VALUE self)
|
14
14
|
{
|
15
|
-
|
15
|
+
VALUE name;
|
16
|
+
if (NIL_P(rb_mod_name(self)))
|
17
|
+
name = rb_str_new2("Anon");
|
18
|
+
else
|
19
|
+
name = rb_mod_name(self);
|
20
|
+
|
21
|
+
return rb_str_concat(name, rb_str_new2("*"));
|
16
22
|
}
|
17
23
|
|
18
24
|
static VALUE
|
@@ -20,6 +26,7 @@ rb_prepend_module(VALUE klass, VALUE module)
|
|
20
26
|
{
|
21
27
|
/* create wrapper module to hold current class's M_TBL */
|
22
28
|
VALUE class_mod_wrapper = rb_module_new();
|
29
|
+
VALUE name;
|
23
30
|
|
24
31
|
/* clear the default M_TBL already allocated for the new wrapper module */
|
25
32
|
st_free_table(RCLASS_M_TBL(class_mod_wrapper));
|
@@ -28,7 +35,12 @@ rb_prepend_module(VALUE klass, VALUE module)
|
|
28
35
|
RCLASS_M_TBL(class_mod_wrapper) = RCLASS_M_TBL(klass);
|
29
36
|
|
30
37
|
/* store name of current class in wrapper module for use by #to_s and #inspect */
|
31
|
-
|
38
|
+
if (NIL_P(rb_mod_name(klass)))
|
39
|
+
name = rb_str_new2("Anon");
|
40
|
+
else
|
41
|
+
name = rb_mod_name(klass);
|
42
|
+
|
43
|
+
rb_iv_set(class_mod_wrapper, "__class_name__", name);
|
32
44
|
|
33
45
|
/* set current class's #to_s to return ClassName* */
|
34
46
|
rb_define_singleton_method(klass, "to_s", klass_to_s, 0);
|
data/lib/1.8/prepend.so
CHANGED
Binary file
|
data/lib/1.9/prepend.so
CHANGED
Binary file
|
data/lib/prepend/version.rb
CHANGED
data/test/test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
direc = File.dirname(__FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require "#{direc}/../lib/prepend"
|
4
|
+
require 'bacon'
|
5
|
+
|
6
|
+
describe 'prepend' do
|
7
|
+
before do
|
8
|
+
@m1 = Module.new {
|
9
|
+
def hello
|
10
|
+
:hello
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should make prepend a method on Module' do
|
16
|
+
Module.method_defined?(:prepend).should.equal true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should make module methods have precedence over class instance methods' do
|
20
|
+
c = Class.new {
|
21
|
+
def hello
|
22
|
+
:bye
|
23
|
+
end
|
24
|
+
}
|
25
|
+
c.new.hello.should.equal :bye
|
26
|
+
c.send(:prepend, @m1)
|
27
|
+
c.new.hello.should.equal :hello
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should make module 1 instance methods have precedence over module 2 instance methods' do
|
31
|
+
m2 = Module.new {
|
32
|
+
def hello
|
33
|
+
:evil
|
34
|
+
end
|
35
|
+
}
|
36
|
+
m2.send(:prepend, @m1)
|
37
|
+
|
38
|
+
c = Class.new
|
39
|
+
c.send(:prepend, m2)
|
40
|
+
|
41
|
+
c.new.hello.should.equal :hello
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prepend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
11
10
|
platform: i386-mswin32
|
12
11
|
authors:
|
13
12
|
- John Mair (banisterfiend)
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-29 00:00:00 +13:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -38,7 +37,8 @@ files:
|
|
38
37
|
- ext/prepend/extconf.rb
|
39
38
|
- ext/prepend/compat.h
|
40
39
|
- ext/prepend/prepend.c
|
41
|
-
|
40
|
+
- test/test.rb
|
41
|
+
has_rdoc: true
|
42
42
|
homepage: http://banisterfiend.wordpress.com
|
43
43
|
licenses: []
|
44
44
|
|
@@ -52,7 +52,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
55
|
segments:
|
57
56
|
- 0
|
58
57
|
version: "0"
|
@@ -61,7 +60,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
60
|
requirements:
|
62
61
|
- - ">="
|
63
62
|
- !ruby/object:Gem::Version
|
64
|
-
hash: 3
|
65
63
|
segments:
|
66
64
|
- 0
|
67
65
|
version: "0"
|