microfsm 0.1.2 → 0.1.3
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 +24 -0
- data/.rubocop.yml +2 -1
- data/.watchr +8 -6
- data/Gemfile +0 -1
- data/Gemfile.lock +12 -12
- data/README.md +0 -1
- data/lib/microfsm.rb +2 -6
- data/lib/version.rb +2 -1
- data/test/test_helper.rb +1 -2
- metadata +3 -3
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50fe926fce3c8dbbf1d292a87c9b7e5fe2704a1e9b1f46bda0789654d3833b55
|
4
|
+
data.tar.gz: 363d50112d184a3a7c4c7f7698a48318377091d9001ac0afa2bb545973943293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b33f83aae371a7158cac6d858228a3c754cfad2817d7e800290f03f7f618708e051264ee8b1e580115c019dc93d085e733027d33df0d45bc772be238ff6de93
|
7
|
+
data.tar.gz: 97f593eb80c36b86cbcb4e6d08f953e4f39d8f63ae7a2d020513926876e613efb5512d4df1986f54fb876873a1554fd918ab5f29169b51411dcb340653f67624
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Rake
|
2
|
+
|
3
|
+
#on: [push, pull_request]
|
4
|
+
on: [push]
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
test:
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
# os: [ubuntu-latest, macos-latest]
|
12
|
+
os: [ubuntu-latest]
|
13
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
14
|
+
# ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
|
15
|
+
ruby: [2.7]
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
24
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.watchr
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
TESTING = %w[test]
|
1
2
|
HH = '#' * 22 unless defined?(HH)
|
2
3
|
H = '#' * 5 unless defined?(H)
|
3
4
|
|
@@ -16,36 +17,37 @@ end
|
|
16
17
|
|
17
18
|
def run_it(type, file)
|
18
19
|
case type
|
19
|
-
when 'test'; run %
|
20
|
+
when 'test'; run %(bundle exec ruby -I test #{file})
|
21
|
+
# when 'spec'; run %(rspec -X #{file})
|
20
22
|
else; puts "#{H} unknown type: #{type}, file: #{file}"
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def run_all_tests
|
25
27
|
puts "\n#{HH} Running all tests #{HH}\n"
|
26
|
-
|
28
|
+
TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
|
27
29
|
end
|
28
30
|
|
29
31
|
def run_matching_files(base)
|
30
32
|
base = base.split('_').first
|
31
|
-
|
33
|
+
TESTING.each { |type|
|
32
34
|
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
|
33
35
|
run_it type, files.join(' ') unless files.empty?
|
34
36
|
}
|
35
37
|
end
|
36
38
|
|
37
|
-
|
39
|
+
TESTING.each { |type|
|
38
40
|
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
|
41
|
+
watch('lib/.*\.rb') { run_all_tests }
|
39
42
|
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
|
40
43
|
watch("#{type}/data/(.*)\.rb") { |match|
|
41
44
|
m1 = match[1]
|
42
45
|
run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb")
|
43
46
|
}
|
44
47
|
}
|
48
|
+
|
45
49
|
%w[rb erb haml slim].each { |type|
|
46
|
-
# watch("app/.*/(.*)\.#{type}") { |match|
|
47
50
|
watch(".*/(.*)\.#{type}") { |match|
|
48
|
-
p [11, match]
|
49
51
|
run_matching_files(match[1])
|
50
52
|
}
|
51
53
|
}
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
microfsm (0.
|
4
|
+
microfsm (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
docile (1.
|
11
|
-
minitest (5.14.
|
10
|
+
docile (1.4.0)
|
11
|
+
minitest (5.14.4)
|
12
12
|
observr (1.0.5)
|
13
13
|
parallel (1.20.1)
|
14
|
-
parser (3.0.
|
14
|
+
parser (3.0.1.1)
|
15
15
|
ast (~> 2.4.1)
|
16
16
|
rainbow (3.0.0)
|
17
17
|
rake (13.0.3)
|
18
|
-
regexp_parser (2.
|
19
|
-
rexml (3.2.
|
20
|
-
rubocop (1.
|
18
|
+
regexp_parser (2.1.1)
|
19
|
+
rexml (3.2.5)
|
20
|
+
rubocop (1.17.0)
|
21
21
|
parallel (~> 1.10)
|
22
22
|
parser (>= 3.0.0.0)
|
23
23
|
rainbow (>= 2.2.2, < 4.0)
|
24
24
|
regexp_parser (>= 1.8, < 3.0)
|
25
25
|
rexml
|
26
|
-
rubocop-ast (>= 1.
|
26
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
27
27
|
ruby-progressbar (~> 1.7)
|
28
28
|
unicode-display_width (>= 1.4.0, < 3.0)
|
29
|
-
rubocop-ast (1.
|
30
|
-
parser (>=
|
29
|
+
rubocop-ast (1.7.0)
|
30
|
+
parser (>= 3.0.1.1)
|
31
31
|
ruby-progressbar (1.11.0)
|
32
32
|
simplecov (0.21.2)
|
33
33
|
docile (~> 1.1)
|
34
34
|
simplecov-html (~> 0.11)
|
35
35
|
simplecov_json_formatter (~> 0.1)
|
36
36
|
simplecov-html (0.12.3)
|
37
|
-
simplecov_json_formatter (0.1.
|
37
|
+
simplecov_json_formatter (0.1.3)
|
38
38
|
unicode-display_width (2.0.0)
|
39
39
|
|
40
40
|
PLATFORMS
|
@@ -50,4 +50,4 @@ DEPENDENCIES
|
|
50
50
|
simplecov
|
51
51
|
|
52
52
|
BUNDLED WITH
|
53
|
-
2.2.
|
53
|
+
2.2.17
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@ MicroFSM
|
|
2
2
|
========
|
3
3
|
|
4
4
|
[![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
5
|
|
7
6
|
MicroFSM implements a minimal/simple Finite-State Machine (FSM).
|
8
7
|
Transitions are triggered by events.
|
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,10 +55,6 @@ class MicroFSM
|
|
55
55
|
@transitions_for.values.map(&:to_a).flatten.uniq.sort
|
56
56
|
end
|
57
57
|
|
58
|
-
def state=(state)
|
59
|
-
@state = state
|
60
|
-
end
|
61
|
-
|
62
58
|
private
|
63
59
|
def transit(event)
|
64
60
|
callbacks = @callbacks_for[event][@state]
|
data/lib/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,10 +59,10 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/rake.yml"
|
62
63
|
- ".rubocop.yml"
|
63
64
|
- ".ruby-gemset"
|
64
65
|
- ".ruby-version"
|
65
|
-
- ".travis.yml"
|
66
66
|
- ".watchr"
|
67
67
|
- Gemfile
|
68
68
|
- Gemfile.lock
|
data/.travis.yml
DELETED