graphviz_transitions 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/graphviz_transitions.rb +16 -4
- data/lib/graphviz_transitions/version.rb +1 -1
- data/lib/tasks/graphviz_transitions.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aec6e508b2b8be23f3bbb176e637cf566455b3b
|
4
|
+
data.tar.gz: f49a4f08a5c9d6157896a9aadf1ecb510384c7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e4559d88709718b664b9109699c1c6ec9d61a8d2c58e60857f973ae9b73edfe89de94126a57621da49caa0068f4d5b1c5fdbb031223b89f25bccade0c31fe2
|
7
|
+
data.tar.gz: cb566a761fd77803267aa57774a8f2733628b4ca216383a074d8639e7305faf47edd4b177456ceb654f0cb4dc52e6482eba6fe6517c8524aa35fde2f8099c647
|
data/README.md
CHANGED
@@ -26,8 +26,11 @@ To generate a graph for a specific model:
|
|
26
26
|
|
27
27
|
To save files to a specific path:
|
28
28
|
|
29
|
-
$ rake
|
29
|
+
$ rake transitions:draw CLASS=Vehicle,Vehicle::Color TARGET=./tmp
|
30
30
|
|
31
|
+
If you only use symbolized method names in your event guards and you want to display them :
|
32
|
+
|
33
|
+
$ rake transitions:draw CLASS=Vehicle GUARDS=true
|
31
34
|
|
32
35
|
## Contributing
|
33
36
|
|
data/lib/graphviz_transitions.rb
CHANGED
@@ -9,6 +9,8 @@ module Transitions
|
|
9
9
|
def self.draw(class_names, options = {})
|
10
10
|
raise ArgumentError, "At least one class must be specified" unless class_names && class_names.split(',').any?
|
11
11
|
|
12
|
+
event_options = options.extract!(:guards)
|
13
|
+
|
12
14
|
class_names.split(',').each do |class_name|
|
13
15
|
klass = class_name.constantize
|
14
16
|
|
@@ -19,7 +21,7 @@ module Transitions
|
|
19
21
|
end
|
20
22
|
|
21
23
|
klass.get_state_machine.events.values.each do |event|
|
22
|
-
event.draw(graph)
|
24
|
+
event.draw(graph, event_options)
|
23
25
|
end
|
24
26
|
graph.output
|
25
27
|
end
|
@@ -29,7 +31,7 @@ module Transitions
|
|
29
31
|
Transitions::State.class_eval do
|
30
32
|
|
31
33
|
def draw(graph)
|
32
|
-
node = graph.add_nodes(self.name.to_s.humanize, shape: final? ? "doublecircle" : "
|
34
|
+
node = graph.add_nodes(self.name.to_s.humanize, shape: final? ? "doublecircle" : "box")
|
33
35
|
graph.add_edge(graph.add_nodes("starting_state", shape: "point"), node) if initial?
|
34
36
|
end
|
35
37
|
|
@@ -49,9 +51,19 @@ module Transitions
|
|
49
51
|
end
|
50
52
|
|
51
53
|
Transitions::Event.class_eval do
|
52
|
-
def draw(graph)
|
54
|
+
def draw(graph, options)
|
53
55
|
@transitions.each do |transition|
|
54
|
-
|
56
|
+
label= "<<FONT> #{name.to_s.humanize} </FONT>"
|
57
|
+
|
58
|
+
if options.key?(:guards) and transition.instance_variable_get('@guard').present?
|
59
|
+
label << "<br/><br/>"
|
60
|
+
label = [transition.instance_variable_get('@guard')].flatten.inject("#{label}") do |memo, guard|
|
61
|
+
memo << "<FONT POINT-SIZE=\"10\"> :#{guard} </FONT><BR/>"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
label << ">"
|
65
|
+
|
66
|
+
graph.add_edge(transition.from.to_s.humanize, transition.to.to_s.humanize, label: label)
|
55
67
|
end
|
56
68
|
end
|
57
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphviz_transitions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Itkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|