74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/confetti/config.rb', line 74
def populate( config_doc )
begin
config_doc = REXML::Document.new( config_doc ).root
rescue REXML::ParseException
raise XMLError, "malformed config.xml"
rescue Iconv::InvalidCharacter
raise EncodingError, "unable to read config.xml"
end
if config_doc.nil?
raise XMLError, "no doc parsed"
end
@xml_doc = config_doc
@package = config_doc.attributes["id"]
@version_string = config_doc.attributes["version"]
@version_code = config_doc.attributes["versionCode"]
config_doc.elements.each do |ele|
attr = ele.attributes
case ele.namespace
when "http://www.w3.org/ns/widgets"
case ele.name
when "name"
@name = Name.new(ele.text.nil? ? "" : ele.text.strip,
attr["shortname"])
when "author"
@author = Author.new(ele.text.nil? ? "" : ele.text.strip,
attr["href"], attr["email"])
when "description"
@description = ele.text.nil? ? "" : ele.text.strip
when "icon"
@icon_set << Image.new(attr["src"], attr["height"], attr["width"],
attr)
@plist_icon_set << attr["src"]
when "feature"
feature = Feature.new(attr["name"], attr["required"])
ele.each_element( 'param' ) do |param|
p_attr = param.attributes
feature.param_set << Param.new(p_attr["name"], p_attr["value"])
end
@feature_set << feature
when "preference"
@preference_set << Preference.new(attr["name"], attr["value"],
attr["readonly"])
when "license"
@license = License.new(ele.text.nil? ? "" : ele.text.strip,
attr["href"])
when "access"
sub = boolean_value(attr["subdomains"], true)
browserOnly = boolean_value(attr["browserOnly"])
@access_set << Access.new(attr["origin"], sub, browserOnly)
when "content"
@content = Content.new(attr["src"], attr["type"], attr["encoding"])
end
when "http://phonegap.com/ns/1.0"
case ele.name
when "platform"
@platform_set << Platform.new(attr["name"])
when "splash"
next if attr["src"].nil? or attr["src"].empty?
@splash_set << Image.new(attr["src"], attr["height"], attr["width"],
attr)
when "url-scheme"
schms = ele.elements.to_a('scheme').map { |a| a.text }
schms.reject! { |a| a.nil? || a.empty? }
next if schms.empty?
@url_scheme_set << UrlScheme.new(schms, attr["name"], attr["role"])
when "plugin"
next if attr["name"].nil? or attr["name"].empty?
plugin = Plugin.new(attr["name"], attr["version"])
ele.each_element('param') do |param|
p_attr = param.attributes
plugin.param_set << Param.new(p_attr["name"], p_attr["value"])
end
@plugin_set << plugin
end
end
end
end
|