File: sample06.rb

package info (click to toggle)
ruby-graphviz 1.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,124 kB
  • ctags: 695
  • sloc: ruby: 7,656; xml: 26; makefile: 17
file content (46 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$:.unshift( "../lib" );
require "graphviz"

GraphViz::new( "G", :rankdir => "LR", :type => "graph" ) { |graph|
  graph.cluster0 { |cluster|
    cluster[:label] = "Back Office"

    cluster.fatman.set { |n|
      n.label = "FatMan"
      n.shape = "rect"
    }
    cluster.grobil.set { |n|
      n.label = "GroBil"
      n.shape = "rect"
    }
  }

  graph.cluster1 { |cluster|
    cluster[:label] = "DMZ"

    cluster.dupont.set { |n|
      n.label = "Dupont"
      n.shape = "rect"
    }
    cluster.dupond.set { |n|
      n.label = "Dupond"
      n.shape = "rect"
    }
  }

  graph.cluster2() { |cluster|
    cluster[:label] = "Front Office"

    cluster.door.set { |n|
      n.label = "Door"
      n.shape = "rect"
    }
  }

  graph.cluster0.fatman << graph.cluster1.dupont
  graph.cluster0.fatman << graph.cluster1.dupond
  graph.cluster0.grobil << graph.cluster1.dupont
  graph.cluster0.grobil << graph.cluster1.dupond
  graph.cluster1.dupont << graph.cluster2.door
  graph.cluster1.dupond << graph.cluster2.door
}.output( :path => '/usr/local/bin/', :png => "#{$0}.png" )