Sha256: c075259bb45cef9f102c28ddc53411bda8dea44450e95f199eca3a0d6ebdd3ad
Contents?: true
Size: 732 Bytes
Versions: 2
Compression:
Stored size: 732 Bytes
Contents
# frozen_string_literal: true require "graphviz" module CobraCommander module Output # Generates graphs of components module GraphViz def self.generate(component, output) g = ::GraphViz.new(:G, type: :digraph, concentrate: true) ([component] + component.deep_dependencies).each do |comp| g.add_nodes comp.name g.add_edges comp.name, comp.dependencies.map(&:name) end g.output(extract_format(output) => output) end private_class_method def self.extract_format(output) format = output[-3..] return format if %w[png dot].include?(format) raise ArgumentError, "output format must be 'png' or 'dot'" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cobra_commander-0.15.1 | lib/cobra_commander/output/graph_viz.rb |
cobra_commander-0.15.0 | lib/cobra_commander/output/graph_viz.rb |