Sha256: 23ae355fbe9cf92547aa75f743256c7e606be7a3fa6028b6de58604456018603
Contents?: true
Size: 940 Bytes
Versions: 2
Compression:
Stored size: 940 Bytes
Contents
require 'furnace/base' class Furnace::Graphviz def initialize @code = "digraph {\n" @code << "node [labeljust=l,nojustify=true,fontname=monospace];" @code << "rankdir=TB;\n" yield self @code << "}" end def node(name, content, options={}) content.gsub!("&", "&") content.gsub!(">", ">") content.gsub!("<", "<") content.gsub!(/\*\*(.+?)\*\*/, '<b>\1</b>') content = content.lines.map { |l| %Q{<tr><td align="left">#{l}</td></tr>} }.join if content.empty? label = "<<empty>>" else label = "<<table border=\"0\">#{content}</table>>" end options = options.merge({ shape: 'box', label: label }) @code << %Q{#{name.inspect} [#{options.map { |k,v| "#{k}=#{v}" }.join(",")}];\n} end def edge(from, to, label="") @code << %Q{#{from.inspect} -> #{to.inspect} [label=#{label.inspect}];\n} end def to_s @code end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
furnace-0.1.1 | lib/furnace/graphviz.rb |
furnace-0.1.0 | lib/furnace/graphviz.rb |