lib/percheron/graph.rb in percheron-0.7.15 vs lib/percheron/graph.rb in percheron-0.7.16
- old
+ new
@@ -31,28 +31,35 @@
def graph
@graph ||= GraphViz.new(:G, graph_opts)
end
def graph_opts
- { type: :digraph, nodesep: 0.75, ranksep: 1.0, label: header_label, fontsize: 12 }
+ { type: :digraph, nodesep: 0.75, ranksep: 1.0, label: header_label }
end
- def units
- @units ||= stack.units
+ def header_label
+ '<
+ <table border="0" cellborder="0">
+ <tr><td height="36" valign="bottom">
+ <font face="Arial Bold" point-size="14">%s</font>
+ </td></tr>
+ <tr><td height="18"><font face="Arial Italic" point-size="11">%s</font></td></tr>
+ </table>
+ >' % [ stack.name, stack_description ]
end
- def header_label
- '\n%s\n%s\n' % [ stack.name, stack.description ]
+ def stack_description
+ stack.description || ' '
end
+ def units
+ @units ||= stack.units
+ end
+
def add_nodes
units.each do |_, unit|
- if unit.pseudo?
- add_pseudo_node(unit)
- else
- add_node(unit)
- end
+ unit.pseudo? ? add_pseudo_node(unit) : add_node(unit)
end
end
def add_node(unit)
nodes[unit.name] = graph.add_nodes(unit.name, node_opts(unit))
@@ -68,17 +75,20 @@
name = 'cluster%s' % graphs.keys.count
graphs[unit.pseudo_name] = graph.add_graph(name, cluster_opts(unit))
end
def cluster_opts(unit)
- { label: unit.pseudo_name, style: 'filled', color: 'lightgrey' }
+ label = '<<font face="Arial Bold">%s</font>>' % unit.pseudo_name
+ { label: label, style: 'filled', color: 'lightgrey', fontsize: 13 }
end
def node_opts(unit)
shape = unit.startable? ? 'box' : 'ellipse'
- label = [ unit.name ]
- unit.ports.each { |ports| label << 'public: %s, internal: %s' % ports.split(':') }
- { shape: shape, label: label.join("\n"), fontname: 'arial', fontsize: 12 }
+ label = [ '<font face="Arial Bold" point-size="12">%s</font><br/>' % unit.name ]
+ unit.ports.each do |ports|
+ label << '<font point-size="11">p: %s, i: %s</font>' % ports.split(':')
+ end
+ { shape: shape, label: '<%s>' % label.join('<br/>'), fontname: 'arial' }
end
def pseudo_node_opts(unit)
node_opts(unit).merge!(style: 'filled', color: 'white')
end