Sha256: 8a9274391ea19cc4ba05de6d396c3b5e5186aba7228574a4ff67f031c1c073d1
Contents?: true
Size: 734 Bytes
Versions: 5
Compression:
Stored size: 734 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] return format if %w[png dot].include?(format) raise ArgumentError, "output format must be 'png' or 'dot'" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems