bstard 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjRmN2FjOTNjZjJkOWI0NDcxMzU3MTNjZDkxMmM0MGQyMTliZTc1ZQ==
4
+ YjUzNDM2MWNmNTA1MjM5MTE5MDJhYTdlNjU2NWVhYTNmMWY0MGI5ZQ==
5
5
  data.tar.gz: !binary |-
6
- NTNhZjk0MDJjNDk2YjE5ZGNjZmE3MTdmMGVkZmU0Zjg3NDk2NTE0Zg==
6
+ ZmE2MGQwY2M1YTVmYzJkMTAwY2ZhNWM3ZmUyYzVjMzNmODNhYmJhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDY4MzExMjVhMTBiYjM4Nzc5MzY2YzUxODMwY2E0NTcxMTA4NjJkNDg5YWU3
10
- MTdjNmY5NTMzYzg4NmU4MDUyYWVmZmM0ZWNjZTVlYWUyNTgxMDlmMzEwM2Zj
11
- NGY3YjdjYmUzZjIyMjVkZGFjNTJlZjRjNmY0MDljZDlkMWIxZDM=
9
+ ZDhiZDcxNGU4MDgyNTgxN2YxYTViOWEzYjkwZWU0YjBmNjI1YmFlYWZmMmI0
10
+ N2M1MWU0ZWVjYTE5MDQ5ZGI3ZjA5NzlhMTU1NjcwNjFmZmIyNDIzZDhmN2Rh
11
+ ZTQ5YmQ3ZDk2ZTU5MTBjZWI3YjE3MjFmMjE5N2M4ZTcxYjU3NTk=
12
12
  data.tar.gz: !binary |-
13
- MGYyZjIzYWE3ODA0MDdiYmI4NzRhOTFhNmNiMTRkZDVkMmEwNzU3OGY3YmQx
14
- Y2U5OTdlOTQ1Y2YzNmU1YmM5ZWNjNTRlNjM4ODhhOTk1YTRmNjExMWFiNWEx
15
- ZDdjZDVhOGQ3OGQyZjljOTIwNTgzZGZhODJkNDg5ODUwM2Y0OWE=
13
+ NDZjODEwNTg1NGJkN2U1ZGE1MDAxOGUwODI2ZTJiMDc0MzY1MTVkNjgyYzIy
14
+ NWFmZjVlNGYwMWEyYThlZjVkMWRmNmMxMmI2Yzg0NmViYmZiOGVlNjBmZjM1
15
+ ZmUyMmIzNDkxNDVlMzEwYTU4YmVkODE5NDIzOWNjYmY4NDg1YWM=
data/README.md CHANGED
@@ -44,7 +44,7 @@ This defines a state machine that:
44
44
  Pretty simple huh?
45
45
 
46
46
  ### Initial State
47
- Set the initial state of the machine with `initial`. If no initial state is set a default state `:uninitialized` is used.
47
+ Set the initial state of the machine with `initial`. If no initial state is set a default state `:uninitialized` is used. As a safeguard `initial` will ignore `nil` or empty string values.
48
48
 
49
49
  ### Querying the State
50
50
 
@@ -79,6 +79,22 @@ Helper methods are dynamically generated to enable querying whether an event can
79
79
  #=> false
80
80
  ```
81
81
 
82
+ ### Defining Events
83
+
84
+ Events are defined by supplying an event name followed by one or more state transition declarations. Each state transition declaration is just a hash key value pair. The key represents the starting state and the value the ending state.
85
+
86
+ ``` ruby
87
+ machine = Bstard.define do |fsm|
88
+ fsm.initial :new
89
+ fsm.event :save, :new => :draft
90
+ fsm.event :approve, :draft => :approved
91
+ fsm.event :publish, :approved => :published
92
+ fsm.event :delete, :draft => :deleted, :approved => :deleted
93
+ end
94
+ ```
95
+
96
+ I find the spear `=>` Hash syntax style works best for me in describing the intent of the definition.
97
+
82
98
  ### Triggering Events
83
99
 
84
100
  Trigger events by sending a message using the event name suffixed with an exclamation mark.
@@ -10,7 +10,7 @@ class Bstard::Fsm
10
10
  end
11
11
 
12
12
  def initial(state)
13
- unless state.nil?
13
+ unless state.nil? || state.empty?
14
14
  @current_state = state.to_sym
15
15
  add_state(current_state)
16
16
  end
@@ -1,4 +1,4 @@
1
1
  module Bstard
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bstard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Headford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler