ruby-macrodroid 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid/actions.rb +31 -12
- data/lib/ruby-macrodroid/base.rb +3 -3
- data/lib/ruby-macrodroid/constraints.rb +1 -1
- data/lib/ruby-macrodroid/macro.rb +10 -3
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7aa07338b6ffd2e4edcad4e7a2b63dee60f71632cb5a29a7f54de51570136f9
|
4
|
+
data.tar.gz: 55009e156bce03bdfb487a46cb0085f3c7f0b5375949b602e3e76ce216148e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710ed235030b9553dcd3ca9f7c79efc6a7608f46ad59e4c14b38a5a2725b81f2145e5bc13cbc7d1385718754115a1de1976896030185b497833b916897d1e57f
|
7
|
+
data.tar.gz: de58a516f728dc63dc0660eac45b137a03a1f447554e8e34a8ed61e06e0a578abc1dd1567ff83592677d416534efa5923649dce8af20c19ad991f21006447e77
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -33,6 +33,7 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
class Action < MacroObject
|
36
|
+
using ColouredText
|
36
37
|
using Params
|
37
38
|
include ObjectX
|
38
39
|
|
@@ -160,7 +161,17 @@ class OpenWebPageAction < ApplicationAction
|
|
160
161
|
a = e.xpath('item/*')
|
161
162
|
|
162
163
|
h2 = if a.any? then
|
163
|
-
|
164
|
+
|
165
|
+
a.map do |node|
|
166
|
+
|
167
|
+
if node.name == 'description' and node.text.to_s =~ /: / then
|
168
|
+
node.text.to_s.split(/: +/,2).map(&:strip)
|
169
|
+
else
|
170
|
+
[node.name.to_sym, node.text.to_s.strip]
|
171
|
+
end
|
172
|
+
|
173
|
+
end.to_h
|
174
|
+
|
164
175
|
else
|
165
176
|
txt = e.text('item/description')
|
166
177
|
{url: (txt || e.text)}
|
@@ -394,7 +405,7 @@ class IfConditionAction < Action
|
|
394
405
|
a: true,
|
395
406
|
constraint_list: []
|
396
407
|
}
|
397
|
-
puts 'obj: ' + obj.inspect
|
408
|
+
puts 'obj: ' + obj.inspect if $debug
|
398
409
|
|
399
410
|
if obj.is_a? Hash then
|
400
411
|
|
@@ -407,20 +418,20 @@ class IfConditionAction < Action
|
|
407
418
|
|
408
419
|
e, macro = obj
|
409
420
|
super()
|
410
|
-
puts 'e.xml: ' + e.xml
|
411
|
-
puts 'e.text: ' + e.text.to_s.strip
|
421
|
+
puts 'e.xml: ' + e.xml if $debug
|
422
|
+
puts 'e.text: ' + e.text.to_s.strip if $debug
|
412
423
|
raw_txt = e.text.to_s.strip[/^if [^$]+/i] || e.text('item/description')
|
413
|
-
puts 'raw_txt: ' + raw_txt.inspect
|
424
|
+
puts 'raw_txt: ' + raw_txt.inspect if $debug
|
414
425
|
|
415
426
|
clause = raw_txt[/^If (.*)/i,1]
|
416
|
-
puts 'clause: ' + clause.inspect
|
427
|
+
puts 'clause: ' + clause.inspect if $debug
|
417
428
|
conditions = clause.split(/\s+\b(?:AND|OR)\b\s+/i)
|
418
|
-
puts 'conditions: ' + conditions.inspect
|
429
|
+
puts 'conditions: ' + conditions.inspect if $debug
|
419
430
|
|
420
431
|
cp = ConstraintsNlp.new
|
421
432
|
|
422
433
|
@constraints = conditions.map do |c|
|
423
|
-
puts 'c: ' + c.inspect
|
434
|
+
puts 'c: ' + c.inspect if $debug
|
424
435
|
r = cp.find_constraint c
|
425
436
|
puts 'found constraint ' + r.inspect if $debug
|
426
437
|
|
@@ -436,7 +447,7 @@ class IfConditionAction < Action
|
|
436
447
|
|
437
448
|
ap = ActionsNlp.new
|
438
449
|
obj2 = action_to_object(ap, item, item, macro)
|
439
|
-
puts 'obj2: ' + obj2.inspect
|
450
|
+
puts 'obj2: ' + obj2.inspect if $debug
|
440
451
|
#macro.add obj2
|
441
452
|
|
442
453
|
end
|
@@ -1627,6 +1638,7 @@ end
|
|
1627
1638
|
# MacroDroid Specific
|
1628
1639
|
#
|
1629
1640
|
class SetVariableAction < Action
|
1641
|
+
using ColouredText
|
1630
1642
|
|
1631
1643
|
def initialize(obj=nil)
|
1632
1644
|
|
@@ -1635,7 +1647,14 @@ class SetVariableAction < Action
|
|
1635
1647
|
elsif obj.is_a? Array
|
1636
1648
|
e, macro = obj
|
1637
1649
|
node = e.element('item/*')
|
1638
|
-
|
1650
|
+
#puts ("node.name: %s node.value: %s" % [node.name, node.value]).debug
|
1651
|
+
r = macro.set_var node.name, node.value.to_s
|
1652
|
+
puts ('r: ' + r.inspect).debug if $debug
|
1653
|
+
r
|
1654
|
+
if r[:type] == 2 then
|
1655
|
+
{ variable: {name: r[:name], type: r[:type]}, new_string_value: r[:string_value]
|
1656
|
+
}
|
1657
|
+
end
|
1639
1658
|
end
|
1640
1659
|
|
1641
1660
|
options = {
|
@@ -2433,7 +2452,7 @@ class KeepAwakeAction < ScreenAction
|
|
2433
2452
|
h2 = if txt then
|
2434
2453
|
|
2435
2454
|
raw_duration = (txt || e.text).to_s
|
2436
|
-
puts 'raw_duration: ' + raw_duration.inspect
|
2455
|
+
puts 'raw_duration: ' + raw_duration.inspect if $debug
|
2437
2456
|
duration = raw_duration[/Screen On - ([^$]+)/i]
|
2438
2457
|
{duration: duration}
|
2439
2458
|
|
@@ -2445,7 +2464,7 @@ class KeepAwakeAction < ScreenAction
|
|
2445
2464
|
|
2446
2465
|
end
|
2447
2466
|
|
2448
|
-
puts ('h: ' + h.inspect).debug
|
2467
|
+
puts ('h: ' + h.inspect).debug if $debug
|
2449
2468
|
|
2450
2469
|
if h[:duration] then
|
2451
2470
|
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -11,7 +11,7 @@ module ObjectX
|
|
11
11
|
|
12
12
|
def action_to_object(ap, e, item, macro)
|
13
13
|
|
14
|
-
debug =
|
14
|
+
debug = $debug
|
15
15
|
|
16
16
|
puts 'inside action_to_object: item.xml: ' + item.xml if debug
|
17
17
|
|
@@ -46,7 +46,7 @@ module ObjectX
|
|
46
46
|
else
|
47
47
|
|
48
48
|
action = e.text.strip
|
49
|
-
puts 'action: ' + action.inspect if
|
49
|
+
puts 'action: ' + action.inspect if $debug
|
50
50
|
r = ap.find_action action
|
51
51
|
|
52
52
|
a = e.xpath('item/*')
|
@@ -56,7 +56,7 @@ module ObjectX
|
|
56
56
|
else
|
57
57
|
{}
|
58
58
|
end
|
59
|
-
puts 'h: ' + h.inspect if
|
59
|
+
puts 'h: ' + h.inspect if $debug
|
60
60
|
|
61
61
|
#r = ap.find_action action
|
62
62
|
#r[0].new(h.merge(macro: self)) if r
|
@@ -908,7 +908,7 @@ class TriggerThatInvokedConstraint < Constraint
|
|
908
908
|
|
909
909
|
def initialize(h={})
|
910
910
|
|
911
|
-
puts ('h: ' + h.inspect).green
|
911
|
+
puts ('h: ' + h.inspect).green if $debug
|
912
912
|
@trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
|
913
913
|
|
914
914
|
options = {
|
@@ -198,6 +198,10 @@ class ActionsNlp
|
|
198
198
|
[VibrateAction, {pattern: pattern}]
|
199
199
|
end
|
200
200
|
|
201
|
+
get /^Vibrate$/i do |pattern|
|
202
|
+
[VibrateAction, {pattern: 'short buzz'}]
|
203
|
+
end
|
204
|
+
|
201
205
|
# e.g. Display Notification: Hi there: This is the body of the message
|
202
206
|
get /^Display Notification: ([^:]+): [^$]+$/i do |subject, text|
|
203
207
|
[NotificationAction, {subject: subject, text: text}]
|
@@ -422,8 +426,8 @@ class Macro
|
|
422
426
|
end
|
423
427
|
|
424
428
|
def add(obj)
|
425
|
-
puts 'inside add; ' + obj.inspect
|
426
|
-
puts '@actions: ' + @actions.inspect
|
429
|
+
puts 'inside add; ' + obj.inspect if @debug
|
430
|
+
puts '@actions: ' + @actions.inspect if @debug
|
427
431
|
|
428
432
|
if obj.kind_of? Trigger then
|
429
433
|
|
@@ -774,7 +778,10 @@ class Macro
|
|
774
778
|
if not @local_variables.has_key? label.to_sym then
|
775
779
|
@local_variables.merge!({label.to_sym => value})
|
776
780
|
end
|
777
|
-
|
781
|
+
|
782
|
+
if @debug then
|
783
|
+
puts ("before varify; label: %s value: %s" % [label, value]).debug
|
784
|
+
end
|
778
785
|
varify(label, value)
|
779
786
|
end
|
780
787
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|