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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46b4c4c4f5f5cce627f88c4c19607cc77bd23095
4
- data.tar.gz: db4d64a617533347040e9b0176fc968b95486f64
3
+ metadata.gz: 2d50d2731f00aceba47464bf8cbe73d4a91a01f1
4
+ data.tar.gz: 26bc3ed9869a9c39065ae635627232e5a1aadb19
5
5
  SHA512:
6
- metadata.gz: 46d4bd89347488975200454f7000cdd61459acf21ede9f1c1ee07858fb4437fdd9cfd032db08f9bc8680f0edb858f97b225b926b48acafccb0ee63289c5bcd25
7
- data.tar.gz: e8c496f34c5b983a5cea385eb1ad162e2b0ebf719540de12ffd481d24a10030c493c06aca5ee00e15176e0fd13992ed8c9bc15676c2aba526fbbfb68d8f99848
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.1.3)
10
- rspec (2.12.0)
11
- rspec-core (~> 2.12.0)
12
- rspec-expectations (~> 2.12.0)
13
- rspec-mocks (~> 2.12.0)
14
- rspec-core (2.12.1)
15
- rspec-expectations (2.12.0)
16
- diff-lcs (~> 1.1.3)
17
- rspec-mocks (2.12.0)
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
@@ -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.respond_to?(:enum_value?) and v.enum_value?
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
@@ -1,3 +1,3 @@
1
1
  class Enum
2
- VERSION = '1.7.1'
2
+ VERSION = '1.7.2'
3
3
  end
@@ -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 respond_to(:enum_value?)
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 respond_to(:enum_value?)
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 respond_to(:enum_value?)
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 be_enum_value and @record.color.should be_blue
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.should_not respond_to(:enum_value?) and @record.color.should == 3
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 respond_to(:enum_value?)
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 respond_to(:enum_value?)
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 be_enum_value and @record.color.should be_blue
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.should_not respond_to(:enum_value?) and @record.color.should == 3
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yinum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Niv