microfsm 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25f7dba6b2b63792351334e86f075f63ad9fcefda142adf3a8659a3526c7cde7
4
- data.tar.gz: 26aa4f34e819701f1643b408e5c9e11818ddd8792c5756d79c93b5f25c3b44ab
3
+ metadata.gz: 0d2e652821a740ba42ae709c3e978631c4a1467649e15b69aedaa07d257141f4
4
+ data.tar.gz: c333a20cee8e96dec737b822d6aa96909458a0f61801751d6c0857fa71ee87a6
5
5
  SHA512:
6
- metadata.gz: 12ccddd7ccdb718d24308ff1401297f4f6b3dec3e0a88dddf2a7bc3201f775184fad58295516c2b758aaa2c7a6b6bcaad745432700eaafaf64e56d2b72e41889
7
- data.tar.gz: 2169f5e53d5ae49eddb591bb34cdace9611b12b5fee5099d0cda41e31e753892da0563f86e3f3297bb39c24a2b4c74ba170518597d0e219c14d4a50e8443c3d3
6
+ metadata.gz: 577d4e3640dd78a8a8ee56f5a10c726c180a2e9d47d0775bb53162be29196cb88e37534189fd644e537e0f3da0fa11b93783e66fa08d5ab5298dc3d613748209
7
+ data.tar.gz: '0950e2d2b4dbf8733c24890e065e4d3ac4973b6fddd02e0b31e523215200d3caa81843a634070dc6f04e018dee58f1808b7882338d034f25f7fcb60fb9755bc3'
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021-2024 Dittmar Krall (www.matiq.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -97,7 +97,7 @@ fsm.state = :new
97
97
  fsm.state #=> :new
98
98
  ```
99
99
 
100
- Check the examples directory for more information.
100
+ Check the _examples_ directory for more information.
101
101
 
102
102
  ## Links
103
103
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MicroFSM
4
- VERSION = "0.1.7" # 2023-12-12
4
+ VERSION = "0.1.9" # 2024-05-22
5
+ # VERSION = "0.1.7" # 2023-12-12
5
6
  # VERSION = "0.1.6" # 2023-04-25
6
7
  # VERSION = "0.1.5" # 2022-12-22
7
8
  # VERSION = "0.1.3" # 2021-06-22
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microfsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dittmar Krall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-12 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -43,27 +43,17 @@ description: MicroFSM implements a minimal/simple Finite-State Machine (FSM). Tr
43
43
  email: dittmar.krall@matiq.com
44
44
  executables: []
45
45
  extensions: []
46
- extra_rdoc_files: []
46
+ extra_rdoc_files:
47
+ - README.md
48
+ - MIT-LICENSE
47
49
  files:
48
- - ".github/workflows/rake.yml"
49
- - ".gitignore"
50
- - ".ruby-gemset"
51
- - ".ruby-version"
52
- - Gemfile
53
- - Gemfile.lock
54
- - LICENSE
50
+ - MIT-LICENSE
55
51
  - README.md
56
- - Rakefile
57
52
  - examples/advanced.rb
58
53
  - examples/basic.rb
59
54
  - examples/callbacks.rb
60
55
  - lib/microfsm.rb
61
- - lib/version.rb
62
- - microfsm.gemspec
63
- - test/callbacks_test.rb
64
- - test/introspection_test.rb
65
- - test/microfsm_test.rb
66
- - test/test_helper.rb
56
+ - lib/microfsm/version.rb
67
57
  homepage: https://github.com/matique/microfsm
68
58
  licenses:
69
59
  - MIT
@@ -83,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
73
  - !ruby/object:Gem::Version
84
74
  version: '0'
85
75
  requirements: []
86
- rubygems_version: 3.4.20
76
+ rubygems_version: 3.5.10
87
77
  signing_key:
88
78
  specification_version: 4
89
79
  summary: Minimal Finite State Machine.
@@ -1,22 +0,0 @@
1
- # see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
2
- name: Rake
3
-
4
- on: [push]
5
-
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby_version: ["3.0", 3.2]
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - uses: actions/checkout@v3
16
- - name: Set up Ruby
17
- uses: ruby/setup-ruby@v1
18
- with:
19
- ruby-version: ${{ matrix.ruby_version }}
20
- bundler-cache: true
21
- - name: Build and test with Rake
22
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- .bundle/
2
- coverage/
3
- .watchr
4
-
5
- *.gem
6
- *.log
7
- *.lock
8
- *.sqlite3
9
- **/*.gem
10
- **/*.log
11
- **/*.lock
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- rails-7.1
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-3.2.2
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- group :test do
5
- gem "observr"
6
- gem "ricecream"
7
- gem "rubocop", require: false
8
- gem "simplecov", require: false
9
- end
data/Gemfile.lock DELETED
@@ -1,60 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- microfsm (0.1.7)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- docile (1.4.0)
11
- json (2.7.1)
12
- language_server-protocol (3.17.0.3)
13
- minitest (5.20.0)
14
- observr (1.0.5)
15
- parallel (1.23.0)
16
- parser (3.2.2.4)
17
- ast (~> 2.4.1)
18
- racc
19
- racc (1.7.3)
20
- rainbow (3.1.1)
21
- rake (13.1.0)
22
- regexp_parser (2.8.3)
23
- rexml (3.2.6)
24
- ricecream (0.2.1)
25
- rubocop (1.59.0)
26
- json (~> 2.3)
27
- language_server-protocol (>= 3.17.0)
28
- parallel (~> 1.10)
29
- parser (>= 3.2.2.4)
30
- rainbow (>= 2.2.2, < 4.0)
31
- regexp_parser (>= 1.8, < 3.0)
32
- rexml (>= 3.2.5, < 4.0)
33
- rubocop-ast (>= 1.30.0, < 2.0)
34
- ruby-progressbar (~> 1.7)
35
- unicode-display_width (>= 2.4.0, < 3.0)
36
- rubocop-ast (1.30.0)
37
- parser (>= 3.2.1.0)
38
- ruby-progressbar (1.13.0)
39
- simplecov (0.22.0)
40
- docile (~> 1.1)
41
- simplecov-html (~> 0.11)
42
- simplecov_json_formatter (~> 0.1)
43
- simplecov-html (0.12.3)
44
- simplecov_json_formatter (0.1.4)
45
- unicode-display_width (2.5.0)
46
-
47
- PLATFORMS
48
- x86_64-linux
49
-
50
- DEPENDENCIES
51
- microfsm!
52
- minitest
53
- observr
54
- rake
55
- ricecream
56
- rubocop
57
- simplecov
58
-
59
- BUNDLED WITH
60
- 2.4.22
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021-2023 Dittmar Krall (www.matiq.com)
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
13
- all 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
21
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "rake"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs.push "test"
6
- t.pattern = "test/*_test.rb"
7
- end
8
-
9
- desc "Default: run unit tests."
10
- task default: :test
data/microfsm.gemspec DELETED
@@ -1,19 +0,0 @@
1
- $LOAD_PATH.push File.expand_path("lib", __dir__)
2
- require "version"
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "microfsm"
6
- s.version = MicroFSM::VERSION
7
- s.summary = %(Minimal Finite State Machine.)
8
- s.description = %{MicroFSM implements a minimal/simple Finite-State Machine (FSM). Transitions are triggered by events. Actions for a transition can be added as callbacks.}
9
- s.authors = ["Dittmar Krall"]
10
- s.email = "dittmar.krall@matiq.com"
11
- s.homepage = "https://github.com/matique/microfsm"
12
- s.license = "MIT"
13
- s.platform = Gem::Platform::RUBY
14
-
15
- s.files = `git ls-files`.split("\n")
16
-
17
- s.add_development_dependency "rake"
18
- s.add_development_dependency "minitest"
19
- end
@@ -1,35 +0,0 @@
1
- require "test_helper"
2
-
3
- describe MicroFSM do
4
- let(:fsm) {
5
- MicroFSM.new(:pending)
6
- .when(:confirm, pending: :confirmed) { @state = "Confirmed" }
7
- .when(:reset, confirmed: :pending) { @state = "Pending" }
8
- }
9
-
10
- def test_executes_callbacks_during_transition
11
- fsm.trigger(:confirm)
12
- assert_equal "Confirmed", @state
13
-
14
- fsm.trigger(:reset)
15
- assert_equal "Pending", @state
16
- end
17
-
18
- def test_two_callbacks_during_transition
19
- fsm.when(:confirm, pending: :confirmed) { @state2 = "Confirmed2" }
20
-
21
- fsm.trigger(:confirm)
22
- assert_equal "Confirmed", @state
23
- assert_equal "Confirmed2", @state2
24
- end
25
-
26
- def test_passing_the_event_name_to_the_callbacks
27
- event_name = nil
28
- fsm.when(:confirm, pending: :confirmed) do |event|
29
- event_name = event
30
- end
31
-
32
- fsm.trigger(:confirm)
33
- assert_equal :confirm, event_name
34
- end
35
- end
@@ -1,22 +0,0 @@
1
- require "test_helper"
2
-
3
- describe MicroFSM do
4
- let(:fsm) {
5
- MicroFSM.new(:pending)
6
- .when(:confirm, pending: :confirmed)
7
- .when(:ignore, pending: :ignored)
8
- .when(:reset, confirmed: :pending, ignored: :pending)
9
- }
10
-
11
- def test_returns_an_array_with_the_defined_events
12
- assert_equal %i[confirm ignore reset], fsm.events
13
- end
14
-
15
- def test_list_the_available_events_for_the_current_state
16
- assert_equal %i[confirm ignore], fsm.triggerable_events
17
- end
18
-
19
- def test_returns_an_array_with_the_defined_states
20
- assert_equal %i[confirmed ignored pending], fsm.states
21
- end
22
- end
@@ -1,72 +0,0 @@
1
- require "test_helper"
2
-
3
- describe MicroFSM do
4
- let(:fsm) {
5
- MicroFSM.new(:pending)
6
- .when(:confirm, pending: :confirmed)
7
- .when(:ignore, pending: :ignored)
8
- .when(:reset, confirmed: :pending, ignored: :pending)
9
- }
10
-
11
- def test_class
12
- assert_kind_of MicroFSM, fsm
13
- end
14
-
15
- def test_defines_initial_state
16
- assert_equal :pending, fsm.state
17
- end
18
-
19
- def test_changes_the_state
20
- assert fsm.trigger?(:confirm)
21
- assert fsm.trigger(:confirm)
22
- assert_equal :confirmed, fsm.state
23
- end
24
-
25
- def test_preserves_the_state_if_transition_is_not_possible
26
- refute fsm.trigger?(:reset)
27
- refute fsm.trigger(:reset)
28
- assert_equal :pending, fsm.state
29
- end
30
-
31
- def test_multiple_transitions
32
- fsm.trigger(:confirm)
33
- assert_equal :confirmed, fsm.state
34
-
35
- fsm.trigger(:reset)
36
- assert_equal :pending, fsm.state
37
-
38
- fsm.trigger(:ignore)
39
- assert_equal :ignored, fsm.state
40
-
41
- fsm.trigger(:reset)
42
- assert_equal :pending, fsm.state
43
- end
44
-
45
- def test_raises_an_error_if_an_invalid_event_is_triggered
46
- assert_raises(MicroFSM::InvalidEvent) do
47
- fsm.trigger(:random_event)
48
- end
49
- end
50
-
51
- def test_raises_error_if_trigger_from_incompatible_state
52
- assert_raises(MicroFSM::InvalidState) do
53
- fsm.trigger!(:reset)
54
- end
55
- end
56
-
57
- def test_raises_an_error_if_a_transition_is_overwritten
58
- fsm = MicroFSM.new(:init)
59
-
60
- fsm.when(:trigger, init: :started)
61
- assert_raises(MicroFSM::InvalidTransition) do
62
- fsm.when(:trigger, init: :wrong)
63
- end
64
- end
65
-
66
- def test_state_assign
67
- new_state = :unknown
68
- refute_equal new_state, fsm.state
69
- fsm.state = new_state
70
- assert_equal new_state, fsm.state
71
- end
72
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- if ENV["COVERAGE"]
2
- require "simplecov"
3
- SimpleCov.start do
4
- add_filter "/test/"
5
- end
6
- end
7
-
8
- require "minitest/autorun"
9
-
10
- require "microfsm"