Sha256: 945e8c3aaf3e00642d7533cc1a6b2b26b1293d03f7b3620b08ba3b316cfab2ba

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

require 'graphviz'

module Renderer
  class GraphViz
    def initialize(file_name, config)
      @g = ::GraphViz::new('G', :type => 'strict digraph') { |g|
        g[:overlap] = :false
        g[:splines] = :true
        g[:sep] = 1
        g[:concentrate] = :true
        g[:rankdir] = "LR"
      }
      @file_name = file_name
      @config = config
    end

    def add_node(name)
      @g.add_node(name)
    end

    def add_edge(from, to, opts)
      @g.add_edge(from, to, ({style: 'bold'}).merge(opts))
    end

    def output
      extension = File.extname(@file_name)
      opts = {extension[1..-1].to_sym => @file_name, :use => @config.format}
      @g.output(opts)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_security_viz-0.1.5.pre.alpha.pre.94 lib/renderer/graphviz.rb
aws_security_viz-0.1.5.pre.alpha.pre.93 lib/renderer/graphviz.rb