Class: Autoproj::PackageManifest::Loader Private

Inherits:
BaseLoader
  • Object
show all
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

RosPackageManifest::Loader

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

Instance Method Summary collapse

Methods inherited from BaseLoader

#tag_end, #tag_start, #text

Constructor Details

#initialize(path, manifest) ⇒ 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.



184
185
186
187
188
# File 'lib/autoproj/package_manifest.rb', line 184

def initialize(path, manifest)
    super()
    @path = path
    @manifest = manifest
end

Instance Attribute Details

#manifestObject (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.



180
181
182
# File 'lib/autoproj/package_manifest.rb', line 180

def manifest
  @manifest
end

#pathObject (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.



180
181
182
# File 'lib/autoproj/package_manifest.rb', line 180

def path
  @path
end

Instance Method Details

#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.



209
210
211
212
213
214
215
# File 'lib/autoproj/package_manifest.rb', line 209

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.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/autoproj/package_manifest.rb', line 190

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

    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.



243
244
245
246
247
248
249
250
251
252
253
# File 'lib/autoproj/package_manifest.rb', line 243

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

#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.



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/autoproj/package_manifest.rb', line 220

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