Module: CobraCommander::CLI::Output::DotGraph

Defined in:
lib/cobra_commander/cli/output/dot_graph.rb

Overview

Generates graphs of components

Class Method Summary collapse

Class Method Details

.generate(components, output) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/cobra_commander/cli/output/dot_graph.rb', line 8

def self.generate(components, output)
  output << "digraph G {\n"
  [*components, *components.flat_map(&:deep_dependencies)].uniq.each do |comp|
    output << "\t#{comp.name};\n"
    comp.dependencies.each do |dep|
      output << "\t#{comp.name} -> #{dep.name};\n"
    end
  end
  output << "}\n"
end