maintain 0.1.3 → 0.1.4
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 +1 -1
- data/lib/maintain/value.rb +9 -0
- data/maintain.gemspec +3 -5
- data/spec/comparing_state_spec.rb +26 -0
- data/spec/setting_state_spec.rb +1 -0
- metadata +12 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/maintain/value.rb
CHANGED
@@ -20,6 +20,11 @@ module Maintain
|
|
20
20
|
compare_value == compare_value_for(value)
|
21
21
|
end
|
22
22
|
|
23
|
+
def ===(value)
|
24
|
+
raise "#{compare_value} #{compare_value_for(value)}"
|
25
|
+
(compare_value == compare_value_for(value)) || super
|
26
|
+
end
|
27
|
+
|
23
28
|
def class
|
24
29
|
value.class
|
25
30
|
end
|
@@ -33,6 +38,10 @@ module Maintain
|
|
33
38
|
value.inspect
|
34
39
|
end
|
35
40
|
|
41
|
+
def name
|
42
|
+
@value.to_s
|
43
|
+
end
|
44
|
+
|
36
45
|
def nil?
|
37
46
|
value.nil?
|
38
47
|
end
|
data/maintain.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{maintain}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Flip Sasser"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-23}
|
13
13
|
s.description = %q{
|
14
14
|
Maintain is a simple state machine mixin for Ruby objects. It supports comparisons, bitmasks,
|
15
15
|
and hooks that really work. It can be used for multiple attributes and will always do its best to
|
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
"README.markdown"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
|
-
".gitignore",
|
24
23
|
"README.markdown",
|
25
24
|
"Rakefile",
|
26
25
|
"VERSION",
|
@@ -29,7 +28,6 @@ Gem::Specification.new do |s|
|
|
29
28
|
"lib/maintain/integer_value.rb",
|
30
29
|
"lib/maintain/maintainer.rb",
|
31
30
|
"lib/maintain/value.rb",
|
32
|
-
"maintain.gemspec",
|
33
31
|
"spec/active_record_spec.rb",
|
34
32
|
"spec/aggregates_spec.rb",
|
35
33
|
"spec/bitwise_spec.rb",
|
@@ -45,7 +43,7 @@ Gem::Specification.new do |s|
|
|
45
43
|
s.homepage = %q{http://github.com/flipsasser/maintain}
|
46
44
|
s.rdoc_options = ["--charset=UTF-8"]
|
47
45
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = %q{1.3.
|
46
|
+
s.rubygems_version = %q{1.3.6}
|
49
47
|
s.summary = %q{A Ruby state machine that lets your code do the driving}
|
50
48
|
s.test_files = [
|
51
49
|
"spec/active_record_spec.rb",
|
@@ -128,6 +128,32 @@ describe Maintain do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
|
132
|
+
describe "identity comparison" do
|
133
|
+
before :each do
|
134
|
+
MaintainTest.maintain :state, :default => :new do
|
135
|
+
state :new, 1
|
136
|
+
state :overdue, 2
|
137
|
+
state :closed, 3
|
138
|
+
end
|
139
|
+
@maintainer = MaintainTest.new
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should work with case statements" do
|
143
|
+
result = case @maintainer.state
|
144
|
+
when :overdue
|
145
|
+
nil
|
146
|
+
when :closed
|
147
|
+
nil
|
148
|
+
when :new
|
149
|
+
"foo"
|
150
|
+
else
|
151
|
+
nil
|
152
|
+
end
|
153
|
+
result.should == "foo"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
131
157
|
describe "integer states" do
|
132
158
|
before :each do
|
133
159
|
MaintainTest.maintain :state, :default => :new do
|
data/spec/setting_state_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Flip Sasser
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-23 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -56,18 +61,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
61
|
requirements:
|
57
62
|
- - ">="
|
58
63
|
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
59
66
|
version: "0"
|
60
|
-
version:
|
61
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
68
|
requirements:
|
63
69
|
- - ">="
|
64
70
|
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
65
73
|
version: "0"
|
66
|
-
version:
|
67
74
|
requirements: []
|
68
75
|
|
69
76
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.3.
|
77
|
+
rubygems_version: 1.3.6
|
71
78
|
signing_key:
|
72
79
|
specification_version: 3
|
73
80
|
summary: A Ruby state machine that lets your code do the driving
|