enumz 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/enumz.gemspec +1 -1
- data/lib/enumz/enumz_factory.rb +4 -1
- data/spec/enum_spec.rb +4 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/enumz.gemspec
CHANGED
data/lib/enumz/enumz_factory.rb
CHANGED
@@ -57,7 +57,10 @@ module EnumzFactory
|
|
57
57
|
mod.instance_variable_set('@options', options)
|
58
58
|
|
59
59
|
# add a constant for each enum name/value
|
60
|
-
data_elements.each { |k,v|
|
60
|
+
data_elements.each { |k,v|
|
61
|
+
raise NameError, "#{k.inspect} is not a valid enum name!" unless /\A[a-zA-Z]/ =~ k.to_s
|
62
|
+
mod.const_set(k.to_s.capitalize, v)
|
63
|
+
}
|
61
64
|
|
62
65
|
# remove all unnecessary defacto ruby module methods
|
63
66
|
# in order to avoid potential conflicts with enum names
|
data/spec/enum_spec.rb
CHANGED
@@ -61,6 +61,10 @@ describe Enumz do
|
|
61
61
|
expect { ArrayColors.invisible }.to raise_error NoMethodError
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'should raise an exception if an invalid enum name is provided' do
|
65
|
+
expect { ExceptionsEnum.enum :ages_enum, {:'20_years' => 20} }.to raise_error NameError
|
66
|
+
end
|
67
|
+
|
64
68
|
it 'should raise an exception if a duplicate enum value is supplied' do
|
65
69
|
expect { ExceptionsEnum.enum :test_enum, {:yellow => 1, :green => 2, :blue => 1}}.to raise_error ArgumentError
|
66
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
segments:
|
132
132
|
- 0
|
133
|
-
hash:
|
133
|
+
hash: -11249047347688538
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
135
|
none: false
|
136
136
|
requirements:
|