Class: Graphwerk::Builders::Graph

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/graphwerk/builders/graph.rb

Constant Summary collapse

OptionsShape =
T.type_alias {
  {
    layout: Graphwerk::Layout,
    application: T::Hash[Symbol, Object],
    graph: T::Hash[Symbol, Object],
    node: T::Hash[Symbol, Object],
    edge: T::Hash[Symbol, Object]
  }
}
DEFAULT_OPTIONS =
T.let({
  layout: Graphwerk::Layout::Dot,
  application: {
    style: 'filled',
    fillcolor: '#333333',
    fontcolor: 'white'
  },
  graph: {
    root: Constants::ROOT_PACKAGE_NAME,
    overlap: false,
    splines: true
  },
  node: {
    shape: 'box',
    style: 'rounded, filled',
    fontcolor: 'white',
    fillcolor: '#EF673E',
    color: '#EF673E',
    fontname: 'Lato'
  },
  edge: {
    len: '0.4'
  }
}, OptionsShape)

Instance Method Summary collapse

Constructor Details

#initialize(package_set, options: {}) ⇒ Graph



45
46
47
48
49
50
# File 'lib/graphwerk/builders/graph.rb', line 45

def initialize(package_set, options: {})
  @package_set = package_set
  @options = T.let(DEFAULT_OPTIONS.deep_merge(options), OptionsShape)
  @graph = T.let(build_empty_graph, GraphViz)
  @nodes = T.let(build_empty_nodes, T::Hash[String, GraphViz::Node])
end

Instance Method Details

#buildObject



53
54
55
56
57
58
# File 'lib/graphwerk/builders/graph.rb', line 53

def build
  setup_graph
  add_packages_to_graph
  add_package_dependencies_to_graph
  @graph
end