nanomachine 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/lib/nanomachine/version.rb +1 -1
- data/nanomachine.gemspec +0 -28
- metadata +7 -57
data/CHANGES
ADDED
data/lib/nanomachine/version.rb
CHANGED
data/nanomachine.gemspec
CHANGED
@@ -6,34 +6,6 @@ require "nanomachine/version"
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "nanomachine"
|
8
8
|
gem.summary = "A really tiny state machine for ruby. No events, only acceptable transitions and transition callbacks."
|
9
|
-
gem.description = <<-DESCRIPTION.gsub(/^ */, "")
|
10
|
-
A really tiny state machine for ruby. No events, only accepted transitions and transition callbacks.
|
11
|
-
|
12
|
-
The difference between Nanomachine, and otherwise known Micromachine (https://rubygems.org/gems/micromachine) is that
|
13
|
-
Micromachine transitions to new states in response to events; multiple events can transition between the two same states.
|
14
|
-
Nanomachine, on the other hand, does not care about events, and only needs the state you want to be in after successful
|
15
|
-
transition.
|
16
|
-
|
17
|
-
Nanomachine can be used in any ruby project, and have no runtime dependencies.
|
18
|
-
|
19
|
-
Example:
|
20
|
-
state_machine = Nanomachine.new("unpublished") do |fsm|
|
21
|
-
fsm.transition("published", %w[unpublished processing removed])
|
22
|
-
fsm.transition("unpublished", %w[published processing removed])
|
23
|
-
fsm.transition("processing", %w[published unpublished])
|
24
|
-
fsm.transition("removed", []) # defined for being explicit
|
25
|
-
|
26
|
-
fsm.on_transition do |(from_state, to_state)|
|
27
|
-
update_column(:state, to_state)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if state_machine.transition_to("published")
|
32
|
-
puts "Publish success!"
|
33
|
-
else
|
34
|
-
puts "Publish failure! We’re in \#{state_machine.state}."
|
35
|
-
end
|
36
|
-
DESCRIPTION
|
37
9
|
|
38
10
|
gem.version = Nanomachine::VERSION
|
39
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanomachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-11-15 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &2167133420 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2167133420
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &2167132520 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,59 +33,8 @@ dependencies:
|
|
33
33
|
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
description:
|
38
|
-
and transition callbacks.
|
39
|
-
|
40
|
-
|
41
|
-
The difference between Nanomachine, and otherwise known Micromachine (https://rubygems.org/gems/micromachine)
|
42
|
-
is that
|
43
|
-
|
44
|
-
Micromachine transitions to new states in response to events; multiple events can
|
45
|
-
transition between the two same states.
|
46
|
-
|
47
|
-
Nanomachine, on the other hand, does not care about events, and only needs the state
|
48
|
-
you want to be in after successful
|
49
|
-
|
50
|
-
transition.
|
51
|
-
|
52
|
-
|
53
|
-
Nanomachine can be used in any ruby project, and have no runtime dependencies.
|
54
|
-
|
55
|
-
|
56
|
-
Example:
|
57
|
-
|
58
|
-
state_machine = Nanomachine.new("unpublished") do |fsm|
|
59
|
-
|
60
|
-
fsm.transition("published", %w[unpublished processing removed])
|
61
|
-
|
62
|
-
fsm.transition("unpublished", %w[published processing removed])
|
63
|
-
|
64
|
-
fsm.transition("processing", %w[published unpublished])
|
65
|
-
|
66
|
-
fsm.transition("removed", []) # defined for being explicit
|
67
|
-
|
68
|
-
|
69
|
-
fsm.on_transition do |(from_state, to_state)|
|
70
|
-
|
71
|
-
update_column(:state, to_state)
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
if state_machine.transition_to("published")
|
79
|
-
|
80
|
-
puts "Publish success!"
|
81
|
-
|
82
|
-
else
|
83
|
-
|
84
|
-
puts "Publish failure! We’re in #{state_machine.state}."
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
'
|
36
|
+
version_requirements: *2167132520
|
37
|
+
description:
|
89
38
|
email:
|
90
39
|
- crzivn@gmail.com
|
91
40
|
- kim@burgestrand.se
|
@@ -96,6 +45,7 @@ files:
|
|
96
45
|
- .gitignore
|
97
46
|
- .rspec
|
98
47
|
- .travis.yml
|
48
|
+
- CHANGES
|
99
49
|
- Gemfile
|
100
50
|
- README.md
|
101
51
|
- Rakefile
|