duelinmarkers-renum 1.1.0 → 1.2.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -22,7 +22,7 @@ module Renum
22
22
  value = klass.new(value_name)
23
23
  klass.const_set(value_name, value)
24
24
  value.instance_eval &instance_block if instance_block
25
- value.init *init_args if init_args.any?
25
+ value.init *init_args if value.respond_to? :init
26
26
  end
27
27
  teardown_from_definition_in_block(klass)
28
28
  else
data/renum.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{renum}
5
- s.version = "1.1.0"
5
+ s.version = "1.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Hume"]
9
- s.date = %q{2009-07-07}
9
+ s.date = %q{2009-09-01}
10
10
  s.description = %q{provides a readable but terse enum facility for Ruby}
11
11
  s.email = %q{duelin.markers@gmail.com}
12
12
  s.extra_rdoc_files = [
data/spec/renum_spec.rb CHANGED
@@ -65,11 +65,12 @@ enum :Size do
65
65
  Small("Really really tiny")
66
66
  Medium("Sort of in the middle")
67
67
  Large("Quite big")
68
+ Unknown()
68
69
 
69
70
  attr_reader :description
70
71
 
71
- def init description
72
- @description = description
72
+ def init description = nil
73
+ @description = description || "NO DESCRIPTION GIVEN"
73
74
  end
74
75
  end
75
76
 
@@ -80,12 +81,12 @@ enum :HairColor do
80
81
  end
81
82
 
82
83
  describe "enum with no values array and values declared in the block" do
83
- it "provides an alternative means of declaring values where extra information can be provided for initialization" do
84
+ it "provides another way to declare values where an init method can take extra params" do
84
85
  Size::Small.description.should == "Really really tiny"
85
86
  end
86
87
 
87
88
  it "works the same as the basic form with respect to ordering" do
88
- Size.values.should == [Size::Small, Size::Medium, Size::Large]
89
+ Size.values.should == [Size::Small, Size::Medium, Size::Large, Size::Unknown]
89
90
  end
90
91
 
91
92
  it "responds as expected to arbitrary method calls, in spite of using method_missing for value definition" do
@@ -95,6 +96,10 @@ describe "enum with no values array and values declared in the block" do
95
96
  it "supports there being no extra data and no init() method defined, if you don't need them" do
96
97
  HairColor::BLONDE.name.should == "BLONDE"
97
98
  end
99
+
100
+ it "calls the init method even if no arguments are provided" do
101
+ Size::Unknown.description.should == "NO DESCRIPTION GIVEN"
102
+ end
98
103
  end
99
104
 
100
105
  enum :Rating do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duelinmarkers-renum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hume
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-07 00:00:00 -07:00
12
+ date: 2009-09-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15