stateful.rb 2.3.1 → 2.3.3
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 +4 -4
- data/CHANGELOG.md +20 -0
- data/LICENSE +21 -0
- data/README.md +69 -6
- data/lib/Stateful/VERSION.rb +1 -1
- data/stateful.rb.gemspec +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36b830fd690c778367717cc317ffe39d53801ee9dc93e0fea1d42ba60ad099f1
|
|
4
|
+
data.tar.gz: 4e9ea424b04703d2202afdcb9b73df9fb7b17514176e64202f54d3ae98092535
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a24a02097f130a4993bab84684fbfd060c4a95c7a33cf1090bd8d02cf1468b11daba5fa99190670a4a42273b8881574dac0c52519198a40affbe903115c174f4
|
|
7
|
+
data.tar.gz: 5b21b16363b87c18ba78034102072e84cd7f5696cfbd1810bf766732cc798641434800275768d4c241940347c3ce7db39e169997cfcf6df1f411123359951bb0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# stateful/CHANGELOG.md
|
|
2
2
|
|
|
3
|
+
## 2.3.3 (20260822): + LICENSE, and correct the README.
|
|
4
|
+
-----------------------------------------------------------------------------------------------------------------------
|
|
5
|
+
### +
|
|
6
|
+
1. LICENSE: the MIT text, copyright 2014-2026 thoran. The gemspec has declared MIT while the repository carried no licence text at all.
|
|
7
|
+
2. README.md: a License section, saying MIT, last.
|
|
8
|
+
### ~
|
|
9
|
+
1. stateful.rb.gemspec: + 'LICENSE' to spec.files, so the gem carries what the declaration claims.
|
|
10
|
+
2. README.md: /thoran\/Stateful/thoran\/stateful/ in the mruby install line, the repository having been renamed.
|
|
11
|
+
3. README.md: /### 6. Multiple state machines per class/### 8. Multiple state machines per class/, the sequence having run 1 to 7 and then 6 again.
|
|
12
|
+
4. lib/Stateful/VERSION.rb: /2.3.2/2.3.3/
|
|
13
|
+
|
|
14
|
+
## 2.3.2 (20260418): Add Sequel examples to README.
|
|
15
|
+
-----------------------------------------------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
### ~
|
|
18
|
+
1. README.md: + Sequel examples (sections 5 and 6), updated description to include Sequel,
|
|
19
|
+
renumbered remaining sections.
|
|
20
|
+
2. lib/Stateful/VERSION.rb: /2.3.1/2.3.2/
|
|
21
|
+
|
|
22
|
+
|
|
3
23
|
## 2.3.1 (20260418): Use require\_relative in tests.
|
|
4
24
|
-----------------------------------------------------------------------------------------------------------------------
|
|
5
25
|
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2026 thoran
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
A Ruby state machine which allows you to easily add state to Poro and
|
|
5
|
+
A Ruby state machine which allows you to easily add state to Poro, ActiveRecord, and Sequel objects. Works with both CRuby and mRuby.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -31,7 +31,7 @@ $ gem install stateful.rb
|
|
|
31
31
|
Add this to your `build_config.rb`:
|
|
32
32
|
|
|
33
33
|
```ruby
|
|
34
|
-
conf.gem github: 'thoran/
|
|
34
|
+
conf.gem github: 'thoran/stateful'
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Usage
|
|
@@ -149,9 +149,67 @@ active_record_machine.final_state?
|
|
|
149
149
|
# => true
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
### 5.
|
|
152
|
+
### 5. Sequel with persistence-specific extend and a stateful block declaration
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
```ruby
|
|
155
|
+
class SequelMachine < Sequel::Model
|
|
156
|
+
extend Stateful::Sequel
|
|
157
|
+
|
|
158
|
+
stateful do
|
|
159
|
+
initial_state :initial_state
|
|
160
|
+
|
|
161
|
+
state :initial_state do
|
|
162
|
+
on :an_event => :next_state
|
|
163
|
+
on :another_event => :final_state
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
state :next_state do
|
|
167
|
+
on :yet_another_event => :final_state
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
final_state :final_state
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
sequel_machine = SequelMachine.create
|
|
175
|
+
sequel_machine.initial_state?
|
|
176
|
+
# => true
|
|
177
|
+
sequel_machine.an_event
|
|
178
|
+
sequel_machine.next_state?
|
|
179
|
+
# => true
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 6. Sequel with persistence non-specific extend, without a stateful block declaration, an initial_state block, and multiple final states
|
|
183
|
+
|
|
184
|
+
```ruby
|
|
185
|
+
class SequelMachine < Sequel::Model
|
|
186
|
+
extend Stateful
|
|
187
|
+
|
|
188
|
+
initial_state :initial_state do
|
|
189
|
+
on :an_event => :next_state
|
|
190
|
+
on :another_event => :final_state0
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
state :next_state do
|
|
194
|
+
on :yet_another_event => :final_state0
|
|
195
|
+
on :and_yet_another_event => :final_state1
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
final_state :final_state0, :final_state1
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
sequel_machine = SequelMachine.create
|
|
202
|
+
sequel_machine.an_event
|
|
203
|
+
sequel_machine.final_state?
|
|
204
|
+
# => false
|
|
205
|
+
sequel_machine.yet_another_event
|
|
206
|
+
sequel_machine.final_state?
|
|
207
|
+
# => true
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 7. Custom attribute name and non-deterministic event ordering
|
|
211
|
+
|
|
212
|
+
It's also possible to define a state machine which has a custom attribute name, which fires off the events in a random or non-deterministic order, and which has no final state.
|
|
155
213
|
|
|
156
214
|
```ruby
|
|
157
215
|
class ActiveRecordMachine < ActiveRecord::Base
|
|
@@ -189,7 +247,7 @@ active_record_machine.final_state?
|
|
|
189
247
|
# => false
|
|
190
248
|
```
|
|
191
249
|
|
|
192
|
-
###
|
|
250
|
+
### 8. Multiple state machines per class
|
|
193
251
|
|
|
194
252
|
A single class can have multiple independent (orthogonal) state machines. Each machine gets its own namespaced methods, while domain predicates and event methods remain unnamespaced.
|
|
195
253
|
|
|
@@ -285,7 +343,7 @@ class Order
|
|
|
285
343
|
end
|
|
286
344
|
```
|
|
287
345
|
|
|
288
|
-
For ActiveRecord, each machine uses a column named `<machine_name>_state`:
|
|
346
|
+
For ActiveRecord and Sequel, each machine uses a column named `<machine_name>_state`:
|
|
289
347
|
|
|
290
348
|
```ruby
|
|
291
349
|
class CreateOrders < ActiveRecord::Migration[6.0]
|
|
@@ -307,3 +365,8 @@ For Poro, each machine uses an instance variable named `@<machine_name>_state`.
|
|
|
307
365
|
3. Commit your changes: `git commit -am 'Add some feature'`
|
|
308
366
|
4. Push to the branch: `git push origin my-new-feature`
|
|
309
367
|
5. Create a new pull request
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
## License
|
|
371
|
+
|
|
372
|
+
MIT
|
data/lib/Stateful/VERSION.rb
CHANGED
data/stateful.rb.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stateful.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -87,6 +87,7 @@ extra_rdoc_files: []
|
|
|
87
87
|
files:
|
|
88
88
|
- CHANGELOG.md
|
|
89
89
|
- Gemfile
|
|
90
|
+
- LICENSE
|
|
90
91
|
- README.md
|
|
91
92
|
- lib/Stateful.rb
|
|
92
93
|
- lib/Stateful/ActiveRecord.rb
|
|
@@ -165,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
166
|
- !ruby/object:Gem::Version
|
|
166
167
|
version: '0'
|
|
167
168
|
requirements: []
|
|
168
|
-
rubygems_version: 4.0.
|
|
169
|
+
rubygems_version: 4.0.19
|
|
169
170
|
specification_version: 4
|
|
170
171
|
summary: A Ruby state machine.
|
|
171
172
|
test_files: []
|