simplificator-fsm 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/fsm/machine.rb +18 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/fsm/machine.rb
CHANGED
@@ -79,6 +79,24 @@ module FSM
|
|
79
79
|
state
|
80
80
|
end
|
81
81
|
|
82
|
+
def to_dot
|
83
|
+
dots = self.transitions.map do |transition|
|
84
|
+
" #{transition.from.name} -> #{transition.to.name}"
|
85
|
+
end
|
86
|
+
"digraph FSM {\n#{dots.join(";\n")}\n}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def dot(options = {})
|
90
|
+
format = options[:format] || :png
|
91
|
+
extension = options[:extension] || format
|
92
|
+
file_name = options[:outfile] || "#{@target_class.name.downcase}.#{extension}"
|
93
|
+
cmd = "dot -T#{format} -o#{file_name}"
|
94
|
+
IO.popen cmd, 'w' do |io|
|
95
|
+
io.write to_dot
|
96
|
+
end
|
97
|
+
raise 'dot failed' unless $?.success?
|
98
|
+
end
|
99
|
+
|
82
100
|
private
|
83
101
|
|
84
102
|
# defines a transition method on the target class.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplificator-fsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simplificator
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|