Class: Autoproj::PackageManifest::Loader Private
- Inherits:
-
BaseLoader
- Object
- BaseLoader
- Autoproj::PackageManifest::Loader
- Defined in:
- lib/autoproj/package_manifest.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
REXML stream parser object used to load the XML contents into a Autoproj::PackageManifest object
Direct Known Subclasses
Constant Summary collapse
- MANIFEST_CLASS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
PackageManifest
- TEXT_FIELDS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
- AUTHOR_FIELDS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #manifest ⇒ Object readonly private
- #path ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #handle_condition(expr) ⇒ Object private
-
#initialize(path, manifest, condition_context: Configuration.new) ⇒ Loader
constructor
private
A new instance of Loader.
- #parse_contact_field(text) ⇒ Object private
- #parse_depend_tag(tag_name, attributes, modes: [], optional: false) ⇒ Object private
- #toplevel_tag_end(name) ⇒ Object private
- #toplevel_tag_start(name, attributes) ⇒ Object private
Methods inherited from BaseLoader
Constructor Details
#initialize(path, manifest, condition_context: Configuration.new) ⇒ Loader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Loader.
223 224 225 226 227 228 229 230 |
# File 'lib/autoproj/package_manifest.rb', line 223 def initialize(path, manifest, condition_context: Configuration.new) super() @path = path @manifest = manifest @condition_parser = RosConditionParser.new do |var| Loader.(var, condition_context) end end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
188 189 190 |
# File 'lib/autoproj/package_manifest.rb', line 188 def manifest @manifest end |
#path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
188 189 190 |
# File 'lib/autoproj/package_manifest.rb', line 188 def path @path end |
Class Method Details
.expand_configuration_variable(var, config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/autoproj/package_manifest.rb', line 192 def self.(var, config) prefix = var[0, 1] var = var[1..-1] if prefix == "$" if var.start_with?("operating_system_name_") os = config.get("operating_system", nil) return "" if os.nil? os_names, = os return "" unless os_names.any? do |name| var == "operating_system_name_#{name}" end return "true" end if var.start_with?("operating_system_version_") os = config.get("operating_system", nil) return "" if os.nil? _, os_versions = os return "" unless os_versions.any? do |ver| var == "operating_system_version_#{ver.gsub(/[.,+-]/, '_')}" end return "true" end config.get(var) end |
Instance Method Details
#handle_condition(expr) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
232 233 234 235 236 |
# File 'lib/autoproj/package_manifest.rb', line 232 def handle_condition(expr) return true unless expr && !expr.empty? @condition_parser.evaluate(expr) end |
#parse_contact_field(text) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
259 260 261 262 263 264 265 |
# File 'lib/autoproj/package_manifest.rb', line 259 def parse_contact_field(text) text.strip.split(",").map do |str| name, email = str.split("/").map(&:strip) email = nil if email&.empty? ContactInfo.new(name, email) end end |
#parse_depend_tag(tag_name, attributes, modes: [], optional: false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/autoproj/package_manifest.rb', line 238 def parse_depend_tag(tag_name, attributes, modes: [], optional: false) package = attributes["package"] || attributes["name"] unless package raise InvalidPackageManifest, "found '#{tag_name}' tag in #{path} "\ "without a 'package' attribute" end return unless handle_condition(attributes["condition"]) if (tag_modes = attributes["modes"]) modes += tag_modes.split(",") end manifest.add_dependency( package, optional: optional || (attributes["optional"] == "1"), modes: modes ) end |
#toplevel_tag_end(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/autoproj/package_manifest.rb', line 293 def toplevel_tag_end(name) if AUTHOR_FIELDS.include?(name) manifest.send("#{name}s").concat(parse_contact_field(@tag_text)) elsif TEXT_FIELDS.include?(name) field = @tag_text.strip manifest.send("#{name}=", field) unless field.empty? elsif name == "tags" manifest..concat(@tag_text.strip.split(",").map(&:strip)) end @tag_text = nil end |
#toplevel_tag_start(name, attributes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/autoproj/package_manifest.rb', line 270 def toplevel_tag_start(name, attributes) if name == "depend" parse_depend_tag(name, attributes) elsif name == "depend_optional" parse_depend_tag(name, attributes, optional: true) elsif name == "rosdep" parse_depend_tag(name, attributes) elsif name =~ /^(\w+)_depend$/ parse_depend_tag(name, attributes, modes: [$1]) elsif name == "description" if (brief = attributes["brief"]) manifest.brief_description = brief end @tag_text = "" elsif TEXT_FIELDS.include?(name) || AUTHOR_FIELDS.include?(name) @tag_text = "" elsif name == "tags" @tag_text = "" else @tag_text = nil end end |