Class: BrewDG::Library

Inherits:
Object
  • Object
show all
Defined in:
lib/brew_dg/library.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Library

Returns a new instance of Library.



10
11
12
13
14
15
16
17
18
# File 'lib/brew_dg/library.rb', line 10

def initialize(options = {})
  @package_cache = options.fetch(:package_cache, {})
  @packages = options.fetch(:packages) do
    %x(brew list).lines.map(&:strip)
  end
  @relevant_dependency_types = options.fetch(:relevant_dependency_types) do
    [:required, :recommended]
  end
end

Instance Method Details

#graphObject



20
21
22
23
24
25
26
27
# File 'lib/brew_dg/library.rb', line 20

def graph
  @packages.reduce(Graph.new) do |graph, name|
    subgraph = subgraph(name)

    graph.add_edges!(*subgraph.edges)
    graph.add_vertices!(*subgraph.vertices)
  end
end

#installation_orderObject



29
30
31
32
# File 'lib/brew_dg/library.rb', line 29

def installation_order
  installation = GraphInstallation.new(graph)
  installation.list.map(&:to_s)
end