yinum 1.7.1 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +9 -9
- data/lib/enum/enum_value.rb +6 -4
- data/lib/enum/helpers/enum_attribute.rb +1 -1
- data/lib/enum/version.rb +1 -1
- data/spec/lib/enum/helpers/enum_attribute_spec.rb +10 -7
- data/spec/lib/enum/helpers/enum_column_spec.rb +8 -4
- 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: 2d50d2731f00aceba47464bf8cbe73d4a91a01f1
|
4
|
+
data.tar.gz: 26bc3ed9869a9c39065ae635627232e5a1aadb19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857019820b29df357921fe69c2cc006d77af3969f2f9deabee50c9347bc9263680e8fac84cbda800c04a647a8feb779d9807343bafc2f4bd1406ff875fcd78d4
|
7
|
+
data.tar.gz: ba7a24c3960486e6d7766da19fa4434acd8005792db599bb883afa843372b96cee4205e07c8ac6b466a1f03a81d3832b90274508a398f256d2071787a69139b7
|
data/CHANGELOG.md
CHANGED
@@ -5,5 +5,10 @@
|
|
5
5
|
|
6
6
|
**1.7.1**
|
7
7
|
* Remove usage of `reverse_merge`, apparently doesn't exist in Ruby core.
|
8
|
-
* `attr_enum`'s writer does not pass an EnumValue to the super.
|
9
|
-
* Fix `EnumValue#t` specs (mocking `I18n`).
|
8
|
+
* `attr_enum`'s writer does not pass an `EnumValue` to the super.
|
9
|
+
* Fix `EnumValue#t` specs (mocking `I18n`).
|
10
|
+
|
11
|
+
**1.7.2**
|
12
|
+
* Added `Object#enum_value?` to fix `attr_enum`'s writer, `BasicObject` does
|
13
|
+
not have `respond_to?`.
|
14
|
+
* Fix specs that didn't catch above bug.
|
data/Gemfile.lock
CHANGED
@@ -6,15 +6,15 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
10
|
-
rspec (2.
|
11
|
-
rspec-core (~> 2.
|
12
|
-
rspec-expectations (~> 2.
|
13
|
-
rspec-mocks (~> 2.
|
14
|
-
rspec-core (2.
|
15
|
-
rspec-expectations (2.
|
16
|
-
diff-lcs (
|
17
|
-
rspec-mocks (2.
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rspec (2.14.1)
|
11
|
+
rspec-core (~> 2.14.0)
|
12
|
+
rspec-expectations (~> 2.14.0)
|
13
|
+
rspec-mocks (~> 2.14.0)
|
14
|
+
rspec-core (2.14.8)
|
15
|
+
rspec-expectations (2.14.5)
|
16
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
17
|
+
rspec-mocks (2.14.6)
|
18
18
|
|
19
19
|
PLATFORMS
|
20
20
|
ruby
|
data/lib/enum/enum_value.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
class Object
|
2
|
+
def enum_value?
|
3
|
+
false
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
1
7
|
class Enum::EnumValue < BasicObject
|
2
8
|
attr_reader :enum, :name, :value
|
3
9
|
|
@@ -70,10 +76,6 @@ class Enum::EnumValue < BasicObject
|
|
70
76
|
end
|
71
77
|
end
|
72
78
|
|
73
|
-
def methods
|
74
|
-
super + @value.methods
|
75
|
-
end
|
76
|
-
|
77
79
|
def method_missing(method, *args, &block)
|
78
80
|
match = method.to_s.match(/^(.+)\?$/)
|
79
81
|
enum_name = match[1].to_sym if match
|
@@ -22,7 +22,7 @@ module Enum::Helpers::EnumAttribute
|
|
22
22
|
define_method(attr) { v = super(); (v.nil? or not e.values.include?(v)) ? Enum::EnumValue.new(e, v) : e[v] }
|
23
23
|
# attribute writer
|
24
24
|
define_method("#{attr}=") do |v|
|
25
|
-
if v.
|
25
|
+
if v.enum_value?
|
26
26
|
super(v.value)
|
27
27
|
elsif v.nil?
|
28
28
|
super(v)
|
data/lib/enum/version.rb
CHANGED
@@ -51,19 +51,19 @@ def enum_attribute_specs
|
|
51
51
|
specify "nil" do
|
52
52
|
@record.color = nil
|
53
53
|
@record[:color].should be_nil
|
54
|
-
@record[:color].should_not
|
54
|
+
@record[:color].should_not be_enum_value
|
55
55
|
end
|
56
56
|
|
57
57
|
specify "name" do
|
58
58
|
@record.color = :red
|
59
|
-
@record[:color] == 1
|
60
|
-
@record[:color].should_not
|
59
|
+
@record[:color].should == 1
|
60
|
+
@record[:color].should_not be_enum_value
|
61
61
|
end
|
62
62
|
|
63
63
|
specify "value" do
|
64
64
|
@record.color = 2
|
65
|
-
@record[:color] == 2
|
66
|
-
@record[:color].should_not
|
65
|
+
@record[:color].should == 2
|
66
|
+
@record[:color].should_not be_enum_value
|
67
67
|
end
|
68
68
|
|
69
69
|
specify "invalid" do
|
@@ -75,16 +75,19 @@ def enum_attribute_specs
|
|
75
75
|
specify "nil" do
|
76
76
|
@record[:color] = nil
|
77
77
|
@record.color.should be_nil
|
78
|
+
@record.color.should be_enum_value
|
78
79
|
end
|
79
80
|
|
80
81
|
specify "value" do
|
81
82
|
@record[:color] = 2
|
82
|
-
@record.color.should
|
83
|
+
@record.color.should be_blue
|
84
|
+
@record.color.should be_enum_value
|
83
85
|
end
|
84
86
|
|
85
87
|
specify "invalid" do
|
86
88
|
@record[:color] = 3
|
87
|
-
@record.color.
|
89
|
+
@record.color.should == 3
|
90
|
+
@record.color.should be_enum_value
|
88
91
|
end
|
89
92
|
end # context "getter"
|
90
93
|
end # context "attribute"
|
@@ -71,18 +71,19 @@ def enum_columns_attribute_specs
|
|
71
71
|
specify "nil" do
|
72
72
|
@record.color = nil
|
73
73
|
@record[:color].should be_nil
|
74
|
+
@record[:color].should_not be_enum_value
|
74
75
|
end
|
75
76
|
|
76
77
|
specify "name" do
|
77
78
|
@record.color = :red
|
78
79
|
@record[:color].should == 1
|
79
|
-
@record[:color].should_not
|
80
|
+
@record[:color].should_not be_enum_value
|
80
81
|
end
|
81
82
|
|
82
83
|
specify "value" do
|
83
84
|
@record.color = 2
|
84
85
|
@record[:color].should == 2
|
85
|
-
@record[:color].should_not
|
86
|
+
@record[:color].should_not be_enum_value
|
86
87
|
end
|
87
88
|
|
88
89
|
specify "invalid" do
|
@@ -94,16 +95,19 @@ def enum_columns_attribute_specs
|
|
94
95
|
specify "nil" do
|
95
96
|
@record[:color] = nil
|
96
97
|
@record.color.should be_nil
|
98
|
+
@record.color.should be_enum_value
|
97
99
|
end
|
98
100
|
|
99
101
|
specify "value" do
|
100
102
|
@record[:color] = 2
|
101
|
-
@record.color.should
|
103
|
+
@record.color.should be_blue
|
104
|
+
@record.color.should be_enum_value
|
102
105
|
end
|
103
106
|
|
104
107
|
specify "invalid" do
|
105
108
|
@record[:color] = 3
|
106
|
-
@record.color.
|
109
|
+
@record.color.should == 3
|
110
|
+
@record.color.should be_enum_value
|
107
111
|
end
|
108
112
|
end # context "getter"
|
109
113
|
end # context "attribute"
|