Class: ElmInstall::GraphBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/elm_install/graph_builder.rb

Overview

This class is for building dependency graphs from a cache.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache, options = { verbose: false }) ⇒ GraphBuilder

Initialies a graph build with a cache and options.

Parameters:

  • cache (Cache)

    The cache to generate the graph from.

  • options (Hash) (defaults to: { verbose: false })

    The options to use.



23
24
25
26
27
# File 'lib/elm_install/graph_builder.rb', line 23

def initialize(cache, options = { verbose: false })
  @graph = Solve::Graph.new
  @options = options
  @cache = cache
end

Instance Attribute Details

#graphSolve::Graph (readonly)

Returns The graph.

Returns:

  • (Solve::Graph)

    The graph



5
6
7
# File 'lib/elm_install/graph_builder.rb', line 5

def graph
  @graph
end

Class Method Details

.graph_from_cache(cache, options = { verbose: false }) ⇒ Solve::Graph

Returns a graph from a cache and options.

Parameters:

  • cache (Cache)

    The cache to generate the graph from.

  • options (Hash) (defaults to: { verbose: false })

    The options to use.

Returns:

  • (Solve::Graph)

    The graph



13
14
15
16
17
# File 'lib/elm_install/graph_builder.rb', line 13

def self.graph_from_cache(cache, options = { verbose: false })
  graph = new cache, options
  graph.build
  graph.graph
end

Instance Method Details

#buildvoid

This method returns an undefined value.

Builds the graph.



32
33
34
35
36
# File 'lib/elm_install/graph_builder.rb', line 32

def build
  @cache.each do |package, versions|
    add_versions package, versions
  end
end