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 = ~<<-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 banner
  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(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 ~<<-EOS
      Specify any of:
        #{attrs.join(', ')}
        #{consts.join(', ')}
        #{colors.join(', ')}
    EOS
  end
end

#versionObject



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

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