Method: Maruto::ModuleConfiguration.parse_module_version

Defined in:
lib/maruto/module_configuration.rb

.parse_module_version(m, xml_root) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/maruto/module_configuration.rb', line 26

def self.parse_module_version(m, xml_root)
	xml_node = xml_root.at_xpath('/config/modules')

	if xml_node.nil?
		return ["config.xml is missing a /config/modules node"]
	end

	warnings = []

	unless xml_node.at_xpath("./#{m[:name]}")
		warnings << "config.xml is missing a /config/modules/#{m[:name]} node"
	end

	xml_node.xpath("./*").each do |n|
		unless n.name.to_sym == m[:name]
			warnings << "config.xml contains configuration for a different module (/config/modules/#{n.name})"
		end
	end

	m[:version] = xml_node.at_xpath("./#{m[:name]}/version").content unless xml_node.at_xpath("./#{m[:name]}/version").nil?

	warnings
end