MINT-statemachine 1.3.0 → 1.3.2
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/CHANGES +28 -19
- data/MINT-statemachine.gemspec +3 -3
- data/README.rdoc +37 -1
- data/lib/statemachine/parallelstate.rb +2 -10
- data/lib/statemachine/superstate.rb +1 -1
- data/lib/statemachine/transition.rb +18 -14
- data/lib/statemachine/version.rb +1 -1
- data/spec/generate/dot_graph/dot_graph_stagemachine_spec.rb +1 -1
- data/spec/sm_parallel_state_spec.rb +106 -10
- metadata +6 -3
data/CHANGES
CHANGED
@@ -1,26 +1,35 @@
|
|
1
1
|
= Statemachine Changelog
|
2
2
|
|
3
|
+
== Version 1.3.2 (2013/02/28)
|
4
|
+
|
5
|
+
* Fixed bug with spontaneous transitions within parallel states.
|
6
|
+
|
7
|
+
== Version 1.3.1 (2013/02/26)
|
8
|
+
|
9
|
+
* improved support for spontaneous transitions. Direct transitions to atomic states that enter a parallel state
|
10
|
+
consider all spontaneous transitions of all entered states.
|
11
|
+
|
3
12
|
== Version 1.3.0
|
4
13
|
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
14
|
+
* fixed bug that prevented exit call on parallel state exit
|
15
|
+
* refactorings to support existing parallel states without calling events twice
|
16
|
+
* if entering a parallel state, spontaneous initial transitions were not executed
|
17
|
+
* introduced workaround to retrieve correct activation callback within parallel state machines
|
18
|
+
* fixed bug that prevented spontaneous transitions from initial state within superstate
|
19
|
+
* added test using transition to self to recheck spontaneous transition's condition.
|
20
|
+
* transitions now stored as array
|
21
|
+
* correct abstract states handling working. All tests working
|
22
|
+
* fixed bug that prevented in parallel state machine setups the correct publishing of all new atomic and abstract states
|
23
|
+
* added option to temporarily disable activation callback for reset
|
24
|
+
* several minor bug fixes
|
25
|
+
* changed activation callback processing so it can be used fo publishing state updates with redis
|
26
|
+
* Added tests for on_entry, on_exit and transitions for parallel states.
|
27
|
+
* fixed optional parameter handling
|
28
|
+
* allow dynamic parameter size
|
29
|
+
* No more In() hack. Use is_in? instead
|
30
|
+
* Support for spontaneous transitions
|
31
|
+
* abstract_states now also includes parallel state name
|
32
|
+
* added treatment for ifs
|
24
33
|
|
25
34
|
== Version 1.2.3
|
26
35
|
|
data/MINT-statemachine.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "MINT-statemachine"
|
5
|
-
s.version = "1.3.
|
5
|
+
s.version = "1.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sebastian Feuerstack"]
|
9
|
-
s.date = "
|
9
|
+
s.date = "2013-02-26"
|
10
10
|
s.description = "The MINT Statemachine is a ruby library for building Finite State Machines, based on the Statemachine gem by Micah Martin."
|
11
11
|
s.email = "Sebastian@Feuerstack.org"
|
12
12
|
s.files = ["TODO", "Gemfile.lock", "LICENSE", "CHANGES", "Rakefile", "Gemfile", "README.rdoc", "MINT-statemachine.gemspec", "lib/statemachine.rb", "lib/statemachine/builder.rb", "lib/statemachine/statemachine.rb", "lib/statemachine/generate/util.rb", "lib/statemachine/generate/dot_graph/dot_graph_statemachine.rb", "lib/statemachine/generate/java/java_statemachine.rb", "lib/statemachine/generate/dot_graph.rb", "lib/statemachine/generate/src_builder.rb", "lib/statemachine/generate/java.rb", "lib/statemachine/transition.rb", "lib/statemachine/version.rb", "lib/statemachine/parallelstate.rb", "lib/statemachine/action_invokation.rb", "lib/statemachine/superstate.rb", "lib/statemachine/state.rb", "lib/statemachine/stub_context.rb", "spec/default_transition_spec.rb", "spec/spec_helper.rb", "spec/sm_super_state_spec.rb", "spec/sm_action_parameterization_spec.rb", "spec/generate/dot_graph/dot_graph_stagemachine_spec.rb", "spec/generate/java/java_statemachine_spec.rb", "spec/sm_entry_exit_actions_spec.rb", "spec/sm_simple_spec.rb", "spec/sm_parallel_state_spec.rb", "spec/transition_spec.rb", "spec/noodle.rb", "spec/sm_activation_spec.rb", "spec/builder_spec.rb", "spec/action_invokation_spec.rb", "spec/sm_turnstile_spec.rb", "spec/history_spec.rb", "spec/sm_odds_n_ends_spec.rb"]
|
13
13
|
s.homepage = "http://www.multi-access.de"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.rubygems_version = "1.8.15"
|
16
|
-
s.summary = "MINT-Statemachine-1.3.
|
16
|
+
s.summary = "MINT-Statemachine-1.3.1 - Statemachine Library for Ruby based on statemachine from http://slagyr.github.com/statemachine http://www.multi-access.de/open-source-software/third-party-software-extensions/"
|
17
17
|
s.test_files = ["spec/default_transition_spec.rb", "spec/sm_super_state_spec.rb", "spec/sm_action_parameterization_spec.rb", "spec/sm_entry_exit_actions_spec.rb", "spec/sm_simple_spec.rb", "spec/sm_parallel_state_spec.rb", "spec/transition_spec.rb", "spec/sm_activation_spec.rb", "spec/builder_spec.rb", "spec/action_invokation_spec.rb", "spec/sm_turnstile_spec.rb", "spec/history_spec.rb", "spec/sm_odds_n_ends_spec.rb"]
|
18
18
|
|
19
19
|
if s.respond_to? :specification_version then
|
data/README.rdoc
CHANGED
@@ -40,6 +40,42 @@ Each action that is called during a transaction has to return true for the trans
|
|
40
40
|
Otherwise the entire transition is assumed as failed and the statemachine remains in its origin
|
41
41
|
state.
|
42
42
|
|
43
|
+
=== Transitions can be spontaneous (eventless)
|
44
|
+
|
45
|
+
In this example the statemachine will first enter the inital u1 state but then directly
|
46
|
+
will do a transition to u2.
|
47
|
+
|
48
|
+
@sm = Statemachine.build @old_sm do
|
49
|
+
superstate :unlocked do
|
50
|
+
trans :u1, nil , :u2
|
51
|
+
trans :u2, :e, :maintenance
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
=== Support for parallel running states
|
56
|
+
|
57
|
+
After sending the :go event, the statemachine of this
|
58
|
+
example will end up in a [:locked,:on] setting.
|
59
|
+
|
60
|
+
@sm = Statemachine.build do
|
61
|
+
trans :start,:go,:p
|
62
|
+
|
63
|
+
parallel :p do
|
64
|
+
statemachine :s1 do
|
65
|
+
superstate :operative do
|
66
|
+
trans :locked, :coin, :unlocked
|
67
|
+
trans :unlocked, :coin, :locked
|
68
|
+
end
|
69
|
+
end
|
70
|
+
statemachine :s2 do
|
71
|
+
superstate :onoff do
|
72
|
+
trans :on, :toggle, :off
|
73
|
+
trans :off, :toggle, :on
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
43
79
|
=== Support for GemBundler
|
44
80
|
|
45
81
|
rake make_spec can be used to create a gemspec file that is required for GemBundler
|
@@ -66,4 +102,4 @@ Lesser General Public License for more details.
|
|
66
102
|
|
67
103
|
You should have received a copy of the GNU Lesser General Public
|
68
104
|
License along with this library; if not, write to the Free Software
|
69
|
-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
105
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -196,16 +196,8 @@ module Statemachine
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def spontaneous_transition
|
199
|
-
|
200
|
-
|
201
|
-
t = s.get_state(s.state).spontaneous_transition
|
202
|
-
transition << [t,s] if t # we need to store the state machine relevant for the transition
|
203
|
-
end
|
204
|
-
if transition.empty?
|
205
|
-
return nil
|
206
|
-
end
|
207
|
-
transition
|
208
|
-
end
|
199
|
+
nil
|
200
|
+
end
|
209
201
|
|
210
202
|
|
211
203
|
def exit(args)
|
@@ -58,22 +58,26 @@ module Statemachine
|
|
58
58
|
sm.activation.call(new_states,sm.abstract_states,sm.states_id) if sm.activation # and not @statemachine.is_parallel
|
59
59
|
end
|
60
60
|
|
61
|
-
# Take any valid spontaneous transitions
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
61
|
+
# Take any valid spontaneous transitions for entered states
|
62
|
+
new_states.each do |entered_state|
|
63
|
+
s = statemachine.get_state(entered_state)
|
64
|
+
transition = s.spontaneous_transition
|
65
|
+
perform_spontaneous_transition(statemachine,s,transition,args) if transition and transition.length >0
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def perform_spontaneous_transition(statemachine,destination,transition,args)
|
70
|
+
if destination.is_parallel
|
71
|
+
transition.each do |trans,statem|
|
72
|
+
trans.each do |t|
|
73
|
+
t[0].invoke(t[1], statem, args) if t[0].is_a? Transition
|
70
74
|
end
|
71
|
-
|
75
|
+
end
|
76
|
+
else
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
78
|
+
if transition.is_a? Array
|
79
|
+
transition.each do |t|
|
80
|
+
t[0].invoke(t[1], statemachine, args) if t[0].is_a? Transition
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
data/lib/statemachine/version.rb
CHANGED
@@ -42,17 +42,17 @@ describe "Parallel states" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should call enter only once if entering parallel state" do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
counter = 0
|
46
|
+
@sm.get_state(:p).entry_action = Proc.new { counter += 1 }
|
47
|
+
@sm.go
|
48
|
+
counter.should == 1
|
49
|
+
end
|
50
50
|
|
51
51
|
|
52
52
|
# @TODO add tests that set a certain state that is part of a parallel state machine
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
# to check if
|
54
|
+
# the other sub statemachine is set to the initial state
|
55
|
+
# the other sub state machines states doe not change if already in this parallel state machine
|
56
56
|
it "supports entering a parallel state" do
|
57
57
|
@sm.state.should eql :start
|
58
58
|
@sm.go
|
@@ -232,11 +232,106 @@ describe "Parallel states" do
|
|
232
232
|
@sm.go
|
233
233
|
lambda {@sm.unknown}.should raise_error
|
234
234
|
end
|
235
|
+
|
236
|
+
it "should support spontaneous initial transitions" do
|
237
|
+
|
238
|
+
@sm = Statemachine.build do
|
239
|
+
trans :start,:go,:p
|
240
|
+
|
241
|
+
parallel :p do
|
242
|
+
statemachine :s1 do
|
243
|
+
superstate :operative do
|
244
|
+
trans :locked, nil, :unlocked
|
245
|
+
trans :unlocked, :coin, :locked
|
246
|
+
end
|
247
|
+
end
|
248
|
+
statemachine :s2 do
|
249
|
+
superstate :onoff do
|
250
|
+
trans :on, nil, :off
|
251
|
+
trans :off, :toggle, :on
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
@sm.go
|
259
|
+
@sm.state.should eql :p
|
260
|
+
@sm.states_id.should == [:unlocked,:off]
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "state flows" do
|
264
|
+
before(:each) do
|
265
|
+
@state_flow = []
|
266
|
+
|
267
|
+
def activate(new_states,abstract_states, atomic_states)
|
268
|
+
@state_flow << new_states
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
it "should support spontaneous initial transitions triggered by direct transition into a parallel atomic state" do
|
273
|
+
|
274
|
+
@sm = Statemachine.build do
|
275
|
+
trans :start,:go,:on
|
276
|
+
|
277
|
+
parallel :p do
|
278
|
+
statemachine :s1 do
|
279
|
+
superstate :operative do
|
280
|
+
trans :locked, nil, :unlocked
|
281
|
+
trans :unlocked, :coin, :locked
|
282
|
+
end
|
283
|
+
end
|
284
|
+
statemachine :s2 do
|
285
|
+
superstate :onoff do
|
286
|
+
trans :on, nil, :off
|
287
|
+
trans :off, :toggle, :on
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
@sm.activation=self.method(:activate)
|
293
|
+
@sm.go
|
294
|
+
@sm.state.should eql :p
|
295
|
+
@state_flow.should == [[:p, :operative, :onoff, :locked, :on],[:unlocked],[:off]]
|
296
|
+
@sm.states_id.should == [:unlocked,:off]
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should support spontaneous initial transitions triggered by direct transition into a parallel atomic state" do
|
300
|
+
@sm = Statemachine.build do
|
301
|
+
trans :start,:go,:a1
|
302
|
+
|
303
|
+
superstate :s do
|
304
|
+
trans :a1, nil, :a2
|
305
|
+
trans :a2, nil, :locked
|
306
|
+
|
307
|
+
parallel :p do
|
308
|
+
statemachine :s1 do
|
309
|
+
superstate :operative do
|
310
|
+
trans :locked, nil, :unlocked
|
311
|
+
trans :unlocked, :coin, :locked
|
312
|
+
end
|
313
|
+
end
|
314
|
+
statemachine :s2 do
|
315
|
+
superstate :onoff do
|
316
|
+
trans :on, nil, :off
|
317
|
+
trans :off, :toggle, :on
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
@sm.activation=self.method(:activate)
|
324
|
+
@sm.go
|
325
|
+
@sm.state.should eql :p
|
326
|
+
@state_flow.should == [[:s, :a1], [:a2],[:p, :operative, :onoff, :locked, :on],[:unlocked],[:off] ]
|
327
|
+
@sm.states_id.should == [:unlocked,:off]
|
328
|
+
end
|
329
|
+
end
|
235
330
|
end
|
236
331
|
|
237
332
|
describe "Nested parallel states" do
|
238
333
|
before (:each) do
|
239
|
-
|
334
|
+
@sm = Statemachine.build do
|
240
335
|
trans :start,:go, :unlocked
|
241
336
|
state :maintenance
|
242
337
|
superstate :test do
|
@@ -262,7 +357,7 @@ describe "Nested parallel states" do
|
|
262
357
|
superstate :onoff2 do
|
263
358
|
trans :on2, :toggle2, :off2
|
264
359
|
trans :off2, :toggle2, :on2
|
265
|
-
|
360
|
+
end
|
266
361
|
end
|
267
362
|
end
|
268
363
|
end
|
@@ -292,3 +387,4 @@ describe "Nested parallel states" do
|
|
292
387
|
end
|
293
388
|
|
294
389
|
end
|
390
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MINT-statemachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-28 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: The MINT Statemachine is a ruby library for building Finite State Machines,
|
15
15
|
based on the Statemachine gem by Micah Martin.
|
@@ -71,6 +71,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- - ! '>='
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: 744247185
|
74
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
78
|
none: false
|
76
79
|
requirements:
|
@@ -82,7 +85,7 @@ rubyforge_project:
|
|
82
85
|
rubygems_version: 1.8.15
|
83
86
|
signing_key:
|
84
87
|
specification_version: 3
|
85
|
-
summary: MINT-Statemachine-1.3.
|
88
|
+
summary: MINT-Statemachine-1.3.2 - Statemachine Library for Ruby based on statemachine
|
86
89
|
from http://slagyr.github.com/statemachine http://www.multi-access.de/open-source-software/third-party-software-extensions/
|
87
90
|
test_files:
|
88
91
|
- spec/default_transition_spec.rb
|