Sha256: 470c098ab4e7abf5e551ea0d840a11255632446af614c2c3e8be4c8039fc23dc

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

require 'graphviz'
require 'logger'

class Graph
  def initialize
    @g = GraphViz::new('G', :type => 'strict digraph') { |g|
      g[:overlap] = :false
      g[:splines] = :true
      g[:sep] = 1
      g[:concentrate] = :true
    }
  end

  def add_node(name)
    log("node: #{name}")
    @g.add_node(name) if name
  end

  def get_node(name, &block)
    @g.get_node(name, &block)
  end

  def add_edge(from, to, opts)
    log("edge: #{from} -> #{to}")
    @g.add_edge(from, to, opts)
  end

  def each_edge(&block)
    @g.each_edge(&block)
  end

  def output(opts)
    log("output: #{opts}")
    @g.output(opts)
  end

  def log(msg)
    puts msg if ENV["DEBUG"]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aws_security_viz-0.1.2.pre.alpha.pre.58 lib/graph.rb
aws_security_viz-0.1.1 lib/graph.rb
aws_security_viz-0.1.1.pre.alpha.pre.56 lib/graph.rb
aws_security_viz-0.1.0 lib/graph.rb