Module: SemanticPuppet::Dependency
- Extended by:
- Dependency
- Included in:
- Dependency
- Defined in:
- lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb,
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb,
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb,
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb,
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb,
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb
Defined Under Namespace
Modules: GraphNode Classes: Graph, ModuleRelease, Source, UnsatisfiableGraph
Sources collapse
-
#add_source(source) ⇒ void
Appends a new Source to the current list.
-
#clear_sources ⇒ void
Clears the current list of Sources.
-
#sources ⇒ Array<Source>
A frozen copy of the Source list.
Instance Method Summary collapse
-
#fetch_releases(name) ⇒ Array<ModuleRelease>
Fetches all available releases for the given module name.
-
#query(modules) ⇒ Graph
Fetches a graph of modules and their dependencies from the currently configured list of Sources.
-
#resolve(graph) ⇒ Array<ModuleRelease>
Given a graph result from #query, this method will resolve the graph of dependencies, if possible, into a flat list of the best suited modules.
Instance Method Details
#add_source(source) ⇒ void
This method returns an undefined value.
Appends a new Source to the current list.
24 25 26 27 28 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb', line 24 def add_source(source) sources @sources << source nil end |
#clear_sources ⇒ void
This method returns an undefined value.
Clears the current list of Sources.
32 33 34 35 36 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb', line 32 def clear_sources sources @sources.clear nil end |
#fetch_releases(name) ⇒ Array<ModuleRelease>
Fetches all available releases for the given module name.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb', line 77 def fetch_releases(name) releases = {} sources.each do |source| source.fetch(name).each do |dependency| releases[dependency.version] ||= dependency end end return releases.values end |
#query(modules) ⇒ Graph
Return a specialized “Graph” object.
Allow for external constraints to be added to the graph.
Fetches a graph of modules and their dependencies from the currently configured list of Sources.
51 52 53 54 55 56 57 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb', line 51 def query(modules) constraints = Hash[modules.map { |k, v| [ k, VersionRange.parse(v) ] }] graph = Graph.new(constraints) fetch_dependencies(graph) return graph end |
#resolve(graph) ⇒ Array<ModuleRelease>
Given a graph result from #query, this method will resolve the graph of dependencies, if possible, into a flat list of the best suited modules. If the dependency graph does not have a suitable resolution, this method will raise an exception to that effect.
66 67 68 69 70 71 |
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb', line 66 def resolve(graph) catch :next do return walk(graph, graph.dependencies.dup) end raise UnsatisfiableGraph.new(graph) end |