Sha256: 227286dff0837900f85c1f09d5ecaedb817038657f2ee6d755448ae644e73a32

Contents?: true

Size: 877 Bytes

Versions: 62

Compression:

Stored size: 877 Bytes

Contents

require 'set'

module Renderer
    class Navigator
      def initialize(file_name, config)
        @nodes = []
        @edges = []
        @file_name = file_name
        @config = config
        @categories = Set.new()
      end
  
      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
  
      def add_edge(from, to, opts)
        @edges << {id: "#{from}-#{to}", from: from, to: to, label: opts[:label]}
      end
  
      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
    end
  end
  

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
aws_security_viz-0.2.5.pre.alpha.pre.35 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.34 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.33 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.32 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.31 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.30 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.29 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.28 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.27 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.26 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.25 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.24 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.23 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.22 lib/renderer/navigator.rb
aws_security_viz-0.2.5.pre.alpha.pre.21 lib/renderer/navigator.rb
aws_security_viz-0.2.4 lib/renderer/navigator.rb
aws_security_viz-0.2.4.pre.alpha.pre.20 lib/renderer/navigator.rb
aws_security_viz-0.2.4.pre.alpha.pre.19 lib/renderer/navigator.rb
aws_security_viz-0.2.4.pre.alpha.pre.18 lib/renderer/navigator.rb
aws_security_viz-0.2.4.pre.alpha.pre.15 lib/renderer/navigator.rb