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.



94
95
96
97
98
99
100
101
102
103
# File 'lib/autoproj/package_manifest.rb', line 94

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.



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

def authors
  @authors
end

#brief_descriptionObject

Returns the value of attribute brief_description.



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

def brief_description
  @brief_description
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



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

def dependencies
  @dependencies
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#licenseObject

Returns the value of attribute license.



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

def license
  @license
end

#maintainersObject

Returns the value of attribute maintainers.



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

def maintainers
  @maintainers
end

#packageObject

The Autobuild::Package instance this manifest applies on



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

def package
  @package
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#rock_maintainersObject

Returns the value of attribute rock_maintainers.



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

def rock_maintainers
  @rock_maintainers
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#versionObject

Returns the value of attribute version.



66
67
68
# File 'lib/autoproj/package_manifest.rb', line 66

def version
  @version
end

Class Method Details

.load(package, file, ros_manifest: false, condition_context: nil) ⇒ 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
23
# File 'lib/autoproj/package_manifest.rb', line 19

def self.load(package, file, ros_manifest: false, condition_context: nil)
    loader_class = ros_manifest ? RosPackageManifest::Loader : Loader
    parse(package, File.read(file), path: file, loader_class: loader_class,
                                    condition_context: condition_context)
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, condition_context: nil) ⇒ 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:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/autoproj/package_manifest.rb', line 34

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

Instance Method Details

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

Add a declared dependency to this package



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

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

#documentationObject



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

def documentation
    description || short_documentation
end

#each_authorObject

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



151
152
153
154
155
156
157
# File 'lib/autoproj/package_manifest.rb', line 151

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



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

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



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

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



121
122
123
124
125
# File 'lib/autoproj/package_manifest.rb', line 121

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



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

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



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

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)


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

def has_documentation?
    description
end

#has_short_documentation?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/autoproj/package_manifest.rb', line 84

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)


107
108
109
# File 'lib/autoproj/package_manifest.rb', line 107

def null?
    @null
end

#short_documentationObject



88
89
90
91
92
# File 'lib/autoproj/package_manifest.rb', line 88

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