Class: Autoproj::PackageManifest
- Inherits:
-
Object
- Object
- Autoproj::PackageManifest
- 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
Defined Under Namespace
Classes: BaseLoader, ContactInfo, Dependency, Loader
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#brief_description ⇒ Object
Returns the value of attribute brief_description.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#description ⇒ Object
Returns the value of attribute description.
-
#license ⇒ Object
Returns the value of attribute license.
-
#maintainers ⇒ Object
Returns the value of attribute maintainers.
-
#package ⇒ Object
The Autobuild::Package instance this manifest applies on.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rock_maintainers ⇒ Object
Returns the value of attribute rock_maintainers.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.load(package, file, ros_manifest: false, condition_context: nil) ⇒ PackageManifest
Load a manifest.xml file and returns the corresponding PackageManifest object.
-
.null(package) ⇒ Object
Create a null manifest for the given package.
-
.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.
Instance Method Summary collapse
-
#add_dependency(name, optional: false, modes: []) ⇒ Object
Add a declared dependency to this package.
- #documentation ⇒ Object
-
#each_author ⇒ Object
Enumerates the name and email of each author.
- #each_dependency(in_modes = []) ⇒ Object
- #each_maintainer ⇒ Object
- #each_os_dependency(modes = Array.new, &block) ⇒ Object
- #each_package_dependency(modes = Array.new, &block) ⇒ Object
- #each_rock_maintainer ⇒ Object
- #has_documentation? ⇒ Boolean
- #has_short_documentation? ⇒ Boolean
-
#initialize(package, path = nil, null: false) ⇒ PackageManifest
constructor
A new instance of PackageManifest.
-
#null? ⇒ Boolean
Whether this is a null manifest (used for packages that have actually no manifest) or not.
- #short_documentation ⇒ Object
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
#authors ⇒ Object
Returns the value of attribute authors.
67 68 69 |
# File 'lib/autoproj/package_manifest.rb', line 67 def @authors end |
#brief_description ⇒ Object
Returns the value of attribute brief_description.
61 62 63 |
# File 'lib/autoproj/package_manifest.rb', line 61 def brief_description @brief_description end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
62 63 64 |
# File 'lib/autoproj/package_manifest.rb', line 62 def dependencies @dependencies end |
#description ⇒ Object
Returns the value of attribute description.
60 61 62 |
# File 'lib/autoproj/package_manifest.rb', line 60 def description @description end |
#license ⇒ Object
Returns the value of attribute license.
65 66 67 |
# File 'lib/autoproj/package_manifest.rb', line 65 def license @license end |
#maintainers ⇒ Object
Returns the value of attribute maintainers.
68 69 70 |
# File 'lib/autoproj/package_manifest.rb', line 68 def maintainers @maintainers end |
#package ⇒ Object
The Autobuild::Package instance this manifest applies on
58 59 60 |
# File 'lib/autoproj/package_manifest.rb', line 58 def package @package end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
59 60 61 |
# File 'lib/autoproj/package_manifest.rb', line 59 def path @path end |
#rock_maintainers ⇒ Object
Returns the value of attribute rock_maintainers.
69 70 71 |
# File 'lib/autoproj/package_manifest.rb', line 69 def rock_maintainers @rock_maintainers end |
#tags ⇒ Object
Returns the value of attribute tags.
63 64 65 |
# File 'lib/autoproj/package_manifest.rb', line 63 def @tags end |
#url ⇒ Object
Returns the value of attribute url.
64 65 66 |
# File 'lib/autoproj/package_manifest.rb', line 64 def url @url end |
#version ⇒ Object
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
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
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.}" rescue Autoproj::ConfigError => e raise Autobuild::PackageException.new(package.name, "prepare"), "invalid #{path}: #{e.}" 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 |
#documentation ⇒ Object
80 81 82 |
# File 'lib/autoproj/package_manifest.rb', line 80 def documentation description || short_documentation end |
#each_author ⇒ Object
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 return enum_for(__method__) unless block_given? .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_maintainer ⇒ Object
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_maintainer ⇒ Object
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
76 77 78 |
# File 'lib/autoproj/package_manifest.rb', line 76 def has_documentation? description end |
#has_short_documentation? ⇒ 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
107 108 109 |
# File 'lib/autoproj/package_manifest.rb', line 107 def null? @null end |
#short_documentation ⇒ Object
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 |