19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/yard-state_machine/yard/state_machine/templates/default/class/html/setup.rb', line 19
def render_state_machine_data state_machines
state_machine_image_paths = Hash.new
images_base_path = File.dirname(serializer.serialized_path(object))
state_machines.each do |state_machine_name, state_machine|
image_file_name = object.name.to_s + '_' + state_machine_name + '.png'
image_path = File.join(images_base_path, image_file_name)
content = GraphViz.new(:G, :type => :digraph) do |graph|
state_machine[:description][:events].each do |event_name, event|
event[:description][:transitions].each do |transition|
to_state = graph.add_node(transition[:to_state].to_s)
transition[:from_states].each do |state|
from_state = graph.add_node(state.to_s)
link = graph.add_edge(from_state, to_state)
link.label = event[:name].to_s
end
end
end
end.output(:png => String)
serializer.serialize(image_path, content)
state_machine_image_paths[state_machine_name] = image_path
end
return state_machine_image_paths
end
|