interchangeable 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/interchangeable.rb +4 -4
- data/lib/interchangeable/version.rb +1 -1
- data/spec/interchangeable_spec.rb +14 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bcdfc0e991f5e031d0aaf71b7b400ef9fbd1898
|
4
|
+
data.tar.gz: ad3ab4c86e1d49bc83c77bfc1a8d863650839455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfd378812d261597c0ac4687a6cd042213179249d74c85c1ec6a840b904a522a7b99c86cc9b2fdb503cadc11d1cd752ac5e9d79c481d17d2aece003ee8a0196
|
7
|
+
data.tar.gz: 0c4153e30f694cc19c61aeeba39ea2cb541d6ff429ecc980883892c3b290146d7d9f3a237771b358e94605231fcfa8ba10c630946311770a36e661b1e8ba92a2
|
data/lib/interchangeable.rb
CHANGED
@@ -11,7 +11,7 @@ class Class
|
|
11
11
|
@interchangeable_description = nil
|
12
12
|
entry = Struct.new(:method_name, :target, :implemented, :default, :description)
|
13
13
|
.new(args[0], self, false, false, description)
|
14
|
-
Interchangeable.
|
14
|
+
Interchangeable.methods << entry
|
15
15
|
if block
|
16
16
|
Interchangeable.define self, args[0], &block
|
17
17
|
entry.default = true
|
@@ -23,8 +23,8 @@ module Interchangeable
|
|
23
23
|
|
24
24
|
class << self
|
25
25
|
|
26
|
-
attr_accessor :
|
27
|
-
def
|
26
|
+
attr_accessor :methods
|
27
|
+
def methods
|
28
28
|
@settings ||= []
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ module Interchangeable
|
|
32
32
|
the_class.instance_eval do
|
33
33
|
define_method method_name, &block
|
34
34
|
end
|
35
|
-
entry = Interchangeable.
|
35
|
+
entry = Interchangeable.methods.select { |x| x.target == the_class && x.method_name && method_name }.first
|
36
36
|
entry.implemented = true
|
37
37
|
entry.default = false
|
38
38
|
end
|
@@ -22,30 +22,30 @@ describe Interchangeable do
|
|
22
22
|
end")
|
23
23
|
end
|
24
24
|
|
25
|
-
describe "
|
25
|
+
describe "methods" do
|
26
26
|
|
27
27
|
it "should create an entry" do
|
28
|
-
Interchangeable.
|
28
|
+
Interchangeable.methods.count.must_equal 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should include the method name" do
|
32
|
-
Interchangeable.
|
32
|
+
Interchangeable.methods.first.method_name.must_equal example.method_name.to_sym
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return the target" do
|
36
|
-
Interchangeable.
|
36
|
+
Interchangeable.methods.first.target.must_equal eval(example.class_name)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should say that it is not implemented" do
|
40
|
-
Interchangeable.
|
40
|
+
Interchangeable.methods.first.implemented.must_equal false
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should say that it is not using the default implementation" do
|
44
|
-
Interchangeable.
|
44
|
+
Interchangeable.methods.first.default.must_equal false
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should include the description" do
|
48
|
-
Interchangeable.
|
48
|
+
Interchangeable.methods.first.description.must_equal example.description
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -65,11 +65,11 @@ describe Interchangeable do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should say that it is not implemented" do
|
68
|
-
Interchangeable.
|
68
|
+
Interchangeable.methods.first.implemented.must_equal true
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should say that it is not using the default implementation" do
|
72
|
-
Interchangeable.
|
72
|
+
Interchangeable.methods.first.default.must_equal false
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
@@ -130,11 +130,11 @@ describe Interchangeable do
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should say that it is implemented" do
|
133
|
-
Interchangeable.
|
133
|
+
Interchangeable.methods.first.implemented.must_equal true
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should say that it is using the default implementation" do
|
137
|
-
Interchangeable.
|
137
|
+
Interchangeable.methods.first.default.must_equal true
|
138
138
|
end
|
139
139
|
|
140
140
|
describe "and a new implementation is define elsewhere" do
|
@@ -155,7 +155,7 @@ describe Interchangeable do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should reset the default flag to false" do
|
158
|
-
Interchangeable.
|
158
|
+
Interchangeable.methods.first.default.must_equal false
|
159
159
|
end
|
160
160
|
|
161
161
|
end
|
@@ -180,8 +180,8 @@ describe Interchangeable do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should put the description on the first, but not the second" do
|
183
|
-
Interchangeable.
|
184
|
-
Interchangeable.
|
183
|
+
Interchangeable.methods[0].description.must_equal "That's a banana"
|
184
|
+
Interchangeable.methods[1].description.nil?.must_equal true
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|