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 CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/enumz.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "enumz"
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["obie quelland"]
@@ -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| mod.const_set(k.to_s.capitalize, 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.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: 3518699016868134358
133
+ hash: -11249047347688538
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  none: false
136
136
  requirements: