ruby-macrodroid 0.8.0 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid.rb +149 -25
- data/lib/ruby-macrodroid/actions.rb +290 -6
- data/lib/ruby-macrodroid/base.rb +0 -52
- data/lib/ruby-macrodroid/triggers.rb +50 -2
- 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: a58f2837ede78c4bdb29b2673c38cf07b850dd8431aa47bf59b9ba08512d1970
|
4
|
+
data.tar.gz: 5300eb53b78a33b8d52682ac21fc901a8fab86f273c581a4fdf5e4fbb033c404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af593ce8663d6a1842fc3f49dedee195119c82dab6f2f2bba8f9f96cce1ef6e8065efa281777598502261e168ee452cccb09583460b15f7e425ea39a65e8f6b8
|
7
|
+
data.tar.gz: d0f84f3016d838e0fc326695dec1631fbfa27f07951045a3518cc7ad36b3f899e03a060459f72864568ea50e74c68009d9baf6411e31de36b8cea56f3be7bc93
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
t
|
2
|
-
|
1
|
+
����M�#�6��G�B|�K�Ovn^?ZM+����E�'�[�.T�A�A0@:tZߣ�(���<�=�<t-y��)LM�/Ф��ųļzJ���_F��c��U���� O��-�O�x���jdK=��\�d�̽W�)7�%h�e�B������+,TD��(,�|�poY�O��*F�:kH\�>�re2�}��B*��m��asRbH!�烆ZYlT�J��؈#u�H��"
|
2
|
+
�d1��x�ƪ�e�^���?���5)�Aɻ
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby-macrodroid.rb
CHANGED
@@ -40,10 +40,7 @@ require 'geocoder'
|
|
40
40
|
require 'subunit'
|
41
41
|
require 'rxfhelper'
|
42
42
|
require 'chronic_cron'
|
43
|
-
|
44
|
-
require 'ruby-macrodroid/triggers'
|
45
|
-
require 'ruby-macrodroid/actions'
|
46
|
-
require 'ruby-macrodroid/constraints'
|
43
|
+
|
47
44
|
|
48
45
|
MODEL =<<EOF
|
49
46
|
device
|
@@ -157,6 +154,16 @@ class ActionsNlp
|
|
157
154
|
[ToastAction, {msg: msg}]
|
158
155
|
end
|
159
156
|
|
157
|
+
# e.g. Popup Message\n hello world!
|
158
|
+
get /^Popup Message\n\s+(.*)/im do |msg|
|
159
|
+
[ToastAction, {msg: msg}]
|
160
|
+
end
|
161
|
+
|
162
|
+
# e.g. Popup Message
|
163
|
+
get /^Popup Message$/i do
|
164
|
+
[ToastAction, {}]
|
165
|
+
end
|
166
|
+
|
160
167
|
# e.g. say current time
|
161
168
|
get /^say current[ _]time/i do
|
162
169
|
[SayTimeAction, {}]
|
@@ -246,16 +253,17 @@ class ActionsNlp
|
|
246
253
|
[KeepAwakeAction, {enabled: false, screen_option: 0}]
|
247
254
|
end
|
248
255
|
|
256
|
+
#a: Disable Keep Awake
|
257
|
+
#
|
258
|
+
get /if (.*)/i do
|
259
|
+
[IfConditionAction, {}]
|
260
|
+
end
|
249
261
|
|
250
262
|
end
|
251
263
|
|
252
264
|
alias find_action run_route
|
253
265
|
|
254
|
-
def to_s(colour: false)
|
255
|
-
'ActionsNlp ' + @h.inspect
|
256
|
-
end
|
257
266
|
|
258
|
-
alias to_summary to_s
|
259
267
|
end
|
260
268
|
|
261
269
|
class ConstraintsNlp
|
@@ -282,6 +290,60 @@ class ConstraintsNlp
|
|
282
290
|
end
|
283
291
|
|
284
292
|
|
293
|
+
module Params
|
294
|
+
|
295
|
+
refine Hash do
|
296
|
+
|
297
|
+
# turns keys from camelCase into snake_case
|
298
|
+
|
299
|
+
def to_snake_case(h=self)
|
300
|
+
|
301
|
+
h.inject({}) do |r, x|
|
302
|
+
|
303
|
+
key, value = x
|
304
|
+
#puts 'value: ' + value.inspect
|
305
|
+
|
306
|
+
val = if value.is_a?(Hash) then
|
307
|
+
to_snake_case(value)
|
308
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
309
|
+
value.map {|row| to_snake_case(row)}
|
310
|
+
else
|
311
|
+
value
|
312
|
+
end
|
313
|
+
|
314
|
+
r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
|
315
|
+
x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
316
|
+
.downcase.to_sym => val
|
317
|
+
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
# turns keys from snake_case to CamelCase
|
322
|
+
def to_camel_case(h=self)
|
323
|
+
|
324
|
+
h.inject({}) do |r,x|
|
325
|
+
|
326
|
+
key, value = x
|
327
|
+
|
328
|
+
val = if value.is_a?(Hash) then
|
329
|
+
to_camel_case(value)
|
330
|
+
elsif value.is_a?(Array) and value.first.is_a? Hash
|
331
|
+
value.map {|row| to_camel_case(row)}
|
332
|
+
else
|
333
|
+
value
|
334
|
+
end
|
335
|
+
|
336
|
+
r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
|
337
|
+
end
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
end
|
345
|
+
|
346
|
+
|
285
347
|
|
286
348
|
class Macro
|
287
349
|
using ColouredText
|
@@ -356,7 +418,25 @@ class Macro
|
|
356
418
|
@description = h[:description]
|
357
419
|
|
358
420
|
# fetch the local variables
|
359
|
-
|
421
|
+
if h[:local_variables].any? and h[:local_variables].first.any? then
|
422
|
+
|
423
|
+
@local_variables = h[:local_variables].map do |var|
|
424
|
+
|
425
|
+
val = case var[:type]
|
426
|
+
when 0 # boolean
|
427
|
+
var[:boolean_value]
|
428
|
+
when 1 # integer
|
429
|
+
var[:int_value]
|
430
|
+
when 2 # string
|
431
|
+
var[:string_value]
|
432
|
+
when 3 # decimal
|
433
|
+
var[:decimal_Value]
|
434
|
+
end
|
435
|
+
|
436
|
+
[var[:name], val]
|
437
|
+
|
438
|
+
end.to_h
|
439
|
+
end
|
360
440
|
|
361
441
|
# fetch the triggers
|
362
442
|
@triggers = h[:trigger_list].map do |trigger|
|
@@ -463,20 +543,42 @@ class Macro
|
|
463
543
|
@actions = node.xpath('action').map do |e|
|
464
544
|
|
465
545
|
puts 'action e: ' + e.xml.inspect if @debug
|
466
|
-
|
546
|
+
puts 'e.text ' + e.text if @debug
|
547
|
+
|
548
|
+
inner_lines = e.xpath('item/description/text()')
|
549
|
+
|
550
|
+
action = if e.text.to_s.strip.empty? then
|
551
|
+
inner_lines.shift
|
552
|
+
else
|
553
|
+
e.text.strip
|
554
|
+
end
|
555
|
+
|
556
|
+
r = ap.find_action action
|
467
557
|
puts 'found action ' + r.inspect if @debug
|
468
558
|
|
469
559
|
if r then
|
470
560
|
|
471
|
-
|
561
|
+
loose = inner_lines.shift
|
472
562
|
|
473
|
-
|
474
|
-
|
563
|
+
raw_attributes = if loose then
|
564
|
+
|
565
|
+
puts 'do something ' + loose.to_s if @debug
|
566
|
+
loose.to_s
|
567
|
+
|
475
568
|
else
|
476
|
-
|
569
|
+
|
570
|
+
a = e.xpath('item/*')
|
571
|
+
|
572
|
+
h = if a.any? then
|
573
|
+
a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h
|
574
|
+
else
|
575
|
+
{}
|
576
|
+
end
|
577
|
+
|
578
|
+
r[1].merge(h)
|
579
|
+
|
477
580
|
end
|
478
|
-
|
479
|
-
r[0].new(r[1].merge(h))
|
581
|
+
r[0].new(raw_attributes)
|
480
582
|
end
|
481
583
|
|
482
584
|
end
|
@@ -584,7 +686,7 @@ EOF
|
|
584
686
|
|
585
687
|
end
|
586
688
|
|
587
|
-
if s =~ /^If/i then
|
689
|
+
if s =~ /^(?:If|WHILE \/ DO)/i then
|
588
690
|
|
589
691
|
if indent < 1 then
|
590
692
|
|
@@ -607,22 +709,39 @@ EOF
|
|
607
709
|
end.join("\n")
|
608
710
|
|
609
711
|
a = [
|
610
|
-
(colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title
|
611
|
-
@triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
|
612
|
-
+ ": %s" % x}.join("\n"),
|
613
|
-
actions
|
712
|
+
(colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title
|
614
713
|
]
|
615
714
|
|
715
|
+
if @description and @description.length >= 1 then
|
716
|
+
a << (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
|
717
|
+
+ @description.gsub(/\n/,"\n ")
|
718
|
+
end
|
719
|
+
|
720
|
+
if @local_variables.length >= 1 then
|
721
|
+
|
722
|
+
vars = @local_variables.map do |k,v|
|
723
|
+
label = colour ? 'v'.bg_magenta : 'v'
|
724
|
+
label += ': '
|
725
|
+
label + "%s: %s" % [k,v]
|
726
|
+
end
|
727
|
+
|
728
|
+
a << vars.join("\n")
|
729
|
+
end
|
730
|
+
|
731
|
+
a << @triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
|
732
|
+
+ ": %s" % x}.join("\n")
|
733
|
+
a << actions
|
734
|
+
|
735
|
+
|
616
736
|
if @constraints.any? then
|
617
737
|
a << @constraints.map do |x|
|
618
738
|
(colour ? "c".bg_green.gray.bold : 'c') + ": %s" % x
|
619
739
|
end.join("\n")
|
620
740
|
end
|
621
741
|
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
end
|
742
|
+
|
743
|
+
|
744
|
+
|
626
745
|
|
627
746
|
a.join("\n") + "\n"
|
628
747
|
|
@@ -1160,3 +1279,8 @@ class DroidSim
|
|
1160
1279
|
|
1161
1280
|
|
1162
1281
|
end
|
1282
|
+
|
1283
|
+
require 'ruby-macrodroid/base'
|
1284
|
+
require 'ruby-macrodroid/triggers'
|
1285
|
+
require 'ruby-macrodroid/actions'
|
1286
|
+
require 'ruby-macrodroid/constraints'
|
@@ -272,7 +272,10 @@ class TakePictureAction < CameraAction
|
|
272
272
|
|
273
273
|
end
|
274
274
|
|
275
|
-
|
275
|
+
|
276
|
+
# Conditions/Loops
|
277
|
+
#
|
278
|
+
class IfConfirmedThenAction < Action
|
276
279
|
|
277
280
|
def initialize(h={})
|
278
281
|
|
@@ -286,6 +289,92 @@ class IfConditionAction < Action
|
|
286
289
|
|
287
290
|
super(h2)
|
288
291
|
|
292
|
+
@label = 'If Confirmed Then '
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
def to_s(colour: false)
|
297
|
+
|
298
|
+
@s = "If Confirmed Then " #+ @constraints.map(&:to_s).join(" %s " % operator)
|
299
|
+
super(colour: colour)
|
300
|
+
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
# Conditions/Loops
|
305
|
+
#
|
306
|
+
class LoopAction < Action
|
307
|
+
|
308
|
+
def initialize(h={})
|
309
|
+
|
310
|
+
options = {
|
311
|
+
|
312
|
+
}
|
313
|
+
|
314
|
+
h2 = options.merge(h)
|
315
|
+
|
316
|
+
super(h2)
|
317
|
+
|
318
|
+
@label = 'WHILE / DO '
|
319
|
+
|
320
|
+
end
|
321
|
+
|
322
|
+
def to_s(colour: false)
|
323
|
+
|
324
|
+
@s = 'WHILE / DO '
|
325
|
+
super()
|
326
|
+
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
# Conditions/Loops
|
331
|
+
#
|
332
|
+
class EndLoopAction < Action
|
333
|
+
|
334
|
+
def initialize(h={})
|
335
|
+
|
336
|
+
options = {
|
337
|
+
|
338
|
+
}
|
339
|
+
|
340
|
+
h2 = options.merge(h)
|
341
|
+
|
342
|
+
super(h2)
|
343
|
+
|
344
|
+
@label = 'End Loop '
|
345
|
+
|
346
|
+
end
|
347
|
+
|
348
|
+
def to_s(colour: false)
|
349
|
+
|
350
|
+
'End Loop '
|
351
|
+
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
# Conditions/Loops
|
356
|
+
#
|
357
|
+
class IfConditionAction < Action
|
358
|
+
|
359
|
+
def initialize(obj=nil)
|
360
|
+
|
361
|
+
h = if obj.is_a? Hash then
|
362
|
+
obj
|
363
|
+
else
|
364
|
+
# get the constraints
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
options = {
|
369
|
+
a: true,
|
370
|
+
constraint_list: ''
|
371
|
+
}
|
372
|
+
|
373
|
+
macro = h[:macro]
|
374
|
+
h2 = options.merge(filter(options,h).merge(macro: macro))
|
375
|
+
|
376
|
+
super(h2)
|
377
|
+
|
289
378
|
@label = 'If '
|
290
379
|
|
291
380
|
end
|
@@ -317,7 +406,7 @@ class ElseAction < Action
|
|
317
406
|
|
318
407
|
end
|
319
408
|
|
320
|
-
class ElseIfConditionAction <
|
409
|
+
class ElseIfConditionAction < Action
|
321
410
|
|
322
411
|
def initialize(h={})
|
323
412
|
|
@@ -326,9 +415,14 @@ class ElseIfConditionAction < IfConditionAction
|
|
326
415
|
}
|
327
416
|
|
328
417
|
super(options.merge h)
|
329
|
-
@label = '
|
418
|
+
@label = 'Else If '
|
330
419
|
|
331
420
|
end
|
421
|
+
|
422
|
+
def to_s(colour: false)
|
423
|
+
@s = 'Else If '
|
424
|
+
super()
|
425
|
+
end
|
332
426
|
|
333
427
|
|
334
428
|
end
|
@@ -643,7 +737,7 @@ class ClipboardAction < DeviceAction
|
|
643
737
|
end
|
644
738
|
|
645
739
|
def to_s(colour: false)
|
646
|
-
'
|
740
|
+
'Fill Clipboard' + "\n " + @h[:clipboard_text] #+ @h.inspect
|
647
741
|
end
|
648
742
|
|
649
743
|
alias to_summary to_s
|
@@ -793,6 +887,11 @@ end
|
|
793
887
|
#
|
794
888
|
class CameraFlashLightAction < DeviceSettingsAction
|
795
889
|
|
890
|
+
# options
|
891
|
+
# 0 Toch On
|
892
|
+
# 1 Torch Off
|
893
|
+
# 2 Torch Toggle
|
894
|
+
#
|
796
895
|
def initialize(h={})
|
797
896
|
|
798
897
|
options = {
|
@@ -1001,6 +1100,40 @@ class FileAction < Action
|
|
1001
1100
|
|
1002
1101
|
end
|
1003
1102
|
|
1103
|
+
|
1104
|
+
|
1105
|
+
# Category: Files
|
1106
|
+
#
|
1107
|
+
class FileOperationV21Action < FileAction
|
1108
|
+
|
1109
|
+
def initialize(h={})
|
1110
|
+
|
1111
|
+
options = {
|
1112
|
+
:app_name=>"", :class_name=>"", :package_name=>"", :file_path=>"",
|
1113
|
+
:file_extensions=>["jpg", "jpeg", "png", "raw", "bmp", "tif", "tiff",
|
1114
|
+
"gif"], :file_option=>2, :from_name=>"Sent",
|
1115
|
+
:from_uri_string=>"", :option=>2
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
super(options.merge h)
|
1119
|
+
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
def to_s(colour: false)
|
1123
|
+
|
1124
|
+
operation = ['Copy', 'Move', 'Delete', 'Create Folder']
|
1125
|
+
file = ['All Files', 'All Media Files', 'Images', 'Audio', 'Videos', 'Specify File Pattern', 'Folder']
|
1126
|
+
|
1127
|
+
detail = @h[:from_name]
|
1128
|
+
detail += ' to: ' + @h[:to_name] if @h[:option] == 1
|
1129
|
+
@s = "%s %s" % [operation[@h[:option]], file[@h[:file_option]]] \
|
1130
|
+
+ "\n " + detail #+ @h.inspect
|
1131
|
+
super()
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
alias to_summary to_s
|
1135
|
+
end
|
1136
|
+
|
1004
1137
|
# Category: Files
|
1005
1138
|
#
|
1006
1139
|
class OpenFileAction < FileAction
|
@@ -1026,6 +1159,30 @@ class OpenFileAction < FileAction
|
|
1026
1159
|
end
|
1027
1160
|
|
1028
1161
|
|
1162
|
+
# Category: Files
|
1163
|
+
#
|
1164
|
+
class WriteToFileAction < FileAction
|
1165
|
+
|
1166
|
+
def initialize(h={})
|
1167
|
+
|
1168
|
+
options = {
|
1169
|
+
app_name: '',
|
1170
|
+
class_name: '',
|
1171
|
+
package_name: '',
|
1172
|
+
file_path: ''
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
super(options.merge h)
|
1176
|
+
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
def to_s(colour: false)
|
1180
|
+
'Write To File' + "\n " + @h[:filename] #+ @h.inspect
|
1181
|
+
end
|
1182
|
+
|
1183
|
+
alias to_summary to_s
|
1184
|
+
end
|
1185
|
+
|
1029
1186
|
class LocationAction < Action
|
1030
1187
|
|
1031
1188
|
def initialize(h={})
|
@@ -1188,6 +1345,32 @@ class ClearLogAction < LoggingAction
|
|
1188
1345
|
alias to_summary to_s
|
1189
1346
|
end
|
1190
1347
|
|
1348
|
+
# MacroDroid Specific
|
1349
|
+
#
|
1350
|
+
class ConfirmNextAction < Action
|
1351
|
+
|
1352
|
+
def initialize(h={})
|
1353
|
+
|
1354
|
+
options = {
|
1355
|
+
:message=>"Do you want to fill the clipboard? ", :title=>"Fill clipboard? ", :negative_text=>"NO", :positive_text=>"YES", :class_type=>"ConfirmNextAction"
|
1356
|
+
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
super(h)
|
1360
|
+
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
def to_s(colour: false)
|
1364
|
+
|
1365
|
+
@s = 'Confirm Next' + "\n %s: %s" % [@h[:title], @h[:message]]
|
1366
|
+
super()
|
1367
|
+
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
alias to_summary to_s
|
1371
|
+
|
1372
|
+
end
|
1373
|
+
|
1191
1374
|
# MacroDroid Specific
|
1192
1375
|
#
|
1193
1376
|
class ExportMacrosAction < Action
|
@@ -1211,6 +1394,101 @@ class ExportMacrosAction < Action
|
|
1211
1394
|
|
1212
1395
|
end
|
1213
1396
|
|
1397
|
+
|
1398
|
+
# MacroDroid Specific
|
1399
|
+
#
|
1400
|
+
class SetVariableAction < Action
|
1401
|
+
|
1402
|
+
def initialize(h={})
|
1403
|
+
|
1404
|
+
options = {
|
1405
|
+
:user_prompt=>true,
|
1406
|
+
:user_prompt_message=>"Please enter a word to see it reversed",
|
1407
|
+
:user_prompt_show_cancel=>true,
|
1408
|
+
:user_prompt_stop_after_cancel=>true,
|
1409
|
+
:user_prompt_title=>"Word reverse",
|
1410
|
+
:name => 'word'
|
1411
|
+
}
|
1412
|
+
super(h)
|
1413
|
+
|
1414
|
+
end
|
1415
|
+
|
1416
|
+
def to_s(colour: false)
|
1417
|
+
|
1418
|
+
input = if @h[:user_prompt] then
|
1419
|
+
'[User Prompt]'
|
1420
|
+
elsif @h[:expression]
|
1421
|
+
@h[:expression]
|
1422
|
+
elsif @h[:int_value_increment]
|
1423
|
+
'(+1)'
|
1424
|
+
elsif @h[:int_value_decrement]
|
1425
|
+
'(-1)'
|
1426
|
+
elsif @h[:int_random]
|
1427
|
+
"Random %d -> %d" % [@h[:int_random_min], @h[:int_random_max]]
|
1428
|
+
else
|
1429
|
+
|
1430
|
+
=begin
|
1431
|
+
sym = case @h[:variable][:type]
|
1432
|
+
when 0 # boolean
|
1433
|
+
:new_boolean_value
|
1434
|
+
when 1 # integer
|
1435
|
+
:new_int_value
|
1436
|
+
when 2 # string
|
1437
|
+
:new_string_value
|
1438
|
+
when 3 # decimal
|
1439
|
+
:new_double_value
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
@h[sym].to_s
|
1443
|
+
=end
|
1444
|
+
a = %i(new_boolean_value new_int_value new_string_value new_double_value)
|
1445
|
+
@h[a[@h[:variable][:type]]].to_s
|
1446
|
+
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
@s = 'Set Variable' + ("\n %s: " % @h[:variable][:name]) + input #+ @h.inspect
|
1450
|
+
super()
|
1451
|
+
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
alias to_summary to_s
|
1455
|
+
|
1456
|
+
end
|
1457
|
+
|
1458
|
+
|
1459
|
+
|
1460
|
+
# MacroDroid Specific
|
1461
|
+
#
|
1462
|
+
class TextManipulationAction < Action
|
1463
|
+
|
1464
|
+
def initialize(h={})
|
1465
|
+
|
1466
|
+
options = {
|
1467
|
+
|
1468
|
+
}
|
1469
|
+
super(h)
|
1470
|
+
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
def to_s(colour: false)
|
1474
|
+
|
1475
|
+
tm = @h[:text_manipulation]
|
1476
|
+
|
1477
|
+
s = case tm[:type].to_sym
|
1478
|
+
when :SubstringManipulation
|
1479
|
+
"Substring(%s, %s)" % [@h[:text], tm[:params].join(', ')]
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
|
1483
|
+
'Text Manipulation' + "\n " + s #+ ' ' + @h.inspect
|
1484
|
+
|
1485
|
+
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
alias to_summary to_s
|
1489
|
+
|
1490
|
+
end
|
1491
|
+
|
1214
1492
|
class PauseAction < Action
|
1215
1493
|
|
1216
1494
|
def initialize(h={})
|
@@ -1572,7 +1850,13 @@ end
|
|
1572
1850
|
#
|
1573
1851
|
class ToastAction < NotificationsAction
|
1574
1852
|
|
1575
|
-
def initialize(
|
1853
|
+
def initialize(obj)
|
1854
|
+
|
1855
|
+
h = if obj.is_a? Hash then
|
1856
|
+
obj
|
1857
|
+
else
|
1858
|
+
{msg: obj}
|
1859
|
+
end
|
1576
1860
|
|
1577
1861
|
if h[:msg] then
|
1578
1862
|
h[:message_text] = h[:msg]
|
@@ -1603,7 +1887,7 @@ class ToastAction < NotificationsAction
|
|
1603
1887
|
end
|
1604
1888
|
|
1605
1889
|
def to_s(colour: false)
|
1606
|
-
"Popup Message\n %s" % @h[:message_text]
|
1890
|
+
@s = "Popup Message\n %s" % @h[:message_text]
|
1607
1891
|
end
|
1608
1892
|
|
1609
1893
|
end
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -8,58 +8,6 @@
|
|
8
8
|
#
|
9
9
|
|
10
10
|
|
11
|
-
module Params
|
12
|
-
|
13
|
-
refine Hash do
|
14
|
-
|
15
|
-
# turns keys from camelCase into snake_case
|
16
|
-
|
17
|
-
def to_snake_case(h=self)
|
18
|
-
|
19
|
-
h.inject({}) do |r, x|
|
20
|
-
|
21
|
-
key, value = x
|
22
|
-
#puts 'value: ' + value.inspect
|
23
|
-
|
24
|
-
val = if value.is_a?(Hash) then
|
25
|
-
to_snake_case(value)
|
26
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
27
|
-
value.map {|row| to_snake_case(row)}
|
28
|
-
else
|
29
|
-
value
|
30
|
-
end
|
31
|
-
|
32
|
-
r.merge key.to_s.sub(/^m_/,'').gsub(/[A-Z][a-z]/){|x| '_' +
|
33
|
-
x.downcase}.gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
|
34
|
-
.downcase.to_sym => val
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# turns keys from snake_case to CamelCase
|
40
|
-
def to_camel_case(h=self)
|
41
|
-
|
42
|
-
h.inject({}) do |r,x|
|
43
|
-
|
44
|
-
key, value = x
|
45
|
-
|
46
|
-
val = if value.is_a?(Hash) then
|
47
|
-
to_camel_case(value)
|
48
|
-
elsif value.is_a?(Array) and value.first.is_a? Hash
|
49
|
-
value.map {|row| to_camel_case(row)}
|
50
|
-
else
|
51
|
-
value
|
52
|
-
end
|
53
|
-
|
54
|
-
r.merge({key.to_s.gsub(/(?<!^m)_[a-z]/){|x| x[-1].upcase} => val})
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
11
|
|
64
12
|
class MacroObject
|
65
13
|
using ColouredText
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# file: ruby-macrodroid/
|
1
|
+
# file: ruby-macrodroid/triggers.rb
|
2
2
|
|
3
3
|
# This file contains the following classes:
|
4
4
|
#
|
@@ -26,6 +26,8 @@
|
|
26
26
|
#
|
27
27
|
|
28
28
|
|
29
|
+
|
30
|
+
|
29
31
|
class Trigger < MacroObject
|
30
32
|
using Params
|
31
33
|
|
@@ -132,7 +134,9 @@ class ApplicationLaunchedTrigger < Trigger
|
|
132
134
|
end
|
133
135
|
|
134
136
|
def to_s(colour: false)
|
135
|
-
|
137
|
+
a = @h[:application_name_list]
|
138
|
+
apps = a.length > 1 ? "[%s]" % a.join(', ') : a.first
|
139
|
+
'Application Launched' + "\n " + apps
|
136
140
|
end
|
137
141
|
|
138
142
|
alias to_summary to_s
|
@@ -971,6 +975,28 @@ class MusicPlayingTrigger < DeviceEventsTrigger
|
|
971
975
|
end
|
972
976
|
|
973
977
|
|
978
|
+
# Category: Device Events
|
979
|
+
#
|
980
|
+
class NFCTrigger < DeviceEventsTrigger
|
981
|
+
|
982
|
+
def initialize(h={})
|
983
|
+
|
984
|
+
options = {
|
985
|
+
}
|
986
|
+
|
987
|
+
super(options.merge h)
|
988
|
+
|
989
|
+
end
|
990
|
+
|
991
|
+
def to_s(colour: false)
|
992
|
+
'NFC Tag' + "\n " + @h[:tag_name]
|
993
|
+
end
|
994
|
+
|
995
|
+
alias to_summary to_s
|
996
|
+
|
997
|
+
end
|
998
|
+
|
999
|
+
|
974
1000
|
# Category: Device Events
|
975
1001
|
#
|
976
1002
|
class DeviceUnlockedTrigger < DeviceEventsTrigger
|
@@ -1254,6 +1280,28 @@ class SunriseSunsetTrigger < Trigger
|
|
1254
1280
|
end
|
1255
1281
|
|
1256
1282
|
|
1283
|
+
# Category: MacroDroid Specific
|
1284
|
+
#
|
1285
|
+
class EmptyTrigger < Trigger
|
1286
|
+
|
1287
|
+
def initialize(h={})
|
1288
|
+
|
1289
|
+
options = {
|
1290
|
+
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
super(options.merge h)
|
1294
|
+
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
def to_s(colour: false)
|
1298
|
+
'EmptyTrigger'
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
alias to_summary to_s
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
|
1257
1305
|
class SensorsTrigger < Trigger
|
1258
1306
|
|
1259
1307
|
def initialize(h={})
|
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.8.
|
4
|
+
version: 0.8.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-09-
|
38
|
+
date: 2020-09-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|