rails_machine 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_machine/configuration.rb +25 -17
- data/lib/rails_machine/version.rb +1 -1
- data/lib/rails_machine.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7e1659eebf7238e7fbb2e3167d8b7c127a32cac
|
4
|
+
data.tar.gz: d958c76251e9b1a808c0fe2fef285b4fb73ac611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a93fbde64eca07e5584b5b3fa1ab67f32e9fc9186085e4c47d19e99e9c34a63b7575a76fdbac1b43b0ef192b069bd8c274e07cfbb3227564a2529ceb7782246
|
7
|
+
data.tar.gz: 2ecd0a3bc38a722cec81539f6ad600874008c7b51af4993ab40522640fe49b6fa63df59526cbd3a9870da83db3c478a803d0c5e135d7b55124d2882250c08e8c
|
@@ -1,24 +1,32 @@
|
|
1
1
|
module RailsMachine
|
2
|
-
|
2
|
+
class Configuration
|
3
3
|
|
4
|
-
|
4
|
+
attr_reader :states, :transitions
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def initialize
|
7
|
+
@states ||= []
|
8
|
+
@transitions ||= {}
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# Just runs code
|
12
|
+
def run(&blk)
|
13
|
+
self.instance_eval(&blk)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def state(name, id: next_id)
|
17
|
+
@states << [name, id]
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def transition(from: :any, to: :any, guards: [])
|
21
|
+
(@transitions[from] ||= [])<< { to: to, guards: guards }
|
22
|
+
end
|
23
|
+
|
24
|
+
def next_id
|
25
|
+
if @states.empty?
|
26
|
+
0
|
27
|
+
else
|
28
|
+
@states.map(&:second).max.next
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
24
32
|
end
|
data/lib/rails_machine.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Łuszczek
|
8
|
+
- Adrian Słapa
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -14,33 +15,34 @@ dependencies:
|
|
14
15
|
name: rails
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '4.1'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- -
|
25
|
+
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '4.1'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: sqlite3
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- -
|
39
|
+
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
description: Simple implementation of state machine for Rails using enums.
|
42
43
|
email:
|
43
44
|
- grzegorz@piklus.pl
|
45
|
+
- adrianouno@gmail.com
|
44
46
|
executables: []
|
45
47
|
extensions: []
|
46
48
|
extra_rdoc_files: []
|
@@ -62,12 +64,12 @@ require_paths:
|
|
62
64
|
- lib
|
63
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
66
|
requirements:
|
65
|
-
- -
|
67
|
+
- - ">="
|
66
68
|
- !ruby/object:Gem::Version
|
67
69
|
version: '2.1'
|
68
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
71
|
requirements:
|
70
|
-
- -
|
72
|
+
- - ">="
|
71
73
|
- !ruby/object:Gem::Version
|
72
74
|
version: '0'
|
73
75
|
requirements: []
|