Class: DepSelector::DependencyGraph
- Inherits:
-
Object
- Object
- DepSelector::DependencyGraph
- Defined in:
- lib/dep_selector/dependency_graph.rb
Constant Summary collapse
- DebugOptionFile =
"/tmp/DepSelectorDebugOn"
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Instance Method Summary collapse
-
#clone ⇒ Object
TODO [cw,2010/11/23]: this is a simple but inefficient impl.
- #each_package ⇒ Object
- #gecode_model_vars ⇒ Object
- #gecode_wrapper ⇒ Object
-
#generate_gecode_wrapper_constraints(packages_to_include_in_solve = nil) ⇒ Object
Note: only invoke this method once all Packages and PackageVersions have been added.
-
#initialize ⇒ DependencyGraph
constructor
A new instance of DependencyGraph.
- #package(name) ⇒ Object
- #to_s(incl_densely_packed_versions = false) ⇒ Object
Constructor Details
#initialize ⇒ DependencyGraph
Returns a new instance of DependencyGraph.
32 33 34 |
# File 'lib/dep_selector/dependency_graph.rb', line 32 def initialize @packages = {} end |
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
30 31 32 |
# File 'lib/dep_selector/dependency_graph.rb', line 30 def packages @packages end |
Instance Method Details
#clone ⇒ Object
TODO [cw,2010/11/23]: this is a simple but inefficient impl. Do it for realz.
67 68 69 |
# File 'lib/dep_selector/dependency_graph.rb', line 67 def clone Marshal.load(Marshal.dump(self)) end |
#each_package ⇒ Object
40 41 42 43 44 |
# File 'lib/dep_selector/dependency_graph.rb', line 40 def each_package packages.each do |name, pkg| yield pkg end end |
#gecode_model_vars ⇒ Object
57 58 59 |
# File 'lib/dep_selector/dependency_graph.rb', line 57 def gecode_model_vars packages.inject({}){|acc, elt| acc[elt.first] = elt.last.gecode_model_var ; acc } end |
#gecode_wrapper ⇒ Object
46 47 48 49 |
# File 'lib/dep_selector/dependency_graph.rb', line 46 def gecode_wrapper raise "Must invoke generate_gecode_wrapper_constraints before attempting to access gecode_wrapper" unless @gecode_wrapper @gecode_wrapper end |
#generate_gecode_wrapper_constraints(packages_to_include_in_solve = nil) ⇒ Object
Note: only invoke this method once all Packages and PackageVersions have been added.
53 54 55 |
# File 'lib/dep_selector/dependency_graph.rb', line 53 def generate_gecode_wrapper_constraints(packages_to_include_in_solve=nil) raise "#generate_gecode_wrapper_constraints references c extensions. don't use." end |
#package(name) ⇒ Object
36 37 38 |
# File 'lib/dep_selector/dependency_graph.rb', line 36 def package(name) packages.has_key?(name) ? packages[name] : (packages[name]=Package.new(self, name)) end |
#to_s(incl_densely_packed_versions = false) ⇒ Object
61 62 63 |
# File 'lib/dep_selector/dependency_graph.rb', line 61 def to_s(incl_densely_packed_versions = false) packages.keys.sort.map{|name| packages[name].to_s(incl_densely_packed_versions)}.join("\n") end |