19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/xmlmunger/parser.rb', line 19
def run options = {}
raise TypeError.new("options argument must be a hash") unless options.is_a?(Hash)
options = default_options.merge options
filtered = options[:filter].inject(xml) { |hash, key| hash[key] }
traverse = NestedHash[filtered].map_values_with_route do |route, value|
next if !options[:attributes] && route.any? { |r| r =~ /@/ }
next if options[:prohibited_types].any? { |type| value.is_a?(type) }
value = ListHeuristics.new(value).to_variable_hash if value.is_a?(Array)
[route, value]
end.compact
parsed = NestedHash[traverse].map_values_with_route do |route, value|
key = make_key(route, options)
[key, value]
end
NestedHash[parsed]
end
|