Class: SemanticPuppet::Dependency::Graph
- Includes:
- GraphNode
- Defined in:
- lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb
Instance Attribute Summary collapse
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
Instance Method Summary collapse
-
#add_graph_constraint(source) {|nodes| ... } ⇒ void
Constrains graph solutions based on the given block.
-
#initialize(modules = {}) ⇒ Graph
constructor
Create a new instance of a dependency graph.
-
#satisfies_graph?(solution) ⇒ Boolean
Checks the proposed solution (or partial solution) against the graph’s constraints.
Methods included from GraphNode
#<<, #<=>, #add_constraint, #add_dependency, #children, #constraints, #constraints_for, #dependencies, #dependency_names, #name, #populate_children, #satisfied?, #satisfies_constraints?, #satisfies_dependency?
Constructor Details
#initialize(modules = {}) ⇒ Graph
Create a new instance of a dependency graph.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb', line 14 def initialize(modules = {}) @modules = modules.keys modules.each do |name, range| add_constraint('initialize', name, range.to_s) do |node| range === node.version end add_dependency(name) end end |
Instance Attribute Details
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
8 9 10 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb', line 8 def modules @modules end |
Instance Method Details
#add_graph_constraint(source) {|nodes| ... } ⇒ void
This method returns an undefined value.
Constrains graph solutions based on the given block. Graph constraints are used to describe fundamental truths about the tooling or module system (e.g.: module names contain a namespace component which is dropped during install, so module names must be unique excluding the namespace).
45 46 47 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb', line 45 def add_graph_constraint(source, &block) constraints[:graph] << [ source, block ] end |
#satisfies_graph?(solution) ⇒ Boolean
Checks the proposed solution (or partial solution) against the graph’s constraints.
55 56 57 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb', line 55 def satisfies_graph?(solution) constraints[:graph].all? { |_, check| check[solution] } end |