ruby-macrodroid 0.7.2 → 0.7.3
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 +203 -6
- 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: cd79e55449071a3fd0ed864f58fc606dedd69059413876c7466cb071f651fef4
|
4
|
+
data.tar.gz: 70dbc1fd844ff449d0ef1ca680e9b47e5233ff82148ab93063b65d9a87e5f70c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1912e55be98c1236a2df6f17e5e19aa1de75e89854ca3be343821133e841656bb45c116e195237a313726b590c31bb7c898f8cf54f868f37c26f3dd9b11f4694
|
7
|
+
data.tar.gz: fdc3adcb802125e4346bbed8fc089e57a303d2f5624e20fe6b597b03a594ae50ca388b13c54bcb43da3bfb265e6fabc1b46f00119a48f199645ee5d8bdcf0c24
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Q�-�N��R�3@��[L]��}�p�֔!DSpIQ���ϤuV9���]\�h�����
|
2
|
+
+ŷ����n#,���M���{���O'!<��SQp����R�R$�im�ra���O�$���C[��G>�{�0��/�4Q�c��#����~OLI9�Ǽ�H����k�N�j2��m�F����Tn��w��z�4<���6{�#�u\6g[x,�8���G\�)K%�ۤWşO9%��$�N`�\���A��*r萳��h�����mp�m��j��j��O-8��� >�G�Fa����x+`TG��/j�&�I+gB�ڵ`�N��<:������bIr�#�:�<�2y4Gc-�(L���(�x��~��4
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ruby-macrodroid.rb
CHANGED
@@ -113,7 +113,10 @@ require 'uuid'
|
|
113
113
|
#require 'glw'
|
114
114
|
#require 'geozone'
|
115
115
|
require 'subunit'
|
116
|
-
require 'rxfhelper'
|
116
|
+
#require 'rxfhelper'
|
117
|
+
require 'requestor'
|
118
|
+
eval Requestor.read('http://a0.jamesrobertson.eu/rorb/r/ruby'){|x| x.require 'rxfhelper' }
|
119
|
+
|
117
120
|
require 'chronic_cron'
|
118
121
|
|
119
122
|
|
@@ -659,18 +662,55 @@ EOF
|
|
659
662
|
|
660
663
|
def to_s()
|
661
664
|
|
665
|
+
indent = 0
|
666
|
+
actions = @actions.map do |x|
|
667
|
+
|
668
|
+
s = x.to_s
|
669
|
+
|
670
|
+
r = if indent <= 0 then
|
671
|
+
|
672
|
+
"a: %s" % s
|
673
|
+
|
674
|
+
elsif indent > 0
|
675
|
+
|
676
|
+
if s =~ /^Else/ then
|
677
|
+
(' ' * (indent-1)) + "%s" % s
|
678
|
+
elsif s =~ /^End/
|
679
|
+
indent -= 1
|
680
|
+
(' ' * indent) + "%s" % s
|
681
|
+
else
|
682
|
+
(' ' * indent) + "%s" % s
|
683
|
+
end
|
684
|
+
|
685
|
+
end
|
686
|
+
|
687
|
+
if s =~ /^If/i then
|
688
|
+
if indent < 1 then
|
689
|
+
r = "a:\n %s" % s
|
690
|
+
indent += 1
|
691
|
+
else
|
692
|
+
r = (' ' * indent) + "%s" % s
|
693
|
+
end
|
694
|
+
|
695
|
+
indent += 1
|
696
|
+
end
|
697
|
+
|
698
|
+
r
|
699
|
+
|
700
|
+
end.join("\n")
|
701
|
+
|
662
702
|
a = [
|
663
703
|
'm: ' + @title,
|
664
704
|
@triggers.map {|x| "t: %s" % x}.join("\n"),
|
665
|
-
|
705
|
+
actions,
|
666
706
|
@constraints.map {|x| "a: %s" % x}.join("\n")
|
667
707
|
]
|
668
708
|
|
669
709
|
if @description and @description.length >= 1 then
|
670
|
-
a.insert(1, 'd: ' + @description)
|
710
|
+
a.insert(1, 'd: ' + @description.gsub(/\n/,"\n "))
|
671
711
|
end
|
672
712
|
|
673
|
-
a.join("\n")
|
713
|
+
a.join("\n") + "\n"
|
674
714
|
|
675
715
|
end
|
676
716
|
|
@@ -719,7 +759,7 @@ class MacroDroid
|
|
719
759
|
using ColouredText
|
720
760
|
using Params
|
721
761
|
|
722
|
-
attr_reader :macros, :geofences
|
762
|
+
attr_reader :macros, :geofences, :yaml
|
723
763
|
|
724
764
|
def initialize(obj=nil, debug: false)
|
725
765
|
|
@@ -897,6 +937,7 @@ class MacroDroid
|
|
897
937
|
|
898
938
|
h = JSON.parse(s, symbolize_names: true)
|
899
939
|
puts 'json_to_yaml: ' + h.to_yaml if @debug
|
940
|
+
@yaml = h.to_yaml # helpful for debugging and testing
|
900
941
|
|
901
942
|
@h = h.to_snake_case
|
902
943
|
puts ('@h: ' + @h.inspect).debug if @debug
|
@@ -1079,13 +1120,32 @@ class MacroObject
|
|
1079
1120
|
UUID.new.generate
|
1080
1121
|
end
|
1081
1122
|
|
1123
|
+
def object(h={})
|
1124
|
+
|
1125
|
+
puts ('inside object h:' + h.inspect).debug if @debug
|
1126
|
+
klass = Object.const_get h[:class_type]
|
1127
|
+
puts klass.inspect.highlight if $debug
|
1128
|
+
|
1129
|
+
klass.new h
|
1130
|
+
|
1131
|
+
end
|
1132
|
+
|
1082
1133
|
end
|
1083
1134
|
|
1084
1135
|
class Trigger < MacroObject
|
1085
|
-
|
1136
|
+
using Params
|
1137
|
+
|
1138
|
+
attr_reader :constraints
|
1139
|
+
|
1086
1140
|
def initialize(h={})
|
1087
1141
|
super({fakeIcon: 0}.merge(h))
|
1088
1142
|
@list << 'fakeIcon'
|
1143
|
+
|
1144
|
+
# fetch the constraints
|
1145
|
+
@constraints = h[:constraint_list].map do |constraint|
|
1146
|
+
object(constraint.to_snake_case)
|
1147
|
+
end
|
1148
|
+
|
1089
1149
|
end
|
1090
1150
|
|
1091
1151
|
def match?(detail={}, model=nil)
|
@@ -1198,6 +1258,11 @@ class BatteryLevelTrigger < Trigger
|
|
1198
1258
|
super(options.merge h)
|
1199
1259
|
|
1200
1260
|
end
|
1261
|
+
|
1262
|
+
def to_s()
|
1263
|
+
operator = @h[:decreases_to] ? '<=' : '>='
|
1264
|
+
"Battery %s %s%%" % [operator, @h[:battery_level]]
|
1265
|
+
end
|
1201
1266
|
|
1202
1267
|
end
|
1203
1268
|
|
@@ -1845,6 +1910,10 @@ class DeviceUnlockedTrigger < DeviceEventsTrigger
|
|
1845
1910
|
super(options.merge h)
|
1846
1911
|
|
1847
1912
|
end
|
1913
|
+
|
1914
|
+
def to_s()
|
1915
|
+
'Screen Unlocked'
|
1916
|
+
end
|
1848
1917
|
|
1849
1918
|
end
|
1850
1919
|
|
@@ -2314,9 +2383,17 @@ end
|
|
2314
2383
|
|
2315
2384
|
|
2316
2385
|
class Action < MacroObject
|
2386
|
+
using Params
|
2387
|
+
|
2388
|
+
attr_reader :constraints
|
2317
2389
|
|
2318
2390
|
def initialize(h={})
|
2319
2391
|
super(h)
|
2392
|
+
|
2393
|
+
# fetch the constraints
|
2394
|
+
@constraints = h[:constraint_list].map do |constraint|
|
2395
|
+
object(constraint.to_snake_case)
|
2396
|
+
end
|
2320
2397
|
end
|
2321
2398
|
|
2322
2399
|
def invoke(s='')
|
@@ -2491,6 +2568,64 @@ class TakePictureAction < CameraAction
|
|
2491
2568
|
|
2492
2569
|
end
|
2493
2570
|
|
2571
|
+
class IfConditionAction < Action
|
2572
|
+
|
2573
|
+
def initialize(h={})
|
2574
|
+
|
2575
|
+
options = {
|
2576
|
+
a: true,
|
2577
|
+
constraint_list: ''
|
2578
|
+
}
|
2579
|
+
|
2580
|
+
super(options.merge h)
|
2581
|
+
|
2582
|
+
end
|
2583
|
+
|
2584
|
+
def to_s()
|
2585
|
+
|
2586
|
+
operator = @h[:is_or_condition] ? 'OR' : 'AND'
|
2587
|
+
r = 'If ' + @constraints.map(&:to_s).join(" %s " % operator)
|
2588
|
+
puts 'if ... @h ' + @h.inspect
|
2589
|
+
r
|
2590
|
+
|
2591
|
+
end
|
2592
|
+
end
|
2593
|
+
|
2594
|
+
class ElseAction < Action
|
2595
|
+
|
2596
|
+
def initialize(h={})
|
2597
|
+
|
2598
|
+
options = {
|
2599
|
+
constraint_list: ''
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
super(options.merge h)
|
2603
|
+
|
2604
|
+
end
|
2605
|
+
|
2606
|
+
def to_s()
|
2607
|
+
'Else'
|
2608
|
+
end
|
2609
|
+
|
2610
|
+
end
|
2611
|
+
|
2612
|
+
class EndIfAction < Action
|
2613
|
+
|
2614
|
+
def initialize(h={})
|
2615
|
+
|
2616
|
+
options = {
|
2617
|
+
constraint_list: ''
|
2618
|
+
}
|
2619
|
+
|
2620
|
+
super(options.merge h)
|
2621
|
+
|
2622
|
+
end
|
2623
|
+
|
2624
|
+
def to_s()
|
2625
|
+
'End If'
|
2626
|
+
end
|
2627
|
+
|
2628
|
+
end
|
2494
2629
|
|
2495
2630
|
class ConnectivityAction < Action
|
2496
2631
|
|
@@ -2863,6 +2998,17 @@ class VibrateAction < DeviceSettingsAction
|
|
2863
2998
|
super(options.merge h)
|
2864
2999
|
|
2865
3000
|
end
|
3001
|
+
|
3002
|
+
def to_s()
|
3003
|
+
|
3004
|
+
pattern = [
|
3005
|
+
'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
|
3006
|
+
'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
|
3007
|
+
'Mini Blip', 'Micro Blip'
|
3008
|
+
]
|
3009
|
+
|
3010
|
+
'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
|
3011
|
+
end
|
2866
3012
|
|
2867
3013
|
end
|
2868
3014
|
|
@@ -3872,6 +4018,21 @@ class BatteryLevelConstraint < Constraint
|
|
3872
4018
|
super(options.merge h)
|
3873
4019
|
|
3874
4020
|
end
|
4021
|
+
|
4022
|
+
def to_s()
|
4023
|
+
|
4024
|
+
operator = if @h[:greater_than] then
|
4025
|
+
'>'
|
4026
|
+
elsif @h[:equals]
|
4027
|
+
'='
|
4028
|
+
else
|
4029
|
+
'<'
|
4030
|
+
end
|
4031
|
+
|
4032
|
+
level = @h[:battery_level]
|
4033
|
+
|
4034
|
+
"Battery %s %s%%" % [operator, level]
|
4035
|
+
end
|
3875
4036
|
|
3876
4037
|
end
|
3877
4038
|
|
@@ -3923,6 +4084,11 @@ class ExternalPowerConstraint < Constraint
|
|
3923
4084
|
super(options.merge h)
|
3924
4085
|
|
3925
4086
|
end
|
4087
|
+
|
4088
|
+
def to_s()
|
4089
|
+
connection = @h[:external_power] ? 'Connected' : 'Disconnected'
|
4090
|
+
'Power ' + connection
|
4091
|
+
end
|
3926
4092
|
|
3927
4093
|
end
|
3928
4094
|
|
@@ -3941,6 +4107,12 @@ class BluetoothConstraint < Constraint
|
|
3941
4107
|
super(options.merge h)
|
3942
4108
|
|
3943
4109
|
end
|
4110
|
+
|
4111
|
+
def to_s()
|
4112
|
+
device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
|
4113
|
+
"Device Connected (%s)" % device
|
4114
|
+
end
|
4115
|
+
|
3944
4116
|
|
3945
4117
|
end
|
3946
4118
|
|
@@ -4265,6 +4437,10 @@ class DeviceLockedConstraint < Constraint
|
|
4265
4437
|
super(options.merge h)
|
4266
4438
|
|
4267
4439
|
end
|
4440
|
+
|
4441
|
+
def to_s()
|
4442
|
+
'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
|
4443
|
+
end
|
4268
4444
|
|
4269
4445
|
end
|
4270
4446
|
|
@@ -4451,6 +4627,11 @@ class HeadphonesConnectionConstraint < Constraint
|
|
4451
4627
|
super(options.merge h)
|
4452
4628
|
|
4453
4629
|
end
|
4630
|
+
|
4631
|
+
def to_s()
|
4632
|
+
connection = @h[:connected] ? 'Connected' : 'Disconnected'
|
4633
|
+
'Headphones ' + connection
|
4634
|
+
end
|
4454
4635
|
|
4455
4636
|
end
|
4456
4637
|
|
@@ -4640,6 +4821,10 @@ class ScreenOnOffConstraint < Constraint
|
|
4640
4821
|
super(options.merge h)
|
4641
4822
|
|
4642
4823
|
end
|
4824
|
+
|
4825
|
+
def to_s()
|
4826
|
+
'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
|
4827
|
+
end
|
4643
4828
|
|
4644
4829
|
end
|
4645
4830
|
|
@@ -4693,6 +4878,14 @@ class LightLevelConstraint < Constraint
|
|
4693
4878
|
super(options.merge h)
|
4694
4879
|
|
4695
4880
|
end
|
4881
|
+
|
4882
|
+
def to_s()
|
4883
|
+
|
4884
|
+
operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
|
4885
|
+
condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
|
4886
|
+
'Light Sensor ' + condition
|
4887
|
+
|
4888
|
+
end
|
4696
4889
|
|
4697
4890
|
end
|
4698
4891
|
|
@@ -4725,5 +4918,9 @@ class ProximitySensorConstraint < Constraint
|
|
4725
4918
|
super(options.merge h)
|
4726
4919
|
|
4727
4920
|
end
|
4921
|
+
|
4922
|
+
def to_s()
|
4923
|
+
'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
|
4924
|
+
end
|
4728
4925
|
|
4729
4926
|
end
|
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.7.
|
4
|
+
version: 0.7.3
|
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-07 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|