microfsm 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +26 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +5 -5
- data/Gemfile.lock +22 -18
- data/LICENSE +3 -1
- data/README.md +30 -34
- data/Rakefile +6 -6
- data/examples/advanced.rb +5 -5
- data/examples/basic.rb +4 -4
- data/examples/callbacks.rb +6 -6
- data/lib/microfsm.rb +3 -6
- data/lib/version.rb +5 -3
- data/microfsm.gemspec +12 -11
- data/test/callbacks_test.rb +4 -4
- data/test/introspection_test.rb +5 -5
- data/test/microfsm_test.rb +5 -5
- data/test/test_helper.rb +5 -6
- metadata +6 -8
- data/.rubocop.yml +0 -19
- data/.travis.yml +0 -15
- data/.watchr +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afc1b721660dde4225b57491fc30f99a4776473d918c7bb75fe59c103b6da37d
|
4
|
+
data.tar.gz: 575c2c67815e3ee7250c4aa49ab4a19a952c59bad6bf006cd9cb5b8d09066796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 146a4d85345da08f2030767fb4a203d6e4516004da3ee55e8b115d17f5ef297824d72bfbc828e49369f82ae0cb71853415464f881bc6a32654de96218d465778
|
7
|
+
data.tar.gz: 407ccf0c6a370b65f7802256bcf588e73f85b604f005e2980ec2e7f223348d6934e43ef1dd371fa82f2085cd2fbb606e73a659bf117528c795a028f954d58bec
|
@@ -0,0 +1,26 @@
|
|
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
|
+
os: [ubuntu-latest]
|
12
|
+
ruby: ["2.7", "3.0", "3.1", head]
|
13
|
+
test_command: ["bundle exec rake test"]
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v3
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- name: Bundle install
|
22
|
+
run: |
|
23
|
+
bundle config path /home/runner/bundle
|
24
|
+
bundle install
|
25
|
+
bundle update
|
26
|
+
- run: ${{ matrix.test_command }}
|
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails-
|
1
|
+
rails-7.0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.1.3
|
data/Gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
source
|
2
|
-
|
1
|
+
source "https://rubygems.org"
|
3
2
|
gemspec
|
4
3
|
|
5
4
|
group :test do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
5
|
+
gem "observr"
|
6
|
+
gem "ricecream"
|
7
|
+
gem "rubocop", require: false
|
8
|
+
gem "simplecov", require: false
|
9
9
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
microfsm (0.
|
4
|
+
microfsm (0.1.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
docile (1.
|
11
|
-
|
10
|
+
docile (1.4.0)
|
11
|
+
json (2.6.3)
|
12
|
+
minitest (5.16.3)
|
12
13
|
observr (1.0.5)
|
13
|
-
parallel (1.
|
14
|
-
parser (3.
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.1.3.0)
|
15
16
|
ast (~> 2.4.1)
|
16
|
-
rainbow (3.
|
17
|
-
rake (13.0.
|
18
|
-
regexp_parser (2.
|
19
|
-
rexml (3.2.
|
20
|
-
|
17
|
+
rainbow (3.1.1)
|
18
|
+
rake (13.0.6)
|
19
|
+
regexp_parser (2.6.1)
|
20
|
+
rexml (3.2.5)
|
21
|
+
ricecream (0.2.1)
|
22
|
+
rubocop (1.41.1)
|
23
|
+
json (~> 2.3)
|
21
24
|
parallel (~> 1.10)
|
22
|
-
parser (>= 3.
|
25
|
+
parser (>= 3.1.2.1)
|
23
26
|
rainbow (>= 2.2.2, < 4.0)
|
24
27
|
regexp_parser (>= 1.8, < 3.0)
|
25
|
-
rexml
|
26
|
-
rubocop-ast (>= 1.
|
28
|
+
rexml (>= 3.2.5, < 4.0)
|
29
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
27
30
|
ruby-progressbar (~> 1.7)
|
28
31
|
unicode-display_width (>= 1.4.0, < 3.0)
|
29
|
-
rubocop-ast (1.
|
30
|
-
parser (>=
|
32
|
+
rubocop-ast (1.24.0)
|
33
|
+
parser (>= 3.1.1.0)
|
31
34
|
ruby-progressbar (1.11.0)
|
32
35
|
simplecov (0.21.2)
|
33
36
|
docile (~> 1.1)
|
34
37
|
simplecov-html (~> 0.11)
|
35
38
|
simplecov_json_formatter (~> 0.1)
|
36
39
|
simplecov-html (0.12.3)
|
37
|
-
simplecov_json_formatter (0.1.
|
38
|
-
unicode-display_width (2.
|
40
|
+
simplecov_json_formatter (0.1.4)
|
41
|
+
unicode-display_width (2.3.0)
|
39
42
|
|
40
43
|
PLATFORMS
|
41
44
|
x86_64-linux
|
@@ -46,8 +49,9 @@ DEPENDENCIES
|
|
46
49
|
minitest
|
47
50
|
observr
|
48
51
|
rake
|
52
|
+
ricecream
|
49
53
|
rubocop
|
50
54
|
simplecov
|
51
55
|
|
52
56
|
BUNDLED WITH
|
53
|
-
2.
|
57
|
+
2.3.26
|
data/LICENSE
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021-2022 Dittmar Krall (www.matiq.com)
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
MicroFSM
|
2
|
-
========
|
1
|
+
# MicroFSM
|
3
2
|
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/microfsm.svg)](https://badge.fury.io/rb/microfsm)
|
5
|
-
[![Build Status](https://travis-ci.org/matique/microfsm.svg?branch=master)](https://travis-ci.org/matique/microfsm)
|
6
4
|
|
7
5
|
MicroFSM implements a minimal/simple Finite-State Machine (FSM).
|
8
6
|
Transitions are triggered by events.
|
@@ -16,33 +14,27 @@ Please feel free to use any of them if they fit better to your work.
|
|
16
14
|
The MicroFSM code consists of less than 100 locs.
|
17
15
|
No magic, no niceties, just an implementation using Ruby hashes.
|
18
16
|
|
19
|
-
Installation
|
20
|
-
------------
|
17
|
+
## Installation
|
21
18
|
|
22
|
-
|
19
|
+
As usual:
|
20
|
+
```ruby
|
23
21
|
# Gemfile
|
24
22
|
gem "microfsm"
|
23
|
+
```
|
24
|
+
and run "bundle install".
|
25
25
|
|
26
|
-
|
26
|
+
## Usage
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
$ [sudo] gem install microfsm
|
31
|
-
~~~~
|
32
|
-
|
33
|
-
Usage
|
34
|
-
-----
|
35
|
-
|
36
|
-
~~~~
|
28
|
+
```ruby
|
37
29
|
require 'microfsm'
|
38
30
|
|
39
31
|
fsm = MicroFSM.new(:new) # Initial state.
|
40
32
|
|
41
33
|
# Define the possible transitions for each event.
|
42
34
|
# Template: fsm.when(<event>, <from> => <to>)
|
43
|
-
fsm.when(:confirm, :
|
44
|
-
fsm.when(:ignore, :
|
45
|
-
fsm.when(:reset, :
|
35
|
+
fsm.when(:confirm, new: :confirmed)
|
36
|
+
fsm.when(:ignore, new: :ignored)
|
37
|
+
fsm.when(:reset, confirmed: :new, ignored: :new)
|
46
38
|
|
47
39
|
fsm.trigger(:confirm) #=> true
|
48
40
|
fsm.state #=> :confirmed
|
@@ -55,12 +47,12 @@ fsm.state #=> :new
|
|
55
47
|
|
56
48
|
fsm.trigger(:ignore) #=> true
|
57
49
|
fsm.state #=> :ignored
|
58
|
-
|
50
|
+
```
|
59
51
|
|
60
52
|
You can also ask if an event will trigger a change in state.
|
61
53
|
Following the example above:
|
62
54
|
|
63
|
-
|
55
|
+
```ruby
|
64
56
|
fsm.state #=> :ignored
|
65
57
|
|
66
58
|
fsm.trigger?(:ignore) #=> false
|
@@ -68,27 +60,25 @@ fsm.trigger?(:reset) #=> true
|
|
68
60
|
|
69
61
|
# And the state is preserved, because you were only asking.
|
70
62
|
fsm.state #=> :ignored
|
71
|
-
|
63
|
+
```
|
72
64
|
|
73
|
-
Actions
|
74
|
-
-------
|
65
|
+
## Actions
|
75
66
|
|
76
67
|
Adding actions to a transition is trivial:
|
77
68
|
|
78
|
-
|
69
|
+
```ruby
|
79
70
|
fsm.when(:confirm, new: :confirmed) { |event| count += 1 }
|
80
71
|
fsm.when(:confirm, new: :confirmed) { |event| foo(event) }
|
81
|
-
|
72
|
+
```
|
82
73
|
|
83
74
|
Two actions/callbacks are triggered in the previous example.
|
84
75
|
|
85
76
|
|
86
|
-
Miscellaneous
|
87
|
-
-------------
|
77
|
+
## Miscellaneous
|
88
78
|
|
89
79
|
Finally, you can list possible events or states:
|
90
80
|
|
91
|
-
|
81
|
+
```ruby
|
92
82
|
# All possible events
|
93
83
|
fsm.events #=> [:confirm, :ignore, :reset]
|
94
84
|
|
@@ -97,19 +87,25 @@ fsm.triggerable_events #=> [:confirm, :ignore]
|
|
97
87
|
|
98
88
|
# All possible states
|
99
89
|
fsm.states #=> [:new, :confirmed, :ignored]
|
100
|
-
|
90
|
+
```
|
101
91
|
|
102
92
|
And, the state can be set (which may be useful for testing purposes):
|
103
93
|
|
104
|
-
|
94
|
+
```ruby
|
105
95
|
fsm.state = :new
|
106
96
|
fsm.state #=> :new
|
107
|
-
|
97
|
+
```
|
108
98
|
|
109
99
|
Check the examples directory for more information.
|
110
100
|
|
111
|
-
Links
|
112
|
-
-----
|
101
|
+
## Links
|
113
102
|
|
114
103
|
- [Wikipedia](https://en.wikipedia.org/wiki/Finite-state_machine)
|
115
104
|
- [micromachine](https://github.com/soveran/micromachine)
|
105
|
+
|
106
|
+
## Miscellaneous
|
107
|
+
|
108
|
+
Copyright (c) 2021-2022 Dittmar Krall (www.matiq.com),
|
109
|
+
released under the MIT license:
|
110
|
+
|
111
|
+
* https://opensource.org/licenses/MIT
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rake"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
4
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs.push
|
6
|
-
t.pattern =
|
5
|
+
t.libs.push "test"
|
6
|
+
t.pattern = "test/*_test.rb"
|
7
7
|
end
|
8
8
|
|
9
|
-
desc
|
10
|
-
task :
|
9
|
+
desc "Default: run unit tests."
|
10
|
+
task default: :test
|
data/examples/advanced.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "microfsm"
|
2
2
|
|
3
3
|
# This example can be run with ruby -I lib/ ./examples/advanced.rb
|
4
4
|
|
5
5
|
fsm = MicroFSM.new(:pending)
|
6
|
-
proc = ->
|
7
|
-
fsm.when(:confirm, :
|
8
|
-
|
9
|
-
|
6
|
+
proc = ->(event) { puts fsm.state.capitalize }
|
7
|
+
fsm.when(:confirm, pending: :confirmed, &proc)
|
8
|
+
.when(:ignore, pending: :ignored, &proc)
|
9
|
+
.when(:reset, confirmed: :pending, ignored: :pending, &proc)
|
10
10
|
|
11
11
|
puts "Should print Confirmed, Pending and Ignored:"
|
12
12
|
fsm.trigger(:confirm)
|
data/examples/basic.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "microfsm"
|
2
2
|
|
3
3
|
# This example can be run with ruby -I lib/ ./examples/basic.rb
|
4
4
|
|
5
5
|
fsm = MicroFSM.new(:pending)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
.when(:confirm, pending: :confirmed)
|
7
|
+
.when(:ignore, pending: :ignored)
|
8
|
+
.when(:reset, confirmed: :pending, ignored: :pending)
|
9
9
|
|
10
10
|
puts "Should print Confirmed, Reset and Ignored:"
|
11
11
|
|
data/examples/callbacks.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "microfsm"
|
2
2
|
|
3
3
|
# This example can be run with ruby -I lib/ ./examples/callbacks.rb
|
4
4
|
|
5
5
|
fsm = MicroFSM.new(:pending)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
.when(:confirm, pending: :confirmed) { puts "Confirmed" }
|
7
|
+
.when(:ignore, pending: :ignored) { puts "Ignored" }
|
8
|
+
.when(:reset, confirmed: :pending, ignored: :pending) {
|
9
|
+
puts "Reset"
|
10
|
+
}
|
11
11
|
|
12
12
|
puts "Should print Confirmed, Reset and Ignored:"
|
13
13
|
fsm.trigger(:confirm)
|
data/lib/microfsm.rb
CHANGED
@@ -5,7 +5,7 @@ class MicroFSM
|
|
5
5
|
InvalidState = Class.new(ArgumentError)
|
6
6
|
InvalidTransition = Class.new(ArgumentError)
|
7
7
|
|
8
|
-
|
8
|
+
attr_accessor :state
|
9
9
|
|
10
10
|
def initialize(initial_state)
|
11
11
|
@state = initial_state
|
@@ -23,7 +23,7 @@ class MicroFSM
|
|
23
23
|
|
24
24
|
@transitions_for[event][from] = to
|
25
25
|
@callbacks_for[event][from] ||= []
|
26
|
-
@callbacks_for[event][from] << block if
|
26
|
+
@callbacks_for[event][from] << block if block
|
27
27
|
end
|
28
28
|
self
|
29
29
|
end
|
@@ -55,11 +55,8 @@ class MicroFSM
|
|
55
55
|
@transitions_for.values.map(&:to_a).flatten.uniq.sort
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
@state = state
|
60
|
-
end
|
58
|
+
private
|
61
59
|
|
62
|
-
private
|
63
60
|
def transit(event)
|
64
61
|
callbacks = @callbacks_for[event][@state]
|
65
62
|
@state = @transitions_for[event][@state]
|
data/lib/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class MicroFSM
|
4
|
-
VERSION =
|
5
|
-
# VERSION =
|
6
|
-
# VERSION =
|
4
|
+
VERSION = "0.1.4" # 2022-12-22
|
5
|
+
# VERSION = "0.1.3" # 2021-06-22
|
6
|
+
# VERSION = "0.1.2" # 2021-02-10
|
7
|
+
# VERSION = "0.1.1" # 2021-02-08
|
8
|
+
# VERSION = "0.0.1" # 2021-01-24
|
7
9
|
end
|
data/microfsm.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path(
|
2
|
-
require
|
1
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
2
|
+
require "version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "microfsm"
|
6
6
|
s.version = MicroFSM::VERSION
|
7
|
-
s.summary = %
|
8
|
-
s.description = %
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.homepage =
|
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://matiq.com"
|
12
12
|
s.license = "MIT"
|
13
|
+
s.platform = Gem::Platform::RUBY
|
13
14
|
|
14
|
-
s.metadata[
|
15
|
+
s.metadata["source_code_uri"] = "https://github.com/matique/microfsm"
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
|
18
|
-
s.add_development_dependency
|
19
|
-
s.add_development_dependency
|
19
|
+
s.add_development_dependency "bundler"
|
20
|
+
s.add_development_dependency "rake"
|
20
21
|
|
21
|
-
s.add_development_dependency
|
22
|
+
s.add_development_dependency "minitest"
|
22
23
|
end
|
data/test/callbacks_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe MicroFSM do
|
4
|
-
let
|
4
|
+
let(:fsm) {
|
5
5
|
MicroFSM.new(:pending)
|
6
|
-
|
7
|
-
|
6
|
+
.when(:confirm, pending: :confirmed) { @state = "Confirmed" }
|
7
|
+
.when(:reset, confirmed: :pending) { @state = "Pending" }
|
8
8
|
}
|
9
9
|
|
10
10
|
def test_executes_callbacks_during_transition
|
data/test/introspection_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe MicroFSM do
|
4
|
-
let
|
4
|
+
let(:fsm) {
|
5
5
|
MicroFSM.new(:pending)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
.when(:confirm, pending: :confirmed)
|
7
|
+
.when(:ignore, pending: :ignored)
|
8
|
+
.when(:reset, confirmed: :pending, ignored: :pending)
|
9
9
|
}
|
10
10
|
|
11
11
|
def test_returns_an_array_with_the_defined_events
|
data/test/microfsm_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe MicroFSM do
|
4
|
-
let
|
4
|
+
let(:fsm) {
|
5
5
|
MicroFSM.new(:pending)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
.when(:confirm, pending: :confirmed)
|
7
|
+
.when(:ignore, pending: :ignored)
|
8
|
+
.when(:reset, confirmed: :pending, ignored: :pending)
|
9
9
|
}
|
10
10
|
|
11
11
|
def test_class
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
if ENV[
|
2
|
-
require
|
1
|
+
if ENV["COVERAGE"]
|
2
|
+
require "simplecov"
|
3
3
|
SimpleCov.start do
|
4
|
-
add_filter
|
5
|
-
command_name 'Minitest'
|
4
|
+
add_filter "/test/"
|
6
5
|
end
|
7
6
|
end
|
8
7
|
|
9
|
-
require
|
8
|
+
require "minitest/autorun"
|
10
9
|
|
11
|
-
require
|
10
|
+
require "microfsm"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microfsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,16 +54,14 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
description: MicroFSM implements a minimal/simple Finite-State Machine (FSM). Transitions
|
56
56
|
are triggered by events. Actions for a transition can be added as callbacks.
|
57
|
-
email: dittmar.krall@
|
57
|
+
email: dittmar.krall@matiq.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- ".
|
62
|
+
- ".github/workflows/rake.yml"
|
63
63
|
- ".ruby-gemset"
|
64
64
|
- ".ruby-version"
|
65
|
-
- ".travis.yml"
|
66
|
-
- ".watchr"
|
67
65
|
- Gemfile
|
68
66
|
- Gemfile.lock
|
69
67
|
- LICENSE
|
@@ -79,7 +77,7 @@ files:
|
|
79
77
|
- test/introspection_test.rb
|
80
78
|
- test/microfsm_test.rb
|
81
79
|
- test/test_helper.rb
|
82
|
-
homepage: https://
|
80
|
+
homepage: https://matiq.com
|
83
81
|
licenses:
|
84
82
|
- MIT
|
85
83
|
metadata:
|
@@ -99,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
97
|
- !ruby/object:Gem::Version
|
100
98
|
version: '0'
|
101
99
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.3.26
|
103
101
|
signing_key:
|
104
102
|
specification_version: 4
|
105
103
|
summary: Minimal Finite State Machine.
|
data/.rubocop.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
inherit_from:
|
2
|
-
- ~/configs/.rubocop.yml
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
Include:
|
6
|
-
- 'lib/**/*.rb'
|
7
|
-
|
8
|
-
Exclude:
|
9
|
-
- 'bin/**/*'
|
10
|
-
- 'test/**/*'
|
11
|
-
SuggestExtensions: false
|
12
|
-
|
13
|
-
Layout/AccessModifierIndentation:
|
14
|
-
Enabled: false
|
15
|
-
Layout/EmptyLinesAroundAccessModifier:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
Metrics/AbcSize:
|
19
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/.watchr
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
HH = '#' * 22 unless defined?(HH)
|
2
|
-
H = '#' * 5 unless defined?(H)
|
3
|
-
|
4
|
-
def usage
|
5
|
-
puts <<-EOS
|
6
|
-
Ctrl-\\ or ctrl-4 Running all tests
|
7
|
-
Ctrl-C Exit
|
8
|
-
EOS
|
9
|
-
end
|
10
|
-
|
11
|
-
def run(cmd)
|
12
|
-
puts "#{HH} #{Time.now} #{HH}"
|
13
|
-
puts "#{H} #{cmd}"
|
14
|
-
system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def run_it(type, file)
|
18
|
-
case type
|
19
|
-
when 'test'; run %Q(ruby -I"lib:test" -r rubygems #{file})
|
20
|
-
else; puts "#{H} unknown type: #{type}, file: #{file}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def run_all_tests
|
25
|
-
puts "\n#{HH} Running all tests #{HH}\n"
|
26
|
-
%w[test].each { |dir| run "rake #{dir}" if File.exist?(dir) }
|
27
|
-
end
|
28
|
-
|
29
|
-
def run_matching_files(base)
|
30
|
-
base = base.split('_').first
|
31
|
-
%w[test spec].each { |type|
|
32
|
-
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
|
33
|
-
run_it type, files.join(' ') unless files.empty?
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
%w[test spec].each { |type|
|
38
|
-
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
|
39
|
-
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
|
40
|
-
watch("#{type}/data/(.*)\.rb") { |match|
|
41
|
-
m1 = match[1]
|
42
|
-
run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb")
|
43
|
-
}
|
44
|
-
}
|
45
|
-
%w[rb erb haml slim].each { |type|
|
46
|
-
# watch("app/.*/(.*)\.#{type}") { |match|
|
47
|
-
watch(".*/(.*)\.#{type}") { |match|
|
48
|
-
p [11, match]
|
49
|
-
run_matching_files(match[1])
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
# Ctrl-\ or ctrl-4
|
54
|
-
Signal.trap('QUIT') { run_all_tests }
|
55
|
-
# Ctrl-C
|
56
|
-
Signal.trap('INT') { abort("Interrupted\n") }
|
57
|
-
usage
|