state-fu 0.11.1
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/LICENSE +40 -0
- data/README.textile +293 -0
- data/Rakefile +114 -0
- data/lib/binding.rb +292 -0
- data/lib/event.rb +192 -0
- data/lib/executioner.rb +120 -0
- data/lib/hooks.rb +39 -0
- data/lib/interface.rb +132 -0
- data/lib/lathe.rb +538 -0
- data/lib/machine.rb +184 -0
- data/lib/method_factory.rb +243 -0
- data/lib/persistence.rb +116 -0
- data/lib/persistence/active_record.rb +34 -0
- data/lib/persistence/attribute.rb +47 -0
- data/lib/persistence/base.rb +100 -0
- data/lib/persistence/relaxdb.rb +23 -0
- data/lib/persistence/session.rb +7 -0
- data/lib/sprocket.rb +58 -0
- data/lib/state-fu.rb +56 -0
- data/lib/state.rb +48 -0
- data/lib/support/active_support_lite/array.rb +9 -0
- data/lib/support/active_support_lite/array/access.rb +60 -0
- data/lib/support/active_support_lite/array/conversions.rb +202 -0
- data/lib/support/active_support_lite/array/extract_options.rb +21 -0
- data/lib/support/active_support_lite/array/grouping.rb +109 -0
- data/lib/support/active_support_lite/array/random_access.rb +13 -0
- data/lib/support/active_support_lite/array/wrapper.rb +25 -0
- data/lib/support/active_support_lite/blank.rb +67 -0
- data/lib/support/active_support_lite/cattr_reader.rb +57 -0
- data/lib/support/active_support_lite/keys.rb +57 -0
- data/lib/support/active_support_lite/misc.rb +59 -0
- data/lib/support/active_support_lite/module.rb +1 -0
- data/lib/support/active_support_lite/module/delegation.rb +130 -0
- data/lib/support/active_support_lite/object.rb +9 -0
- data/lib/support/active_support_lite/string.rb +38 -0
- data/lib/support/active_support_lite/symbol.rb +16 -0
- data/lib/support/applicable.rb +41 -0
- data/lib/support/arrays.rb +197 -0
- data/lib/support/core_ext.rb +90 -0
- data/lib/support/exceptions.rb +106 -0
- data/lib/support/has_options.rb +16 -0
- data/lib/support/logger.rb +165 -0
- data/lib/support/methodical.rb +17 -0
- data/lib/support/no_stdout.rb +55 -0
- data/lib/support/plotter.rb +62 -0
- data/lib/support/vizier.rb +300 -0
- data/lib/tasks/spec_last.rake +55 -0
- data/lib/tasks/state_fu.rake +57 -0
- data/lib/transition.rb +338 -0
- data/lib/transition_query.rb +224 -0
- data/spec/custom_formatter.rb +49 -0
- data/spec/features/binding_and_transition_helper_mixin_spec.rb +111 -0
- data/spec/features/method_missing_only_once_spec.rb +28 -0
- data/spec/features/not_requirements_spec.rb +118 -0
- data/spec/features/plotter_spec.rb +97 -0
- data/spec/features/shared_log_spec.rb +7 -0
- data/spec/features/singleton_machine_spec.rb +39 -0
- data/spec/features/state_and_array_options_accessor_spec.rb +47 -0
- data/spec/features/transition_boolean_comparison_spec.rb +101 -0
- data/spec/helper.rb +13 -0
- data/spec/integration/active_record_persistence_spec.rb +202 -0
- data/spec/integration/binding_extension_spec.rb +41 -0
- data/spec/integration/class_accessor_spec.rb +117 -0
- data/spec/integration/event_definition_spec.rb +74 -0
- data/spec/integration/example_01_document_spec.rb +133 -0
- data/spec/integration/example_02_string_spec.rb +88 -0
- data/spec/integration/instance_accessor_spec.rb +97 -0
- data/spec/integration/lathe_extension_spec.rb +67 -0
- data/spec/integration/machine_duplication_spec.rb +101 -0
- data/spec/integration/relaxdb_persistence_spec.rb +97 -0
- data/spec/integration/requirement_reflection_spec.rb +270 -0
- data/spec/integration/state_definition_spec.rb +163 -0
- data/spec/integration/transition_spec.rb +1033 -0
- data/spec/spec.opts +9 -0
- data/spec/spec_helper.rb +132 -0
- data/spec/state_fu_spec.rb +948 -0
- data/spec/units/binding_spec.rb +192 -0
- data/spec/units/event_spec.rb +214 -0
- data/spec/units/exceptions_spec.rb +82 -0
- data/spec/units/lathe_spec.rb +570 -0
- data/spec/units/machine_spec.rb +229 -0
- data/spec/units/method_factory_spec.rb +366 -0
- data/spec/units/sprocket_spec.rb +69 -0
- data/spec/units/state_spec.rb +59 -0
- metadata +171 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
##
|
4
|
+
##
|
5
|
+
##
|
6
|
+
|
7
|
+
describe "Common features / functionality for StateFu::State & StateFu::Event" do
|
8
|
+
|
9
|
+
include MySpecHelper
|
10
|
+
Sprocket = StateFu::Sprocket
|
11
|
+
before do
|
12
|
+
@machine = StateFu::Machine.new
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "calling Sprocket.new" do
|
16
|
+
it "should create a new Sprocket given valid args" do
|
17
|
+
sprocket = Sprocket.new(@machine, :flux, { :meta => :doodle })
|
18
|
+
sprocket.should be_kind_of( Sprocket )
|
19
|
+
sprocket.name.should == :flux
|
20
|
+
sprocket.options[:meta].should == :doodle
|
21
|
+
sprocket.machine.should == @machine
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "instance methods" do
|
26
|
+
before do
|
27
|
+
@sprocket = Sprocket.new(@machine, :flux, {:meta => "wibble"})
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".apply!" do
|
31
|
+
|
32
|
+
it "should yield itself if the block's arity is 1" do
|
33
|
+
yielded = false
|
34
|
+
@sprocket.apply!{ |s| yielded = s }
|
35
|
+
yielded.should == @sprocket
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should instance_eval the block if its arity is 0/-1" do
|
39
|
+
yielded = false
|
40
|
+
@sprocket.apply!{ yielded = self }
|
41
|
+
yielded.should == @sprocket
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should merge any options passed into .options" do
|
45
|
+
opts = @sprocket.options
|
46
|
+
newopts = { :size => "huge", :colour => "orange" }
|
47
|
+
@sprocket.apply!( newopts )
|
48
|
+
@sprocket.options.should == opts.merge(newopts)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should instance_eval the block if one is passed" do
|
52
|
+
ref = nil
|
53
|
+
@sprocket.apply!(){ ref = self }
|
54
|
+
ref.should == @sprocket
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return itself" do
|
58
|
+
@sprocket.apply!.should == @sprocket
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "to_sym" do
|
63
|
+
it "should return its name" do
|
64
|
+
@sprocket.to_sym.should == @sprocket.name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
## See state_and_event_common_spec.rb for behaviour shared between
|
4
|
+
## StateFu::State and StateFu::Event
|
5
|
+
##
|
6
|
+
|
7
|
+
describe StateFu::State do
|
8
|
+
include MySpecHelper
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@machine = Object.new
|
12
|
+
@state = StateFu::State.new( @machine, :flux, {:meta => "wibble"} )
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "instance methods" do
|
16
|
+
|
17
|
+
describe "#after?(other_state)" do
|
18
|
+
|
19
|
+
it "should be true when the other state is is after? this one" do
|
20
|
+
m = StateFu::Machine.new do
|
21
|
+
states :red, :green, :yellow
|
22
|
+
end
|
23
|
+
m.states[:green].after?(:red).should be_true
|
24
|
+
m.states[:green].after?(:yellow).should be_false
|
25
|
+
m.states[:green].after?(:green).should be_false
|
26
|
+
m.states[:green].after?(m.states[:red]).should be_true
|
27
|
+
m.states[:green].after?(m.states[:yellow]).should be_false
|
28
|
+
m.states[:green].after?(m.states[:green]).should be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "##before?(other_state)" do
|
33
|
+
|
34
|
+
it "should be true when the other state is is before this one" do
|
35
|
+
m = StateFu::Machine.new do
|
36
|
+
states :red, :green, :yellow
|
37
|
+
end
|
38
|
+
m.states[:green].before?(:red).should be_false
|
39
|
+
m.states[:green].before?(:yellow).should be_true
|
40
|
+
m.states[:green].after?(:green).should be_false
|
41
|
+
m.states[:green].before?(m.states[:red]).should be_false
|
42
|
+
m.states[:green].before?(m.states[:yellow]).should be_true
|
43
|
+
m.states[:green].after?(m.states[:green]).should be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#events" do
|
48
|
+
|
49
|
+
it "should call machine.events.from(self)" do
|
50
|
+
machine_events = Object.new
|
51
|
+
mock( @machine ).events { machine_events }
|
52
|
+
mock( machine_events ).from( @state ) { nil }
|
53
|
+
@state.events
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: state-fu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.11.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-26 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A rich library for state-oriented programming with state machines / workflows
|
17
|
+
email: david@rubyist.net.au
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.textile
|
25
|
+
files:
|
26
|
+
- Rakefile
|
27
|
+
- lib/binding.rb
|
28
|
+
- lib/event.rb
|
29
|
+
- lib/executioner.rb
|
30
|
+
- lib/hooks.rb
|
31
|
+
- lib/interface.rb
|
32
|
+
- lib/lathe.rb
|
33
|
+
- lib/machine.rb
|
34
|
+
- lib/method_factory.rb
|
35
|
+
- lib/persistence.rb
|
36
|
+
- lib/persistence/active_record.rb
|
37
|
+
- lib/persistence/attribute.rb
|
38
|
+
- lib/persistence/base.rb
|
39
|
+
- lib/persistence/relaxdb.rb
|
40
|
+
- lib/persistence/session.rb
|
41
|
+
- lib/sprocket.rb
|
42
|
+
- lib/state-fu.rb
|
43
|
+
- lib/state.rb
|
44
|
+
- lib/support/active_support_lite/array.rb
|
45
|
+
- lib/support/active_support_lite/array/access.rb
|
46
|
+
- lib/support/active_support_lite/array/conversions.rb
|
47
|
+
- lib/support/active_support_lite/array/extract_options.rb
|
48
|
+
- lib/support/active_support_lite/array/grouping.rb
|
49
|
+
- lib/support/active_support_lite/array/random_access.rb
|
50
|
+
- lib/support/active_support_lite/array/wrapper.rb
|
51
|
+
- lib/support/active_support_lite/blank.rb
|
52
|
+
- lib/support/active_support_lite/cattr_reader.rb
|
53
|
+
- lib/support/active_support_lite/keys.rb
|
54
|
+
- lib/support/active_support_lite/misc.rb
|
55
|
+
- lib/support/active_support_lite/module.rb
|
56
|
+
- lib/support/active_support_lite/module/delegation.rb
|
57
|
+
- lib/support/active_support_lite/object.rb
|
58
|
+
- lib/support/active_support_lite/string.rb
|
59
|
+
- lib/support/active_support_lite/symbol.rb
|
60
|
+
- lib/support/applicable.rb
|
61
|
+
- lib/support/arrays.rb
|
62
|
+
- lib/support/core_ext.rb
|
63
|
+
- lib/support/exceptions.rb
|
64
|
+
- lib/support/has_options.rb
|
65
|
+
- lib/support/logger.rb
|
66
|
+
- lib/support/methodical.rb
|
67
|
+
- lib/support/no_stdout.rb
|
68
|
+
- lib/support/plotter.rb
|
69
|
+
- lib/support/vizier.rb
|
70
|
+
- lib/tasks/spec_last.rake
|
71
|
+
- lib/tasks/state_fu.rake
|
72
|
+
- lib/transition.rb
|
73
|
+
- lib/transition_query.rb
|
74
|
+
- spec/custom_formatter.rb
|
75
|
+
- spec/features/binding_and_transition_helper_mixin_spec.rb
|
76
|
+
- spec/features/method_missing_only_once_spec.rb
|
77
|
+
- spec/features/not_requirements_spec.rb
|
78
|
+
- spec/features/plotter_spec.rb
|
79
|
+
- spec/features/shared_log_spec.rb
|
80
|
+
- spec/features/singleton_machine_spec.rb
|
81
|
+
- spec/features/state_and_array_options_accessor_spec.rb
|
82
|
+
- spec/features/transition_boolean_comparison_spec.rb
|
83
|
+
- spec/helper.rb
|
84
|
+
- spec/integration/active_record_persistence_spec.rb
|
85
|
+
- spec/integration/binding_extension_spec.rb
|
86
|
+
- spec/integration/class_accessor_spec.rb
|
87
|
+
- spec/integration/event_definition_spec.rb
|
88
|
+
- spec/integration/example_01_document_spec.rb
|
89
|
+
- spec/integration/example_02_string_spec.rb
|
90
|
+
- spec/integration/instance_accessor_spec.rb
|
91
|
+
- spec/integration/lathe_extension_spec.rb
|
92
|
+
- spec/integration/machine_duplication_spec.rb
|
93
|
+
- spec/integration/relaxdb_persistence_spec.rb
|
94
|
+
- spec/integration/requirement_reflection_spec.rb
|
95
|
+
- spec/integration/state_definition_spec.rb
|
96
|
+
- spec/integration/transition_spec.rb
|
97
|
+
- spec/spec.opts
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/state_fu_spec.rb
|
100
|
+
- spec/units/binding_spec.rb
|
101
|
+
- spec/units/event_spec.rb
|
102
|
+
- spec/units/exceptions_spec.rb
|
103
|
+
- spec/units/lathe_spec.rb
|
104
|
+
- spec/units/machine_spec.rb
|
105
|
+
- spec/units/method_factory_spec.rb
|
106
|
+
- spec/units/sprocket_spec.rb
|
107
|
+
- spec/units/state_spec.rb
|
108
|
+
- LICENSE
|
109
|
+
- README.textile
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://github.com/davidlee/state-fu
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options:
|
116
|
+
- --charset=UTF-8
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
version:
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
130
|
+
version:
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project: state-fu
|
134
|
+
rubygems_version: 1.3.5
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: A rich library for state-oriented programming with state machines / workflows
|
138
|
+
test_files:
|
139
|
+
- spec/custom_formatter.rb
|
140
|
+
- spec/features/binding_and_transition_helper_mixin_spec.rb
|
141
|
+
- spec/features/method_missing_only_once_spec.rb
|
142
|
+
- spec/features/not_requirements_spec.rb
|
143
|
+
- spec/features/plotter_spec.rb
|
144
|
+
- spec/features/shared_log_spec.rb
|
145
|
+
- spec/features/singleton_machine_spec.rb
|
146
|
+
- spec/features/state_and_array_options_accessor_spec.rb
|
147
|
+
- spec/features/transition_boolean_comparison_spec.rb
|
148
|
+
- spec/helper.rb
|
149
|
+
- spec/integration/active_record_persistence_spec.rb
|
150
|
+
- spec/integration/binding_extension_spec.rb
|
151
|
+
- spec/integration/class_accessor_spec.rb
|
152
|
+
- spec/integration/event_definition_spec.rb
|
153
|
+
- spec/integration/example_01_document_spec.rb
|
154
|
+
- spec/integration/example_02_string_spec.rb
|
155
|
+
- spec/integration/instance_accessor_spec.rb
|
156
|
+
- spec/integration/lathe_extension_spec.rb
|
157
|
+
- spec/integration/machine_duplication_spec.rb
|
158
|
+
- spec/integration/relaxdb_persistence_spec.rb
|
159
|
+
- spec/integration/requirement_reflection_spec.rb
|
160
|
+
- spec/integration/state_definition_spec.rb
|
161
|
+
- spec/integration/transition_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
163
|
+
- spec/state_fu_spec.rb
|
164
|
+
- spec/units/binding_spec.rb
|
165
|
+
- spec/units/event_spec.rb
|
166
|
+
- spec/units/exceptions_spec.rb
|
167
|
+
- spec/units/lathe_spec.rb
|
168
|
+
- spec/units/machine_spec.rb
|
169
|
+
- spec/units/method_factory_spec.rb
|
170
|
+
- spec/units/sprocket_spec.rb
|
171
|
+
- spec/units/state_spec.rb
|