Class: Gviz::Command
Instance Method Summary collapse
Instance Method Details
#banner ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gviz/command.rb', line 21 def = ~<<-EOS Gviz is a tool for generating graphviz dot data with simple Ruby's syntax. It works with a graph spec file (defaulting to load 'graph.ru'). Example of graph.ru: route :main => [:init, :parse, :cleanup, :printf] route :init => :make, :parse => :execute route :execute => [:make, :compare, :printf] save(:sample, :png) EOS puts help end |
#build(file = 'graph.ru') ⇒ Object
8 9 10 11 12 |
# File 'lib/gviz/command.rb', line 8 def build(file='graph.ru') Graph([:name], [:type]) { instance_eval ::File.read(file) } rescue Errno::ENOENT abort "graph file `#{file}` not found" end |
#man(name = '') ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gviz/command.rb', line 42 def man(name='') attrs = %w(graph node edge subgraph cluster) consts = %w(arrows shapes layouts output_formats) colors = %w(color_names color_schemes full_color_names full_color_schemes svg_color_names dark_colors) name = name.downcase case name when *attrs then puts format_attr(name) when *consts then puts consts.map { |c| format_const c } when *colors then puts format_const(name) when /color/ then puts colors.map { |c| format_const c } else puts ~<<-EOS Specify any of: #{attrs.join(', ')} #{consts.join(', ')} #{colors.join(', ')} EOS end end |