Class: Autoproj::PackageManifest

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

Overview

Access to the information contained in a package’s manifest.xml file

Use PackageManifest.load to create

Direct Known Subclasses

RosPackageManifest

Defined Under Namespace

Classes: BaseLoader, ContactInfo, Dependency, Loader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, path = nil, null: false) ⇒ PackageManifest

Returns a new instance of PackageManifest.



86
87
88
89
90
91
92
93
94
95
# File 'lib/autoproj/package_manifest.rb', line 86

def initialize(package, path = nil, null: false)
    @package = package
    @path = path
    @dependencies = []
    @authors = []
    @maintainers = []
    @rock_maintainers = []
    @tags = []
    @null = null
end

Instance Attribute Details

#authorsObject

Returns the value of attribute authors.



59
60
61
# File 'lib/autoproj/package_manifest.rb', line 59

def authors
  @authors
end

#brief_descriptionObject

Returns the value of attribute brief_description.



53
54
55
# File 'lib/autoproj/package_manifest.rb', line 53

def brief_description
  @brief_description
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



54
55
56
# File 'lib/autoproj/package_manifest.rb', line 54

def dependencies
  @dependencies
end

#descriptionObject

Returns the value of attribute description.



52
53
54
# File 'lib/autoproj/package_manifest.rb', line 52

def description
  @description
end

#licenseObject

Returns the value of attribute license.



57
58
59
# File 'lib/autoproj/package_manifest.rb', line 57

def license
  @license
end

#maintainersObject

Returns the value of attribute maintainers.



60
61
62
# File 'lib/autoproj/package_manifest.rb', line 60

def maintainers
  @maintainers
end

#packageObject

The Autobuild::Package instance this manifest applies on



50
51
52
# File 'lib/autoproj/package_manifest.rb', line 50

def package
  @package
end

#pathObject (readonly)

Returns the value of attribute path.



51
52
53
# File 'lib/autoproj/package_manifest.rb', line 51

def path
  @path
end

#rock_maintainersObject

Returns the value of attribute rock_maintainers.



61
62
63
# File 'lib/autoproj/package_manifest.rb', line 61

def rock_maintainers
  @rock_maintainers
end

#tagsObject

Returns the value of attribute tags.



55
56
57
# File 'lib/autoproj/package_manifest.rb', line 55

def tags
  @tags
end

#urlObject

Returns the value of attribute url.



56
57
58
# File 'lib/autoproj/package_manifest.rb', line 56

def url
  @url
end

#versionObject

Returns the value of attribute version.



58
59
60
# File 'lib/autoproj/package_manifest.rb', line 58

def version
  @version
end

Class Method Details

.load(package, file, ros_manifest: false) ⇒ PackageManifest

Load a manifest.xml file and returns the corresponding PackageManifest object

Parameters:

  • the (PackageDescription)

    package we’re loading it for

  • file (String)

    the path to the manifest.xml file

  • ros_manifest (Boolean) (defaults to: false)

    whether the file follows the ROS format

Returns:

See Also:



19
20
21
22
# File 'lib/autoproj/package_manifest.rb', line 19

def self.load(package, file, ros_manifest: false)
    loader_class = ros_manifest ? RosPackageManifest::Loader : Loader
    parse(package, File.read(file), path: file, loader_class: loader_class)
end

.null(package) ⇒ Object

Create a null manifest for the given package



7
8
9
# File 'lib/autoproj/package_manifest.rb', line 7

def self.null(package)
    new(package, null: true)
end

.parse(package, contents, path: "<loaded from string>", loader_class: Loader) ⇒ PackageManifest

Create a PackageManifest object from the XML content provided as a string

Parameters:

  • the (PackageDescription)

    package we’re loading it for

  • contents (String)

    the manifest.xml contents as a string

  • path (String) (defaults to: "<loaded from string>")

    the file path, used for error reporting

  • ros_manifest (Boolean)

    whether the file follows the ROS format

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/autoproj/package_manifest.rb', line 33

def self.parse(package, contents,
    path: "<loaded from string>", loader_class: Loader)
    manifest = loader_class::MANIFEST_CLASS.new(package, path)
    loader = loader_class.new(path, manifest)
    begin
        REXML::Document.parse_stream(contents, loader)
    rescue REXML::ParseException => e
        raise Autobuild::PackageException.new(package.name, "prepare"),
              "invalid #{file}: #{e.message}"
    end
    manifest
end

Instance Method Details

#add_dependency(name, optional: false, modes: []) ⇒ Object

Add a declared dependency to this package



64
65
66
# File 'lib/autoproj/package_manifest.rb', line 64

def add_dependency(name, optional: false, modes: [])
    dependencies << Dependency.new(name, optional, modes)
end

#documentationObject



72
73
74
# File 'lib/autoproj/package_manifest.rb', line 72

def documentation
    description || short_documentation
end

#each_authorObject

Enumerates the name and email of each author. If no email is present, yields (name, nil)



143
144
145
146
147
148
149
# File 'lib/autoproj/package_manifest.rb', line 143

def each_author
    return enum_for(__method__) unless block_given?

    authors.each do |m|
        yield(m.name, m.email)
    end
end

#each_dependency(in_modes = []) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/autoproj/package_manifest.rb', line 103

def each_dependency(in_modes = [])
    return enum_for(__method__, in_modes) unless block_given?

    dependencies.each do |dep|
        if dep.modes.empty? || in_modes.any? { |m| dep.modes.include?(m) }
            yield(dep.name, dep.optional)
        end
    end
end

#each_maintainerObject



133
134
135
136
137
138
139
# File 'lib/autoproj/package_manifest.rb', line 133

def each_maintainer
    return enum_for(__method__) unless block_given?

    maintainers.each do |m|
        yield(m.name, m.email)
    end
end

#each_os_dependency(modes = Array.new, &block) ⇒ Object



113
114
115
116
117
# File 'lib/autoproj/package_manifest.rb', line 113

def each_os_dependency(modes = Array.new, &block)
    Autoproj.warn_deprecated "#{self.class}##{__method__}",
                             "call #each_dependency instead"
    each_dependency(modes, &block)
end

#each_package_dependency(modes = Array.new, &block) ⇒ Object



119
120
121
122
123
# File 'lib/autoproj/package_manifest.rb', line 119

def each_package_dependency(modes = Array.new, &block)
    Autoproj.warn_deprecated "#{self.class}##{__method__}",
                             "call #each_dependency instead"
    each_dependency(modes, &block)
end

#each_rock_maintainerObject



125
126
127
128
129
130
131
# File 'lib/autoproj/package_manifest.rb', line 125

def each_rock_maintainer
    return enum_for(__method__) unless block_given?

    rock_maintainers.each do |m|
        yield(m.name, m.email)
    end
end

#has_documentation?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/autoproj/package_manifest.rb', line 68

def has_documentation?
    description
end

#has_short_documentation?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/autoproj/package_manifest.rb', line 76

def has_short_documentation?
    brief_description
end

#null?Boolean

Whether this is a null manifest (used for packages that have actually no manifest) or not

Returns:

  • (Boolean)


99
100
101
# File 'lib/autoproj/package_manifest.rb', line 99

def null?
    @null
end

#short_documentationObject



80
81
82
83
84
# File 'lib/autoproj/package_manifest.rb', line 80

def short_documentation
    brief_description ||
        "no documentation available for package '#{package.name}' "\
        "in its manifest.xml file"
end