Class: Autoproj::Metapackage

Inherits:
Object
  • Object
show all
Defined in:
lib/autoproj/metapackage.rb

Overview

A set of packages that can be referred to by name

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

The metapackage name



5
6
7
# File 'lib/autoproj/metapackage.rb', line 5

def name
  @name
end

#packages_by_nameObject (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

Parameters:

  • pkg (Autobuild::Package)


40
41
42
# File 'lib/autoproj/metapackage.rb', line 40

def add(pkg)
    packages_by_name[pkg.name] = pkg
end

#clearObject



65
66
67
# File 'lib/autoproj/metapackage.rb', line 65

def clear
    packages_by_name.clear
end

#delete_ifObject



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

Yield Parameters:

  • pkg (Autobuild::Package)


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

Parameters:

  • pkg (String, #name)

    the package or package name

Returns:

  • (Boolean)


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

#packagesObject

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

#sizeObject



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.

Returns:

  • (Boolean)

    whether the dependencies from this metapackage are weak or not

See Also:

  • #weak_dependencies


17
18
19
# File 'lib/autoproj/metapackage.rb', line 17

def weak_dependencies?
    !!@weak_dependencies
end