Class: Gviz::Command

Inherits:
Thor show all
Defined in:
lib/gviz/command.rb

Instance Method Summary collapse

Instance Method Details



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 banner
  banner = ~"  Gviz is a tool for generating graphviz dot data with simple Ruby's syntax.\n  It works with a graph spec file (defaulting to load 'graph.ru').\n\n  Example of graph.ru:\n\n    route :main => [:init, :parse, :cleanup, :printf]\n    route :init => :make, :parse => :execute\n    route :execute => [:make, :compare, :printf]\n\n    save(:sample, :png)\n\n  EOS\n  puts banner\n  help\nend\n"

#build(file = 'graph.ru') ⇒ Object



8
9
10
11
12
# File 'lib/gviz/command.rb', line 8

def build(file='graph.ru')
  Graph(options[:name], options[: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 ~"      Specify any of:\n        \#{attrs.join(', ')}\n        \#{consts.join(', ')}\n        \#{colors.join(', ')}\n    EOS\n  end\nend\n"

#versionObject



15
16
17
# File 'lib/gviz/command.rb', line 15

def version
  puts "Gviz #{Gviz::VERSION} (c) 2012-2013 kyoendo"
end