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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaab0ba74029bdfcc02c11031d43d3b1be8773fc
4
- data.tar.gz: 1762ecf230b3501d72701176d20b9e527f1d2d86
3
+ metadata.gz: 9aec6e508b2b8be23f3bbb176e637cf566455b3b
4
+ data.tar.gz: f49a4f08a5c9d6157896a9aadf1ecb510384c7aa
5
5
  SHA512:
6
- metadata.gz: 8b41eee2edf4db58304ef7c6a9537844a8e85117d0b105e52c2f87feead91cdc0ae6b76a35a989a4eac5d957257dcf6acdf6ddc8c0e15bedf534b31f005e45d5
7
- data.tar.gz: c45c2b5f7fcde6a71affb6fe85ffb15f2c01fa6286a6054cbc0e21ea6db584c8776b1506a1378427cbd97b429ed36e923813026b615b59d4c0531dc017e6169b
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 aasm:draw CLASS=Vehicle,Vehicle::Color TARGET=./tmp
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
 
@@ -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" : "ellipse")
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
- graph.add_edge(transition.from.to_s.humanize, transition.to.to_s.humanize, label: " #{name.to_s.humanize} ")
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
@@ -1,3 +1,3 @@
1
1
  module GraphvizTransitions
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -4,7 +4,7 @@ namespace :transitions do
4
4
  options = {}
5
5
  options[:path] = ENV['TARGET'] if ENV['TARGET']
6
6
  options[:orientation] = ENV['ORIENTATION'] if ENV['ORIENTATION']
7
-
7
+ options[:guards] = true if ENV['GUARDS']
8
8
  Transitions::Machine.draw(ENV['CLASS'], options)
9
9
  end
10
10
  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.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-23 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake