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) ⇒ 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) ⇒ 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.
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 = [] = [] @maintainers = [] @rock_maintainers = [] = [] @null = null end |
Instance Attribute Details
#authors ⇒ Object
Returns the value of attribute authors.
59 60 61 |
# File 'lib/autoproj/package_manifest.rb', line 59 def end |
#brief_description ⇒ Object
Returns the value of attribute brief_description.
53 54 55 |
# File 'lib/autoproj/package_manifest.rb', line 53 def brief_description @brief_description end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
54 55 56 |
# File 'lib/autoproj/package_manifest.rb', line 54 def dependencies @dependencies end |
#description ⇒ Object
Returns the value of attribute description.
52 53 54 |
# File 'lib/autoproj/package_manifest.rb', line 52 def description @description end |
#license ⇒ Object
Returns the value of attribute license.
57 58 59 |
# File 'lib/autoproj/package_manifest.rb', line 57 def license @license end |
#maintainers ⇒ Object
Returns the value of attribute maintainers.
60 61 62 |
# File 'lib/autoproj/package_manifest.rb', line 60 def maintainers @maintainers end |
#package ⇒ Object
The Autobuild::Package instance this manifest applies on
50 51 52 |
# File 'lib/autoproj/package_manifest.rb', line 50 def package @package end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
51 52 53 |
# File 'lib/autoproj/package_manifest.rb', line 51 def path @path end |
#rock_maintainers ⇒ Object
Returns the value of attribute rock_maintainers.
61 62 63 |
# File 'lib/autoproj/package_manifest.rb', line 61 def rock_maintainers @rock_maintainers end |
#tags ⇒ Object
Returns the value of attribute tags.
55 56 57 |
# File 'lib/autoproj/package_manifest.rb', line 55 def end |
#url ⇒ Object
Returns the value of attribute url.
56 57 58 |
# File 'lib/autoproj/package_manifest.rb', line 56 def url @url end |
#version ⇒ Object
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
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
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 |
#documentation ⇒ Object
72 73 74 |
# File 'lib/autoproj/package_manifest.rb', line 72 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)
143 144 145 146 147 148 149 |
# File 'lib/autoproj/package_manifest.rb', line 143 def return enum_for(__method__) unless block_given? .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_maintainer ⇒ Object
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_maintainer ⇒ Object
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
68 69 70 |
# File 'lib/autoproj/package_manifest.rb', line 68 def has_documentation? description end |
#has_short_documentation? ⇒ 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
99 100 101 |
# File 'lib/autoproj/package_manifest.rb', line 99 def null? @null end |
#short_documentation ⇒ Object
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 |