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



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

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

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

Class Method Details

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

Returns a graph from a cache.



7
8
9
10
11
# File 'lib/elm_install/graph_builder.rb', line 7

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

Instance Method Details

#buildObject

Builds the graph.



21
22
23
24
25
# File 'lib/elm_install/graph_builder.rb', line 21

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