barebone-fsm 0.0.1.2 → 0.0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/lib/barebone-fsm.rb +5 -8
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -78,6 +78,8 @@ The api is not stable yet, it may go trhough lots of changes before the first st
|
|
78
78
|
I am open to any suggestion or request to support custom features.
|
79
79
|
|
80
80
|
== Changes
|
81
|
+
* Version: 0.0.1.3
|
82
|
+
* Minor fixes on the usage examples
|
81
83
|
* Version: 0.0.1.2
|
82
84
|
* @state instance variable for FSM is dropped in favour of the #state instance method.
|
83
85
|
* #state method and index operator [] now accept nil arguement for state name, which returns the current state.
|
data/lib/barebone-fsm.rb
CHANGED
@@ -18,14 +18,14 @@
|
|
18
18
|
#
|
19
19
|
module FSM
|
20
20
|
|
21
|
-
# == Overview
|
22
|
-
# ---
|
23
21
|
# FSMState class represents a state of the finite state machine.
|
24
22
|
#
|
25
23
|
# == Usage
|
26
|
-
# ---
|
27
24
|
# state = FSMState.new :state_name
|
28
|
-
# state.event(:event_name)
|
25
|
+
# state.event(:event_name) do # creates the event when block is given
|
26
|
+
# puts "#{@event} triggered on state #{@state}"
|
27
|
+
# :new_state
|
28
|
+
# end
|
29
29
|
# puts state
|
30
30
|
# state.event :event_name # triggers the event when block is absent
|
31
31
|
#
|
@@ -73,8 +73,6 @@ module FSM
|
|
73
73
|
|
74
74
|
end
|
75
75
|
|
76
|
-
# == Overview
|
77
|
-
# ---
|
78
76
|
# This class implements the finite-state machine.
|
79
77
|
# FSM class exposes the states it contains and can trigger an event.
|
80
78
|
# States are created on the fly first time it's referenced through index operator [].
|
@@ -85,9 +83,8 @@ module FSM
|
|
85
83
|
# This can be either the default state if defined or the first referenced state.
|
86
84
|
#
|
87
85
|
# == Usage
|
88
|
-
# ---
|
89
86
|
# fsm = FSM.new :default_state
|
90
|
-
# fsm[:default_state].event(:first_event) do
|
87
|
+
# fsm[:default_state].event(:first_event) do # the state is defined and referenced at the same time
|
91
88
|
# puts "The first transition from the default_state to state_name"
|
92
89
|
# :state_name # the next state is defined here
|
93
90
|
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barebone-fsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.3
|
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: 2013-01-
|
12
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A barebone implementation of finite state machine keeping simplicity
|
15
15
|
in mind.
|