Sha256: e46b146c18a3b47e03281196859e87e6d4b9a2353f8c732ec891bcf0b51d4aaa
Contents?: true
Size: 776 Bytes
Versions: 2
Compression:
Stored size: 776 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..-1] # standard:disable Style/SlicingWithRange 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.14.0 | lib/cobra_commander/output/graph_viz.rb |
cobra_commander-0.13.0 | lib/cobra_commander/output/graph_viz.rb |