12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/ruby-macrodroid/base.rb', line 12
def action_to_object(ap, e, item, macro)
debug = true
puts 'inside action_to_object: item.xml: ' + item.xml if debug
if item.element('description') then
item.xpath('description').map do |description|
inner_lines = description.text.to_s.strip.lines
puts 'inner_lines: ' + inner_lines.inspect if debug
action = if e.text.to_s.strip.empty? then
inner_lines.shift.strip
else
e.text.strip
end
puts 'action: ' + action.inspect if debug
r = ap.find_action action
puts 'r: ' + r.inspect if debug
puts 'description: ' + description.xml.inspect if debug
index = macro.actions.length
macro.add Action.new
o = object_create(r[0],[description, macro]) if r
macro.actions[index] = o
puts 'after o' if debug
o
end
else
action = e.text.strip
puts 'action: ' + action.inspect if @debug
r = ap.find_action action
a = e.xpath('item/*')
h = if a.any? then
a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h
else
{}
end
puts 'h: ' + h.inspect if @debug
o = object_create(r[0], h.merge(macro: macro)) if r
macro.add o
o
end
end
|