Class: Autoproj::Metapackage
- Inherits:
-
Object
- Object
- Autoproj::Metapackage
- Defined in:
- lib/autoproj/metapackage.rb
Overview
A set of packages that can be referred to by name
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The metapackage name.
-
#packages_by_name ⇒ Object
readonly
The packages listed in this metapackage.
-
#weak_dependencies ⇒ Object
writeonly
The normal dependency handling behaviour is to generate an error if a metapackage is selected for the build but some of its dependencies cannot be built.
Instance Method Summary collapse
-
#add(pkg) ⇒ Object
Adds a package to this metapackage.
- #clear ⇒ Object
- #delete_if ⇒ Object
-
#each_package {|pkg| ... } ⇒ Object
Lists the packages contained in this metapackage.
-
#include?(pkg) ⇒ Boolean
Tests if the given package is included in this metapackage.
-
#initialize(name) ⇒ Metapackage
constructor
A new instance of Metapackage.
-
#packages ⇒ Object
Deprecated, use #each_package instead.
-
#remove(pkg) ⇒ Object
Remove a package from this metapackage.
- #size ⇒ Object
-
#weak_dependencies? ⇒ Boolean
Whether the dependencies from this metapackage are weak or not.
Constructor Details
#initialize(name) ⇒ Metapackage
Returns a new instance of Metapackage.
21 22 23 24 25 |
# File 'lib/autoproj/metapackage.rb', line 21 def initialize(name) @name = name @packages_by_name = Hash.new @weak_dependencies = false end |
Instance Attribute Details
#name ⇒ Object (readonly)
The metapackage name
5 6 7 |
# File 'lib/autoproj/metapackage.rb', line 5 def name @name end |
#packages_by_name ⇒ Object (readonly)
The packages listed in this metapackage
7 8 9 |
# File 'lib/autoproj/metapackage.rb', line 7 def packages_by_name @packages_by_name end |
#weak_dependencies=(value) ⇒ Object (writeonly)
The normal dependency handling behaviour is to generate an error if a metapackage is selected for the build but some of its dependencies cannot be built. This modifies the behaviour to simply ignore the problematic packages.
12 13 14 |
# File 'lib/autoproj/metapackage.rb', line 12 def weak_dependencies=(value) @weak_dependencies = value end |
Instance Method Details
#add(pkg) ⇒ Object
Adds a package to this metapackage
40 41 42 |
# File 'lib/autoproj/metapackage.rb', line 40 def add(pkg) packages_by_name[pkg.name] = pkg end |
#clear ⇒ Object
65 66 67 |
# File 'lib/autoproj/metapackage.rb', line 65 def clear packages_by_name.clear end |
#delete_if ⇒ Object
69 70 71 |
# File 'lib/autoproj/metapackage.rb', line 69 def delete_if packages_by_name.delete_if { |name, package| yield(package) } end |
#each_package {|pkg| ... } ⇒ Object
Lists the packages contained in this metapackage
53 54 55 |
# File 'lib/autoproj/metapackage.rb', line 53 def each_package(&block) packages_by_name.each_value(&block) end |
#include?(pkg) ⇒ Boolean
Tests if the given package is included in this metapackage
60 61 62 63 |
# File 'lib/autoproj/metapackage.rb', line 60 def include?(pkg) pkg = pkg.name unless pkg.respond_to?(:to_str) packages_by_name.has_key?(pkg) end |
#packages ⇒ Object
Deprecated, use #each_package instead
32 33 34 35 |
# File 'lib/autoproj/metapackage.rb', line 32 def packages Autoproj.warn_deprecated "use #each_package instead" each_package.to_a end |
#remove(pkg) ⇒ Object
Remove a package from this metapackage
45 46 47 48 |
# File 'lib/autoproj/metapackage.rb', line 45 def remove(pkg) pkg = pkg.name if pkg.respond_to?(:name) packages_by_name.delete(pkg) end |
#size ⇒ Object
27 28 29 |
# File 'lib/autoproj/metapackage.rb', line 27 def size packages_by_name.size end |
#weak_dependencies? ⇒ Boolean
Returns whether the dependencies from this metapackage are weak or not.
17 18 19 |
# File 'lib/autoproj/metapackage.rb', line 17 def weak_dependencies? !!@weak_dependencies end |