ruby-macrodroid 0.9.5 → 0.9.6
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 +68 -12
- data/lib/ruby-macrodroid/base.rb +21 -12
- data/lib/ruby-macrodroid/constraints.rb +4 -1
- data/lib/ruby-macrodroid/macro.rb +50 -6
- data/lib/ruby-macrodroid/triggers.rb +1 -1
- metadata +2 -2
- 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: 652f6174d50060ca2b7e3197c2bc79062ed6af498b1982ef8c73e27b0422ad85
|
4
|
+
data.tar.gz: 86096eb1c1fef612666065e0e3d48c619b4768d801723b6beaa273687d643fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9705342b8176dc48a5bfca362a17e340bfd56f67d2eafa3b20602fa493d02cbf5a9cbfe13b2dfb02565a74bb02bf01477de6884151a659fab4500c4b2cbfea4
|
7
|
+
data.tar.gz: 6e7bae11b8cf64ff3b0efd4f852f6bb8c2e419aa8d25693aeb894dde64c063c2dbcf9abe9bddf5dbe87cb630d8fa6e6c183d105b6b71fedee804918a79467489
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -143,19 +143,23 @@ end
|
|
143
143
|
|
144
144
|
# Category: Applications
|
145
145
|
#
|
146
|
+
|
147
|
+
|
146
148
|
class OpenWebPageAction < ApplicationAction
|
149
|
+
using ColouredText
|
147
150
|
|
148
151
|
def initialize(obj={}, macro=nil)
|
149
|
-
|
150
|
-
|
152
|
+
|
153
|
+
$debug = true
|
154
|
+
puts ('obj: ' + obj.inspect).debug if $debug
|
151
155
|
|
152
156
|
h = if obj.is_a? Hash then
|
153
157
|
|
154
|
-
obj
|
158
|
+
obj.merge({macro: macro})
|
155
159
|
|
156
160
|
elsif obj.is_a? Array
|
157
161
|
|
158
|
-
puts 'obj: ' + obj.inspect if $debug
|
162
|
+
puts ('obj: ' + obj.inspect).debug if $debug
|
159
163
|
e, macro = obj
|
160
164
|
|
161
165
|
a = e.xpath('item/*')
|
@@ -181,7 +185,7 @@ class OpenWebPageAction < ApplicationAction
|
|
181
185
|
|
182
186
|
end
|
183
187
|
|
184
|
-
puts 'h:' + h.inspect if $debug
|
188
|
+
puts ('h:' + h.inspect).debug if $debug
|
185
189
|
|
186
190
|
#h[:url_to_open] = h[:url] if h[:url] and h[:url].length > 1
|
187
191
|
|
@@ -451,8 +455,12 @@ class IfConditionAction < Action
|
|
451
455
|
#macro.add obj2
|
452
456
|
|
453
457
|
end
|
454
|
-
|
455
|
-
{
|
458
|
+
|
459
|
+
h = {
|
460
|
+
constraint_list: @constraints.map(&:to_h)
|
461
|
+
}
|
462
|
+
super(h) {}
|
463
|
+
|
456
464
|
else
|
457
465
|
# get the constraints
|
458
466
|
|
@@ -487,16 +495,41 @@ end
|
|
487
495
|
|
488
496
|
class ElseAction < Action
|
489
497
|
|
490
|
-
def initialize(
|
498
|
+
def initialize(obj=[])
|
491
499
|
|
492
500
|
options = {
|
493
|
-
constraint_list:
|
501
|
+
constraint_list: []
|
494
502
|
}
|
503
|
+
|
504
|
+
if obj.is_a? Hash then
|
505
|
+
|
506
|
+
h = obj
|
495
507
|
|
496
|
-
|
508
|
+
super(options.merge h)
|
509
|
+
|
510
|
+
elsif obj.is_a? Array
|
511
|
+
|
512
|
+
e, macro = obj
|
513
|
+
|
514
|
+
# find any nested actions
|
515
|
+
item = e.element('item')
|
516
|
+
|
517
|
+
if item then
|
518
|
+
|
519
|
+
ap = ActionsNlp.new
|
520
|
+
obj2 = action_to_object(ap, item, item, macro)
|
521
|
+
puts 'obj2: ' + obj2.inspect if $debug
|
522
|
+
#macro.add obj2
|
523
|
+
|
524
|
+
end
|
525
|
+
|
526
|
+
super(options)
|
527
|
+
end
|
528
|
+
|
497
529
|
|
498
530
|
|
499
|
-
|
531
|
+
|
532
|
+
end
|
500
533
|
|
501
534
|
def to_s(colour: false, indent: 0)
|
502
535
|
'Else'
|
@@ -2374,8 +2407,31 @@ end
|
|
2374
2407
|
# Category: Screen
|
2375
2408
|
#
|
2376
2409
|
class ScreenOnAction < ScreenAction
|
2410
|
+
using ColouredText
|
2377
2411
|
|
2378
|
-
def initialize(
|
2412
|
+
def initialize(obj=nil)
|
2413
|
+
|
2414
|
+
debug = false
|
2415
|
+
|
2416
|
+
h = if obj.is_a? Hash then
|
2417
|
+
|
2418
|
+
obj
|
2419
|
+
|
2420
|
+
elsif obj.is_a? Array
|
2421
|
+
=begin
|
2422
|
+
puts 'obj: ' + obj.inspect if debug
|
2423
|
+
e, macro = obj
|
2424
|
+
puts ('e: ' + e.xml.inspect).debug if debug
|
2425
|
+
a = e.xpath('item/*')
|
2426
|
+
|
2427
|
+
txt = e.text.to_s
|
2428
|
+
puts ('txt: ' + txt.inspect).debug if debug
|
2429
|
+
state = txt[/Screen (On|Off)/i,1]
|
2430
|
+
|
2431
|
+
{screen_off: state.downcase == 'off'}
|
2432
|
+
=end
|
2433
|
+
{}
|
2434
|
+
end
|
2379
2435
|
|
2380
2436
|
options = {
|
2381
2437
|
pie_lock_screen: false,
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -9,9 +9,10 @@
|
|
9
9
|
|
10
10
|
module ObjectX
|
11
11
|
|
12
|
+
|
12
13
|
def action_to_object(ap, e, item, macro)
|
13
14
|
|
14
|
-
debug =
|
15
|
+
debug = false
|
15
16
|
|
16
17
|
puts 'inside action_to_object: item.xml: ' + item.xml if debug
|
17
18
|
|
@@ -32,15 +33,23 @@ module ObjectX
|
|
32
33
|
|
33
34
|
r = ap.find_action action
|
34
35
|
puts 'r: ' + r.inspect if debug
|
35
|
-
puts 'description: ' + description.xml.inspect if debug
|
36
|
-
#o = r[0].new([description, self]) if r
|
37
|
-
index = macro.actions.length
|
38
|
-
macro.add Action.new
|
39
|
-
o = object_create(r[0],[description, macro]) if r
|
40
|
-
macro.actions[index] = o
|
41
|
-
puts 'after o' if debug
|
42
|
-
o
|
43
36
|
|
37
|
+
if r[1].any? then
|
38
|
+
|
39
|
+
macro.add r[0].new(r[1])
|
40
|
+
|
41
|
+
else
|
42
|
+
|
43
|
+
puts 'description: ' + description.xml.inspect if debug
|
44
|
+
#o = r[0].new([description, self]) if r
|
45
|
+
index = macro.actions.length
|
46
|
+
macro.add Action.new
|
47
|
+
o = object_create(r[0],[description, macro]) if r
|
48
|
+
macro.actions[index] = o
|
49
|
+
puts 'after o' if debug
|
50
|
+
o
|
51
|
+
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
else
|
@@ -185,11 +194,11 @@ class MacroObject
|
|
185
194
|
private
|
186
195
|
|
187
196
|
def hashify(h)
|
188
|
-
|
197
|
+
puts 'h: ' + h.inspect
|
189
198
|
h2 = h.inject({}) do |r,x|
|
190
|
-
puts 'x: ' + x.inspect if $debug
|
199
|
+
puts 'x: ' + x.inspect #if $debug
|
191
200
|
key, value = x
|
192
|
-
puts 'key: ' + key.inspect if $debug
|
201
|
+
puts 'key: ' + key.inspect #if $debug
|
193
202
|
new_key = key.to_s.gsub(/\w_\w/){|x| x[0] + x[-1].upcase}
|
194
203
|
new_key = new_key.prepend 'm_' unless @list.include? new_key
|
195
204
|
new_key = 'm_SIGUID' if new_key == 'm_siguid'
|
@@ -798,7 +798,10 @@ class MacroDroidVariableConstraint < Constraint
|
|
798
798
|
h[:variable] = {}
|
799
799
|
h[:variable][:name] = h[:loperand]
|
800
800
|
h[:variable][:type] = 2
|
801
|
-
|
801
|
+
|
802
|
+
val = h[:roperand] =~ /true|false/ ? h[:roperand].capitalize \
|
803
|
+
: h[:roperand]
|
804
|
+
h[:string_value] = val
|
802
805
|
end
|
803
806
|
|
804
807
|
options = {
|
@@ -25,6 +25,7 @@ VAR_TYPES = {
|
|
25
25
|
|
26
26
|
class TriggersNlp
|
27
27
|
include AppRoutes
|
28
|
+
using ColouredText
|
28
29
|
|
29
30
|
def initialize(macro=nil)
|
30
31
|
|
@@ -34,8 +35,40 @@ class TriggersNlp
|
|
34
35
|
|
35
36
|
end
|
36
37
|
|
37
|
-
def triggers(params)
|
38
|
+
def triggers(params)
|
39
|
+
|
40
|
+
# -- Battery/Power ---------------------------------------------
|
41
|
+
|
42
|
+
get /^Power Connected: (Wired \([^\)]+\))/i do |s|
|
43
|
+
|
44
|
+
h = {
|
45
|
+
power_connected_options: [true, true, true],
|
46
|
+
has_set_usb_option: true,
|
47
|
+
power_connected: true
|
48
|
+
}
|
49
|
+
|
50
|
+
a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
|
51
|
+
|
52
|
+
puts ('s: ' + s.inspect).debug
|
53
|
+
|
54
|
+
options = s.downcase.split(/ \+ /)
|
55
|
+
puts ('options: ' + options.inspect).debug
|
56
|
+
|
57
|
+
h[:power_connected_options] = a.map {|x| options.include? x.downcase }
|
58
|
+
|
59
|
+
[ExternalPowerTrigger, h]
|
60
|
+
end
|
38
61
|
|
62
|
+
get /^Power Connected: Any/i do |s|
|
63
|
+
|
64
|
+
h = {
|
65
|
+
power_connected_options: [true, true, true],
|
66
|
+
has_set_usb_option: true,
|
67
|
+
power_connected: true
|
68
|
+
}
|
69
|
+
|
70
|
+
[ExternalPowerTrigger, h]
|
71
|
+
end
|
39
72
|
# e.g. at 7:30pm daily
|
40
73
|
get /^(?:at )?(\d+:\d+(?:[ap]m)?) daily/i do |time, days|
|
41
74
|
[TimerTrigger, {time: time,
|
@@ -135,6 +168,7 @@ class ActionsNlp
|
|
135
168
|
def initialize(macro=nil)
|
136
169
|
|
137
170
|
super()
|
171
|
+
|
138
172
|
params = {macro: macro}
|
139
173
|
actions(params)
|
140
174
|
|
@@ -256,13 +290,13 @@ class ActionsNlp
|
|
256
290
|
|
257
291
|
#
|
258
292
|
get /^WebHook \(Url\)/i do
|
259
|
-
[OpenWebPageAction,
|
293
|
+
[OpenWebPageAction, {}]
|
260
294
|
end
|
261
295
|
|
262
296
|
# e.g. webhook entered_kitchen
|
263
297
|
#
|
264
298
|
get /^webhook$/i do
|
265
|
-
[OpenWebPageAction, params]
|
299
|
+
[OpenWebPageAction, {}, params[:macro]]
|
266
300
|
end
|
267
301
|
|
268
302
|
# -- Location ---------------------------------------------------------
|
@@ -272,7 +306,7 @@ class ActionsNlp
|
|
272
306
|
end
|
273
307
|
|
274
308
|
get /^Share Location$/i do
|
275
|
-
[ShareLocationAction,
|
309
|
+
[ShareLocationAction, {}]
|
276
310
|
end
|
277
311
|
|
278
312
|
#a: Keep Device Awake Screen On Until Disabled
|
@@ -296,7 +330,7 @@ class ActionsNlp
|
|
296
330
|
end
|
297
331
|
|
298
332
|
get /Keep Device Awake$/i do
|
299
|
-
[KeepAwakeAction,
|
333
|
+
[KeepAwakeAction, {}]
|
300
334
|
end
|
301
335
|
|
302
336
|
#a: Disable Keep Awake
|
@@ -311,6 +345,10 @@ class ActionsNlp
|
|
311
345
|
[IfConditionAction, {}]
|
312
346
|
end
|
313
347
|
|
348
|
+
get /else/i do
|
349
|
+
[ElseAction, {}]
|
350
|
+
end
|
351
|
+
|
314
352
|
get /End If/i do
|
315
353
|
[EndIfAction, {}]
|
316
354
|
end
|
@@ -320,6 +358,12 @@ class ActionsNlp
|
|
320
358
|
get /^Set Variable$/i do
|
321
359
|
[SetVariableAction, {}]
|
322
360
|
end
|
361
|
+
|
362
|
+
# -- Screen ------------------------------------------------
|
363
|
+
#
|
364
|
+
get /^Screen (On|Off)$/i do |state|
|
365
|
+
[ScreenOnAction, {screen_off: state.downcase == 'off'}]
|
366
|
+
end
|
323
367
|
|
324
368
|
end
|
325
369
|
|
@@ -702,7 +746,7 @@ class Macro
|
|
702
746
|
action = e.text.strip
|
703
747
|
r = ap.find_action action
|
704
748
|
#r[0].new(r[1]) if r
|
705
|
-
self.add object_create(r[0]
|
749
|
+
self.add object_create(r[0],*r[1..-1]) if r
|
706
750
|
|
707
751
|
end
|
708
752
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macrodroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
NZ2kdBIUDnAM24e0/wXdVxg4HnsZbdymxyzMQ4P5pKYcpI6oisBxI37p/Xy+wAg3
|
36
36
|
SBHno3GEuuD8ZWj24IMJpfbp
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-10-
|
38
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|