ruby-enum 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/ruby-enum/enum.rb +3 -8
- data/lib/ruby-enum/version.rb +1 -1
- data/pkg/ruby-enum-0.7.0.gem +0 -0
- data/pkg/ruby-enum-0.7.1.gem +0 -0
- data/spec/ruby-enum/enum_spec.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff88e3a9dd8dc2188f929ad3e84cc86a0fd313c3
|
4
|
+
data.tar.gz: 66f8dd956d3eeb27fd2457c56f76a144c30a1518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b4196088d70c8cfabf6e2adfe15a99744343dabc8b4275b26340314186a755375efac54900d1b4e61957ed13d7e818fcac860fd7dac6a04350efdbbf479f79d
|
7
|
+
data.tar.gz: 409a290aa4ed199c6ec84fba971b33b4e176625c400ba313de111d7dacb3180f32a5ba83ace957f7e01875483b00de50ea7c9f884483f6df0b1d4d6c295c9685
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### 0.7.1 (23/2/2017)
|
2
|
+
|
3
|
+
* [#16](https://github.com/dblock/ruby-enum/pull/16): Replaces const_missing method in favor of const_set - [@laertispappas](https://github.com/laertispappas).
|
4
|
+
|
1
5
|
### 0.7.0 (21/2/2017)
|
2
6
|
|
3
7
|
* [#3](https://github.com/dblock/ruby-enum/pull/13): Adds support for sub classing an Enum - [@laertispappas](https://github.com/laertispappas).
|
data/Gemfile.lock
CHANGED
data/lib/ruby-enum/enum.rb
CHANGED
@@ -30,6 +30,8 @@ module Ruby
|
|
30
30
|
new_instance = new(key, value)
|
31
31
|
@_enum_hash[key] = new_instance
|
32
32
|
@_enums_by_value[value] = new_instance
|
33
|
+
|
34
|
+
const_set key, value
|
33
35
|
end
|
34
36
|
|
35
37
|
def validate_key!(key)
|
@@ -45,14 +47,7 @@ module Ruby
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def const_missing(key)
|
48
|
-
|
49
|
-
if enum_instance
|
50
|
-
@_enum_hash[key].value
|
51
|
-
elsif superclass.instance_variable_get(:@_enum_hash)
|
52
|
-
superclass.send(:const_missing, key)
|
53
|
-
else
|
54
|
-
raise Ruby::Enum::Errors::UninitializedConstantError, name: name, key: key
|
55
|
-
end
|
50
|
+
raise Ruby::Enum::Errors::UninitializedConstantError, name: name, key: key
|
56
51
|
end
|
57
52
|
|
58
53
|
# Iterate over all enumerated values.
|
data/lib/ruby-enum/version.rb
CHANGED
data/pkg/ruby-enum-0.7.0.gem
CHANGED
Binary file
|
Binary file
|
data/spec/ruby-enum/enum_spec.rb
CHANGED
@@ -169,4 +169,12 @@ describe Ruby::Enum do
|
|
169
169
|
expect { EmptyEnums::ORANGE }.to raise_error Ruby::Enum::Errors::UninitializedConstantError
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
173
|
+
context 'when a constant is redefined in a global namespace' do
|
174
|
+
before do
|
175
|
+
RED = 'black'.freeze
|
176
|
+
end
|
177
|
+
|
178
|
+
it { expect(Colors::RED).to eq 'red' }
|
179
|
+
end
|
172
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/ruby-enum/version.rb
|
49
49
|
- lib/ruby_enum.rb
|
50
50
|
- pkg/ruby-enum-0.7.0.gem
|
51
|
+
- pkg/ruby-enum-0.7.1.gem
|
51
52
|
- ruby-enum.gemspec
|
52
53
|
- spec/ruby-enum/enum_spec.rb
|
53
54
|
- spec/ruby-enum/version_spec.rb
|