移行システムでいくつかの操作を実行できるツールを作成しており、それらを視覚化する必要もあります。
ruby-gem に関するドキュメントはあまりありませんが (これは私が入手できる最高のものでした: http://www.omninerd.com/articles/Automating_Data_Visualization_with_Ruby_and_Graphviz )、移行システムからグラフを作成することができました。(自由に使用してください。サンプルコードはあまりありません。コメント/質問も大歓迎です)
# note: model is something of my own datatype,
# having states, labels, transitions, start_state and a name
# I hope the code is self-explaining
@graph = GraphViz::new(model.name, "type" => "graph" )
#settings
@graph.edge[:dir] = "forward"
@graph.edge[:arrowsize]= "0.5"
#make the graph
model.states.each do |cur_state|
@graph.add_node(cur_state.name).label = cur_state.name
cur_state.out_transitions.each do |cur_transition|
@graph.add_edge(cur_transition.from.name, cur_transition.to.name).label = cur_transition.label.to_s
end
end
#make a .pdf output (can also be changed to .eps, .png or whatever)
@graph.output("pdf" => File.join(".")+"/" + @graph.name + ".pdf")
#it's really not that hard :-)
私ができない唯一のことは、「何もないところから」開始状態に矢印を描くことです。提案は誰ですか?