bstard 0.2.1 → 0.2.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.
- checksums.yaml +8 -8
- data/.travis.yml +1 -0
- data/README.md +8 -4
- data/bstard.gemspec +2 -2
- data/lib/bstard/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTc5MTIxYjYyOGVkYWM2OTA0NzA0NzU3NWE5YTMyMGJiYjM2MmFkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjEwNWEwZjZkMTNjMGIzNzhiMTVmN2RlYzQyMjQ0YmI1YWNjZjkxYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDg0NzdiMTUxZTA5YjVlYjUwYzU2ZjkzNjg5ZWQ1ZDMyMjNlY2ZkMzBiYmIy
|
10
|
+
Mzk5NTkwOTgwYmEzZDhlMTA2NjBkMDkzODNmYThjMDE2YjJiZjE2YTM0YmMx
|
11
|
+
MGFhYTY1M2RlYWFjMDlmYzc1Mjg5MTkzZjljYTJhODI1YjA3ZjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2M1YTJhNDMzYjU4NjM0OWViZmQyMjhiNWVlYjE4NmIzMmFkNGFiZjhhNDBk
|
14
|
+
NDNjZDk5YzE1MzU0MDhiYTRlY2UzNmVlYWI1MjVkYWJiYzM4N2M4NWU3MjIy
|
15
|
+
MzI5Y2UwMGU4YTljMmE0NWJlNTY1ZjVmMTE5ZGY0ZTViNjgyZjk=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
A small state machine library with a simple interface. Designed around the concept of aggregation rather than inheritance enabling its use wherever you need it without the need to derive from it or mix it in.
|
4
4
|
|
5
|
+
[](http://badge.fury.io/rb/bstard)
|
6
|
+
[](https://travis-ci.org/tonyheadford/bstard)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -52,7 +55,7 @@ The current state of the machine is accessed via the `current_state` method
|
|
52
55
|
#=> :new
|
53
56
|
```
|
54
57
|
|
55
|
-
Helper methods are automatically generated for each state consisting of the state name
|
58
|
+
Helper methods are automatically generated for each state consisting of the state name suffixed with a question mark. This method returns `true` if the current state matches the queried state or `false` otherwise.
|
56
59
|
|
57
60
|
``` ruby
|
58
61
|
machine.new?
|
@@ -65,7 +68,7 @@ Helper methods are automatically generated for each state consisting of the stat
|
|
65
68
|
|
66
69
|
### Querying Transitions
|
67
70
|
|
68
|
-
Helper methods are dynamically generated to enable querying whether an event
|
71
|
+
Helper methods are dynamically generated to enable querying whether an event can transition the current state. These methods are named using the event name prefixed with 'can\_' and suffixed with a question mark.
|
69
72
|
|
70
73
|
```ruby
|
71
74
|
machine.current_state
|
@@ -78,7 +81,7 @@ Helper methods are dynamically generated to enable querying whether an event is
|
|
78
81
|
|
79
82
|
### Triggering Events
|
80
83
|
|
81
|
-
Trigger events by sending a message
|
84
|
+
Trigger events by sending a message using the event name suffixed with an exclamation mark.
|
82
85
|
|
83
86
|
```ruby
|
84
87
|
machine.submit!
|
@@ -112,7 +115,7 @@ State change callbacks are configured with `when`
|
|
112
115
|
end
|
113
116
|
```
|
114
117
|
|
115
|
-
Use the symbol `:any` for event or state change callbacks that should
|
118
|
+
Use the symbol `:any` for event or state change callbacks that should run when any event is triggered or after any state change.
|
116
119
|
|
117
120
|
``` ruby
|
118
121
|
machine = Bstard.define do |fsm|
|
@@ -133,6 +136,7 @@ class MyModel < ActiveRecord::Base
|
|
133
136
|
def make_draft
|
134
137
|
# do stuff
|
135
138
|
state.save!
|
139
|
+
save
|
136
140
|
end
|
137
141
|
|
138
142
|
private
|
data/bstard.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "minitest"
|
26
26
|
spec.add_development_dependency "minitest-reporters"
|
27
27
|
end
|
data/lib/bstard/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bstard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Headford
|
@@ -14,30 +14,30 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|