class Renderer::Navigator
Public Class Methods
new(file_name, config)
click to toggle source
# File lib/renderer/navigator.rb, line 5 def initialize(file_name, config) @nodes = [] @edges = [] @file_name = file_name @config = config @categories = Set.new() end
Public Instance Methods
add_edge(from, to, opts)
click to toggle source
# File lib/renderer/navigator.rb, line 20 def add_edge(from, to, opts) @edges << {id: "#{from}-#{to}", from: from, to: to, label: opts[:label]} end
add_node(name, opts)
click to toggle source
# File lib/renderer/navigator.rb, line 13 def add_node(name, opts) vpc = opts[:vpc_id] || 'default' info = "<b>Security group</b>: #{name}, <br/><b>VPC:</b> #{vpc}" @nodes << {id: name, label: name, categories: [vpc], info: info} @categories.add(vpc) end
output()
click to toggle source
# File lib/renderer/navigator.rb, line 24 def output IO.write(@file_name, { data: {nodes: @nodes, edges: @edges}, categories: Hash[@categories.map{|c| [c, c]}] }.to_json) Renderer.copy_asset('navigator.html', @file_name) end