maintain 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.markdown +168 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/lib/maintain/bitmask_value.rb +43 -0
- data/lib/maintain/integer_value.rb +7 -0
- data/lib/maintain/maintainer.rb +171 -0
- data/lib/maintain/value.rb +105 -0
- data/lib/maintain.rb +119 -0
- data/spec/active_record_spec.rb +67 -0
- data/spec/aggregates_spec.rb +35 -0
- data/spec/bitwise_spec.rb +83 -0
- data/spec/comparing_state_spec.rb +194 -0
- data/spec/defining_states_spec.rb +79 -0
- data/spec/hooks_spec.rb +44 -0
- data/spec/integer_spec.rb +22 -0
- data/spec/maintain_spec.rb +45 -0
- data/spec/object_spec.rb +7 -0
- data/spec/proxy_spec.rb +124 -0
- data/spec/setting_state_spec.rb +56 -0
- metadata +84 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# Comparing state values
|
2
|
+
|
3
|
+
require 'lib/maintain'
|
4
|
+
|
5
|
+
describe Maintain do
|
6
|
+
before :each do
|
7
|
+
class MaintainTest
|
8
|
+
attr_accessor :existant_attribute
|
9
|
+
extend Maintain
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "setting" do
|
14
|
+
describe "string states" do
|
15
|
+
before :each do
|
16
|
+
MaintainTest.maintain :state do
|
17
|
+
state :new
|
18
|
+
state :overdue
|
19
|
+
state :closed
|
20
|
+
end
|
21
|
+
@maintainer = MaintainTest.new
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should, you know, work" do
|
25
|
+
@maintainer.state = :new
|
26
|
+
@maintainer.state.should == :new
|
27
|
+
@maintainer.state = 'new'
|
28
|
+
@maintainer.state.should == :new
|
29
|
+
@maintainer.state = 0
|
30
|
+
@maintainer.state.should == :new
|
31
|
+
@maintainer.state = 'nada'
|
32
|
+
@maintainer.state.should be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "integer states" do
|
37
|
+
before :each do
|
38
|
+
MaintainTest.maintain :state do
|
39
|
+
state :new, 1
|
40
|
+
state :overdue, 2
|
41
|
+
state :closed, 3
|
42
|
+
end
|
43
|
+
@maintainer = MaintainTest.new
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should, you know, work" do
|
47
|
+
@maintainer.state = 1
|
48
|
+
@maintainer.state.should == :new
|
49
|
+
@maintainer.state = 'new'
|
50
|
+
@maintainer.state.should == :new
|
51
|
+
@maintainer.state = :new
|
52
|
+
@maintainer.state.should == :new
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maintain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Flip Sasser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-19 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "\n Maintain is a simple state machine mixin for Ruby objects. It supports comparisons, bitmasks,\n and hooks that really work. It can be used for multiple attributes and will always do its best to\n stay out of your way and let your code drive the machine, and not vice versa.\n "
|
17
|
+
email: flip@x451.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.markdown
|
24
|
+
files:
|
25
|
+
- .gitignore
|
26
|
+
- README.markdown
|
27
|
+
- Rakefile
|
28
|
+
- VERSION
|
29
|
+
- lib/maintain.rb
|
30
|
+
- lib/maintain/bitmask_value.rb
|
31
|
+
- lib/maintain/integer_value.rb
|
32
|
+
- lib/maintain/maintainer.rb
|
33
|
+
- lib/maintain/value.rb
|
34
|
+
- spec/active_record_spec.rb
|
35
|
+
- spec/aggregates_spec.rb
|
36
|
+
- spec/bitwise_spec.rb
|
37
|
+
- spec/comparing_state_spec.rb
|
38
|
+
- spec/defining_states_spec.rb
|
39
|
+
- spec/hooks_spec.rb
|
40
|
+
- spec/integer_spec.rb
|
41
|
+
- spec/maintain_spec.rb
|
42
|
+
- spec/object_spec.rb
|
43
|
+
- spec/proxy_spec.rb
|
44
|
+
- spec/setting_state_spec.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/flipsasser/maintain
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: A Ruby state machine that lets your code do the driving
|
73
|
+
test_files:
|
74
|
+
- spec/active_record_spec.rb
|
75
|
+
- spec/aggregates_spec.rb
|
76
|
+
- spec/bitwise_spec.rb
|
77
|
+
- spec/comparing_state_spec.rb
|
78
|
+
- spec/defining_states_spec.rb
|
79
|
+
- spec/hooks_spec.rb
|
80
|
+
- spec/integer_spec.rb
|
81
|
+
- spec/maintain_spec.rb
|
82
|
+
- spec/object_spec.rb
|
83
|
+
- spec/proxy_spec.rb
|
84
|
+
- spec/setting_state_spec.rb
|