Class: Autoproj::RosPackageManifest::Loader Private

Inherits:
PackageManifest::Loader show all
Defined in:
lib/autoproj/ros_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 PackageManifest object

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.

RosPackageManifest
SUPPORTED_MODES =

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.

%w[test doc].freeze
DEPEND_TAGS =

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.

%w[depend build_depend build_export_depend
buildtool_depend buildtool_export_depend
exec_depend test_depend run_depend doc_depend].to_set.freeze

Constants inherited from PackageManifest::Loader

PackageManifest::Loader::AUTHOR_FIELDS, PackageManifest::Loader::TEXT_FIELDS

Instance Attribute Summary

Attributes inherited from PackageManifest::Loader

#manifest, #path

Instance Method Summary collapse

Methods inherited from PackageManifest::Loader

#parse_contact_field, #parse_depend_tag

Methods inherited from PackageManifest::BaseLoader

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



26
27
28
29
30
# File 'lib/autoproj/ros_package_manifest.rb', line 26

def initialize(path, manifest)
    super
    @env = manifest.package.ws.env
    @condition_parser = RosConditionParser.new(@env)
end

Instance Method Details

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



100
101
102
103
104
105
106
# File 'lib/autoproj/ros_package_manifest.rb', line 100

def author_tag_end(name)
    author_name = @tag_text.strip
    email = @author_email ? @author_email.strip : nil
    email = nil if email&.empty?
    contact = PackageManifest::ContactInfo.new(author_name, email)
    manifest.send("#{name}s").concat([contact])
end

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



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/autoproj/ros_package_manifest.rb', line 84

def depend_tag_end(name)
    return unless handle_condition(@depend_condition)

    if @tag_text.strip.empty?
        raise InvalidPackageManifest, "found '#{name}' tag in #{path} "\
                                      "without content"
    end

    mode = []
    if (m = /^(\w+)_depend$/.match(name))
        mode = SUPPORTED_MODES & [m[1]]
    end

    manifest.add_dependency(@tag_text, modes: mode)
end

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



53
54
55
56
57
58
# File 'lib/autoproj/ros_package_manifest.rb', line 53

def exportlevel_tag_end(name)
    return unless name == "build_type"
    return unless handle_condition(@build_type_condition)

    manifest.build_type = @tag_text.strip
end

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



46
47
48
49
50
51
# File 'lib/autoproj/ros_package_manifest.rb', line 46

def exportlevel_tag_start(name, attributes)
    return unless name == "build_type"

    @build_type_condition = attributes["condition"]
    @tag_text = ""
end

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



78
79
80
81
82
# File 'lib/autoproj/ros_package_manifest.rb', line 78

def handle_condition(expr)
    return true unless expr && !expr.empty?

    @condition_parser.evaluate(expr)
end

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



37
38
39
40
41
42
43
44
# File 'lib/autoproj/ros_package_manifest.rb', line 37

def tag_end(name)
    super
    exportlevel_tag_end(name) if @export_level
    if @tag_level == 0 && name == "package" &&
       (!manifest.name || manifest.name.empty?)
        raise InvalidPackageManifest, "Package name missiing in #{path}"
    end
end

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



32
33
34
35
# File 'lib/autoproj/ros_package_manifest.rb', line 32

def tag_start(name, attributes)
    super
    exportlevel_tag_start(name, attributes) if @export_level
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.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/autoproj/ros_package_manifest.rb', line 108

def toplevel_tag_end(name)
    if DEPEND_TAGS.include?(name)
        depend_tag_end(name)
    elsif AUTHOR_FIELDS.include?(name)
        author_tag_end(name)
    elsif TEXT_FIELDS.include?(name)
        field = @tag_text.strip
        manifest.send("#{name}=", field) unless field.empty?
    elsif name == "name"
        manifest.name = @tag_text.strip
    elsif name == "export"
        @export_level = false
    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.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/autoproj/ros_package_manifest.rb', line 60

def toplevel_tag_start(name, attributes)
    if DEPEND_TAGS.include?(name)
        @depend_condition = attributes["condition"]
        @tag_text = ""
    elsif TEXT_FIELDS.include?(name)
        @tag_text = ""
    elsif AUTHOR_FIELDS.include?(name)
        @author_email = attributes["email"]
        @tag_text = ""
    elsif name == "name"
        @tag_text = ""
    elsif name == "export"
        @export_level = true
    else
        @tag_text = nil
    end
end