Class: BrewDG::Library
- Inherits:
-
Object
- Object
- BrewDG::Library
- Defined in:
- lib/brew_dg/library.rb
Instance Method Summary collapse
- #graph ⇒ Object
-
#initialize(options = {}) ⇒ Library
constructor
A new instance of Library.
- #installation_order ⇒ Object
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( = {}) @package_cache = .fetch(:package_cache, {}) @packages = .fetch(:packages) do %x(brew list).lines.map(&:strip) end @relevant_dependency_types = .fetch(:relevant_dependency_types) do [:required, :recommended] end end |
Instance Method Details
#graph ⇒ Object
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_order ⇒ Object
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 |