class Autoproj::PackageManifest::Loader
@api private
REXML stream parser object used to load the XML contents into a {PackageManifest} object
Constants
- AUTHOR_FIELDS
- MANIFEST_CLASS
-
Access to the information contained in a package’s manifest.xml file
Use
PackageManifest.load
to create - TEXT_FIELDS
Attributes
Public Class Methods
Source
# File lib/autoproj/package_manifest.rb, line 192 def self.expand_configuration_variable(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
Source
# 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.expand_configuration_variable(var, condition_context) end end
Calls superclass method
Autoproj::PackageManifest::BaseLoader::new
Public Instance Methods
Source
# File lib/autoproj/package_manifest.rb, line 232 def handle_condition(expr) return true unless expr && !expr.empty? @condition_parser.evaluate(expr) end
Source
# 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
Source
# 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
Source
# 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.tags.concat(@tag_text.strip.split(",").map(&:strip)) end @tag_text = nil end
Source
# 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