ruby-macrodroid 0.7.2 → 0.7.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70dd1172a7d2ad827ff72771851910b140616b3f41fd7843ef65dc5bdf55fd5e
4
- data.tar.gz: d5ef7e748dd16bfbc83e0ca05932a2b7723c61ea2ee2fbc8f69ef1c77c651ef0
3
+ metadata.gz: b2bb7feb730c6e27fa5a975bfdbf07828880549917f2f827444024baab88520d
4
+ data.tar.gz: 1c6e78b40874c2ddc5760d052974998071c581ba5cc3c52dcef58c2d1cd288ce
5
5
  SHA512:
6
- metadata.gz: 91746fa312b8c1c5069c16f5c7337b1f6f438af8afecedc5e6469f21e00f98108788f3248d8d93284d9829858b0bf11ce5ad1591bba4a7f8f4ed1005a71c111c
7
- data.tar.gz: bd1cefc341fd57809b563f1a4f21f013b3fe3e93143cef0c07862bdfe738ca6479e39c86a80355c110bd786da5b63849cc59616c7d67be58750c4ff2c68a47c3
6
+ metadata.gz: f5f66318dc99e82aa73fb6ce5ba11604f290f57d5757cfcdc46664165095b950cebf30da91b4dd9623200f5b615306f40f7815eefb78fe3f7eb65f5567dfd940
7
+ data.tar.gz: '03767919cd1943368facf1c7b66c8ebc6cffeceef99123e9d24957adc6cbedc336fa55468c05b73df691cb8c204d629dfdc085933aaee86370dbecf5f67e6b00'
@@ -1,2 +1,3 @@
1
- <%��_ER���c���{u[e'z���ZK����<��5Oj{�Brv��b���gm
2
- C�9�� ;�X��/�O�{��#�z˕�@�9D89���ʲ)�؋�ӱ��|p� w�g�-h�������d�Q6���Z�f�QP�^,c�co:�+2ɢ0u����L௲w�� !�Ҁ:+|c�Z��T{���Ƀ�IU$�4�7�5�s���g�ub
1
+ &����Ht�>#�x������_��$���� TR���5q�3Rd{�j���8Iz�~���v���9��e1�œ�DT3'�����q���@d�R�Lp�8P���`��G��M�� > ����̮7G^ 0�6���L?����`�r`F����u)
2
+ m���[Zꖻ������F�%���������YS�
3
+ ���@^��t���*�Y�]b��� @��
data.tar.gz.sig CHANGED
Binary file
@@ -110,8 +110,9 @@
110
110
  require 'yaml'
111
111
  require 'rowx'
112
112
  require 'uuid'
113
- #require 'glw'
114
- #require 'geozone'
113
+ require 'glw'
114
+ require 'geozone'
115
+ require 'geocoder'
115
116
  require 'subunit'
116
117
  require 'rxfhelper'
117
118
  require 'chronic_cron'
@@ -135,6 +136,12 @@ class TriggersNlp
135
136
  end
136
137
 
137
138
  def triggers(params)
139
+
140
+ # e.g. at 7:30pm daily
141
+ get /^(?:at )?(\d+:\d+(?:[ap]m)?) daily/i do |time, days|
142
+ [TimerTrigger, {time: time,
143
+ days: %w(Mon Tue Wed Thu Fri Sat Sun).join(', ')}]
144
+ end
138
145
 
139
146
  get /^(?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)/i do |time, days|
140
147
  [TimerTrigger, {time: time, days: days}]
@@ -143,7 +150,7 @@ class TriggersNlp
143
150
  # time.is? 'at 18:30pm on Mon or Tue'
144
151
  get /^time.is\? ['"](?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)['"]/i do |time, days|
145
152
  [TimerTrigger, {time: time, days: days.gsub(' or ',', ')}]
146
- end
153
+ end
147
154
 
148
155
  get /^shake[ _]device\??$/i do
149
156
  [ShakeDeviceTrigger, {}]
@@ -657,20 +664,75 @@ end
657
664
  EOF
658
665
  end
659
666
 
660
- def to_s()
667
+ def to_s(colour: false)
668
+
669
+ indent = 0
670
+ actions = @actions.map do |x|
671
+
672
+ s = x.to_s
673
+
674
+ r = if indent <= 0 then
675
+
676
+ if colour then
677
+ "a".bg_blue.gray.bold + ": %s" % s
678
+ else
679
+ "a: %s" % s
680
+ end
681
+
682
+ elsif indent > 0
683
+
684
+ if s =~ /^Else/ then
685
+ (' ' * (indent-1)) + "%s" % s
686
+ elsif s =~ /^End/
687
+ indent -= 1
688
+ (' ' * indent) + "%s" % s
689
+ else
690
+ (' ' * indent) + "%s" % s
691
+ end
692
+
693
+ end
694
+
695
+ if s =~ /^If/i then
696
+
697
+ if indent < 1 then
698
+
699
+ r = if colour then
700
+ "a".bg_blue.gray.bold + ":\n %s" % s
701
+ else
702
+ "a:\n %s" % s
703
+ end
704
+
705
+ indent += 1
706
+ else
707
+ r = (' ' * indent) + "%s" % s
708
+ end
709
+
710
+ indent += 1
711
+ end
712
+
713
+ r
714
+
715
+ end.join("\n")
661
716
 
662
717
  a = [
663
- 'm: ' + @title,
664
- @triggers.map {|x| "t: %s" % x}.join("\n"),
665
- @actions.map {|x| "a: %s" % x}.join("\n"),
666
- @constraints.map {|x| "a: %s" % x}.join("\n")
718
+ (colour ? "m".bg_cyan.gray.bold : 'm') + ': ' + @title,
719
+ @triggers.map {|x| (colour ? "t".bg_red.gray.bold : 't') \
720
+ + ": %s" % x}.join("\n"),
721
+ actions
667
722
  ]
668
723
 
724
+ if @constraints.any? then
725
+ a << @constraints.map do |x|
726
+ (colour ? "c".bg_green.gray.bold : 'c') + ": %s" % x
727
+ end.join("\n")
728
+ end
729
+
669
730
  if @description and @description.length >= 1 then
670
- a.insert(1, 'd: ' + @description)
731
+ a.insert(1, (colour ? "d".bg_gray.gray.bold : 'd') + ': ' \
732
+ + @description.gsub(/\n/,"\n "))
671
733
  end
672
734
 
673
- a.join("\n")
735
+ a.join("\n") + "\n"
674
736
 
675
737
  end
676
738
 
@@ -704,7 +766,13 @@ EOF
704
766
  puts 'GeofenceTrigger found'.highlight if $debug
705
767
  GeofenceTrigger.new(h, geofences: @geofences)
706
768
  else
707
- klass.new h
769
+ puts 'before klass'
770
+ h2 = h.merge( macro: self)
771
+ puts 'h2: ' + h2.inspect
772
+ r = klass.new h2
773
+
774
+ r
775
+
708
776
  end
709
777
 
710
778
  end
@@ -719,7 +787,7 @@ class MacroDroid
719
787
  using ColouredText
720
788
  using Params
721
789
 
722
- attr_reader :macros, :geofences
790
+ attr_reader :macros, :geofences, :yaml
723
791
 
724
792
  def initialize(obj=nil, debug: false)
725
793
 
@@ -848,15 +916,16 @@ class MacroDroid
848
916
  @macros.map(&:to_pc).join("\n\n")
849
917
  end
850
918
 
851
- def to_s()
919
+ def to_s(colour: false)
852
920
 
853
921
  lines = []
854
922
 
855
923
  if @geofences.any? then
856
- lines << @geofences.map {|_, value| 'g: ' + value.to_s}.join("\n\n") + "\n"
924
+ lines << @geofences.map {|_, value| (colour ? "g".green.bold : 'g') \
925
+ + ': ' + value.to_s}.join("\n\n") + "\n"
857
926
  end
858
927
 
859
- lines << @macros.map(&:to_s).join("\n")
928
+ lines << @macros.map {|x| x.to_s(colour: colour)}.join("\n")
860
929
  lines.join("\n")
861
930
 
862
931
  end
@@ -874,13 +943,23 @@ class MacroDroid
874
943
  name = e.text.to_s.strip
875
944
  item = e.element('item')
876
945
  coordinates = item.text('coordinates')
877
- latitude, longitude = coordinates.split(/, */,2)
878
- radius = item.text('radius')
946
+ location = item.text('location')
947
+
948
+ if not coordinates and location then
949
+ results = Geocoder.search(location)
950
+ coordinates = results[0].coordinates.join(', ') if results.any?
951
+ end
952
+
953
+ if coordinates then
954
+ latitude, longitude = coordinates.split(/, */,2)
955
+ radius = item.text('radius')
956
+ end
879
957
 
880
958
  id = UUID.new.generate
881
959
 
882
960
  h = {
883
961
  name: name,
962
+ location: location,
884
963
  longitude: longitude,
885
964
  latitude: latitude,
886
965
  radius: radius,
@@ -897,6 +976,7 @@ class MacroDroid
897
976
 
898
977
  h = JSON.parse(s, symbolize_names: true)
899
978
  puts 'json_to_yaml: ' + h.to_yaml if @debug
979
+ @yaml = h.to_yaml # helpful for debugging and testing
900
980
 
901
981
  @h = h.to_snake_case
902
982
  puts ('@h: ' + @h.inspect).debug if @debug
@@ -993,10 +1073,11 @@ class GeofenceMap
993
1073
 
994
1074
  attr_accessor :name, :longitude, :latitude, :radius, :id
995
1075
 
996
- def initialize(id: '', longitude: '', latitude: '', name: '', radius: '')
1076
+ def initialize(id: '', longitude: '', latitude: '', name: '', radius: '',
1077
+ location: nil)
997
1078
 
998
- @id, @latitude, @longitude, @name, @radius = id, latitude, \
999
- longitude, name, radius
1079
+ @id, @latitude, @longitude, @name, @radius, @location = id, latitude, \
1080
+ longitude, name, radius, location
1000
1081
 
1001
1082
  end
1002
1083
 
@@ -1014,8 +1095,13 @@ class GeofenceMap
1014
1095
 
1015
1096
  def to_s()
1016
1097
 
1017
- coordinates = "%s, %s" % [@longitude, @latitude]
1018
- "%s\n coordinates: %s\n radius: %s" % [@name, coordinates, @radius]
1098
+ lines = []
1099
+ coordinates = "%s, %s" % [@latitude, @longitude]
1100
+ lines << "%s" % @name
1101
+ lines << " location: %s" % @location if @location
1102
+ lines << " coordinates: %s" % coordinates
1103
+ lines << " radius: %s" % @radius
1104
+ lines.join("\n")
1019
1105
 
1020
1106
  end
1021
1107
 
@@ -1024,7 +1110,7 @@ end
1024
1110
  class MacroObject
1025
1111
  using ColouredText
1026
1112
 
1027
- attr_reader :type
1113
+ attr_reader :type, :siguid
1028
1114
  attr_accessor :options
1029
1115
 
1030
1116
  def initialize(h={})
@@ -1060,6 +1146,10 @@ class MacroObject
1060
1146
 
1061
1147
  end
1062
1148
 
1149
+ def siguid()
1150
+ @h[:siguid]
1151
+ end
1152
+
1063
1153
  def to_s()
1064
1154
  "#<%s %s>" % [self.class, @h.inspect]
1065
1155
  end
@@ -1079,13 +1169,32 @@ class MacroObject
1079
1169
  UUID.new.generate
1080
1170
  end
1081
1171
 
1172
+ def object(h={})
1173
+
1174
+ puts ('inside object h:' + h.inspect).debug if @debug
1175
+ klass = Object.const_get h[:class_type]
1176
+ puts klass.inspect.highlight if $debug
1177
+
1178
+ klass.new h
1179
+
1180
+ end
1181
+
1082
1182
  end
1083
1183
 
1084
1184
  class Trigger < MacroObject
1085
-
1185
+ using Params
1186
+
1187
+ attr_reader :constraints
1188
+
1086
1189
  def initialize(h={})
1087
1190
  super({fakeIcon: 0}.merge(h))
1088
1191
  @list << 'fakeIcon'
1192
+
1193
+ # fetch the constraints
1194
+ @constraints = @h[:constraint_list].map do |constraint|
1195
+ object(constraint.to_snake_case)
1196
+ end
1197
+
1089
1198
  end
1090
1199
 
1091
1200
  def match?(detail={}, model=nil)
@@ -1198,6 +1307,11 @@ class BatteryLevelTrigger < Trigger
1198
1307
  super(options.merge h)
1199
1308
 
1200
1309
  end
1310
+
1311
+ def to_s()
1312
+ operator = @h[:decreases_to] ? '<=' : '>='
1313
+ "Battery %s %s%%" % [operator, @h[:battery_level]]
1314
+ end
1201
1315
 
1202
1316
  end
1203
1317
 
@@ -1252,6 +1366,24 @@ class ExternalPowerTrigger < Trigger
1252
1366
  super(options.merge h)
1253
1367
 
1254
1368
  end
1369
+
1370
+ def to_s()
1371
+
1372
+ return 'Power Disconnected' unless @h[:power_connected]
1373
+
1374
+ status = 'Power Connectd'
1375
+ options = if @h[:power_connected_options].all? then
1376
+ 'Any'
1377
+ else
1378
+
1379
+ a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
1380
+ @h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\
1381
+ .compact.map {|i| a[i] }.join(' + ')
1382
+
1383
+ end
1384
+
1385
+ "%s: %s" % [status, options]
1386
+ end
1255
1387
 
1256
1388
  end
1257
1389
 
@@ -1601,14 +1733,32 @@ class TimerTrigger < Trigger
1601
1733
 
1602
1734
  def to_s()
1603
1735
 
1604
- dow = @h[:days_of_week]
1736
+ dow = @h[:days_of_week]
1605
1737
 
1606
- a = Date::ABBR_DAYNAMES
1607
-
1608
- time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%-H:%M%P")
1609
- days = (a[1..-1] << a.first).zip(dow).select {|_,b| b}.map(&:first)
1738
+ wd = Date::ABBR_DAYNAMES
1739
+ a = (wd[1..-1] << wd.first)
1740
+
1741
+ a2 = dow.map.with_index.to_a
1742
+ start = a2.find {|x,i| x}.last
1743
+ r = a2[start..-1].take_while {|x,i| x == true}
1744
+ r2 = a2[start..-1].select {|x,i| x}
1610
1745
 
1611
- "at %s on %s" % [time, days.join(', ')]
1746
+ days = if r == r2 then
1747
+
1748
+ x1, x2 = a2[start].last, a2[r.length-1].last
1749
+
1750
+ if (x2 - x1) >= 2 then
1751
+ "%s-%s" % [a[x1],a[x2]]
1752
+ else
1753
+ a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
1754
+ end
1755
+ else
1756
+ a.zip(dow).select {|_,b| b}.map(&:first).join(', ')
1757
+ end
1758
+
1759
+ time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%-H:%M%P")
1760
+
1761
+ "%s %s" % [time, days]
1612
1762
  end
1613
1763
 
1614
1764
  private
@@ -1845,6 +1995,10 @@ class DeviceUnlockedTrigger < DeviceEventsTrigger
1845
1995
  super(options.merge h)
1846
1996
 
1847
1997
  end
1998
+
1999
+ def to_s()
2000
+ 'Screen Unlocked'
2001
+ end
1848
2002
 
1849
2003
  end
1850
2004
 
@@ -2006,7 +2160,7 @@ class GeofenceTrigger < Trigger
2006
2160
  def initialize( h={}, geofences: {})
2007
2161
 
2008
2162
  if h[:name] then
2009
- puts ('geofences2: ' + geofences.inspect)
2163
+ puts ('geofences2: ' + geofences.inspect) if $debug
2010
2164
  found = geofences.find {|x| x.name.downcase == h[:name].downcase}
2011
2165
  h[:geofence_id] = found.id if found
2012
2166
 
@@ -2314,9 +2468,20 @@ end
2314
2468
 
2315
2469
 
2316
2470
  class Action < MacroObject
2471
+ using Params
2472
+
2473
+ attr_reader :constraints
2317
2474
 
2318
- def initialize(h={})
2475
+ def initialize(h={})
2476
+
2477
+ macro = h[:macro]
2478
+ h.delete :macro
2319
2479
  super(h)
2480
+
2481
+ # fetch the constraints
2482
+ @constraints = @h[:constraint_list].map do |constraint|
2483
+ object(constraint.to_snake_case.merge(macro: macro))
2484
+ end
2320
2485
  end
2321
2486
 
2322
2487
  def invoke(s='')
@@ -2491,6 +2656,65 @@ class TakePictureAction < CameraAction
2491
2656
 
2492
2657
  end
2493
2658
 
2659
+ class IfConditionAction < Action
2660
+
2661
+ def initialize(h={})
2662
+
2663
+ options = {
2664
+ a: true,
2665
+ constraint_list: ''
2666
+ }
2667
+
2668
+ macro = h[:macro]
2669
+ h2 = options.merge(filter(options,h).merge(macro: macro))
2670
+
2671
+ super(h2)
2672
+
2673
+ end
2674
+
2675
+ def to_s()
2676
+
2677
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
2678
+ 'If ' + @constraints.map(&:to_s).join(" %s " % operator)
2679
+
2680
+ end
2681
+ end
2682
+
2683
+ class ElseAction < Action
2684
+
2685
+ def initialize(h={})
2686
+
2687
+ options = {
2688
+ constraint_list: ''
2689
+ }
2690
+
2691
+ super(options.merge h)
2692
+
2693
+ end
2694
+
2695
+ def to_s()
2696
+ 'Else'
2697
+ end
2698
+
2699
+ end
2700
+
2701
+ class EndIfAction < Action
2702
+
2703
+ def initialize(h={})
2704
+
2705
+ options = {
2706
+ constraint_list: ''
2707
+ }
2708
+
2709
+ super(options.merge h)
2710
+
2711
+ end
2712
+
2713
+ def to_s()
2714
+ 'End If'
2715
+ end
2716
+
2717
+ end
2494
2718
 
2495
2719
  class ConnectivityAction < Action
2496
2720
 
@@ -2558,6 +2782,25 @@ class SetBluetoothAction < ConnectivityAction
2558
2782
 
2559
2783
  end
2560
2784
 
2785
+ class SetHotspotAction < ConnectivityAction
2786
+
2787
+ def initialize(h={})
2788
+
2789
+ options = {
2790
+ device_name: "", state: 0, turn_wifi_on: true, use_legacy_mechanism: false, mechanism: 0
2791
+
2792
+ }
2793
+
2794
+ super(options.merge h)
2795
+
2796
+ end
2797
+
2798
+ def to_s()
2799
+ action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
2800
+ action + ' HotSpot'
2801
+ end
2802
+ end
2803
+
2561
2804
  # Category: Connectivity
2562
2805
  #
2563
2806
  class SendIntentAction < ConnectivityAction
@@ -2863,6 +3106,17 @@ class VibrateAction < DeviceSettingsAction
2863
3106
  super(options.merge h)
2864
3107
 
2865
3108
  end
3109
+
3110
+ def to_s()
3111
+
3112
+ pattern = [
3113
+ 'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
3114
+ 'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
3115
+ 'Mini Blip', 'Micro Blip'
3116
+ ]
3117
+
3118
+ 'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
3119
+ end
2866
3120
 
2867
3121
  end
2868
3122
 
@@ -3143,6 +3397,35 @@ class ClearLogAction < LoggingAction
3143
3397
 
3144
3398
  end
3145
3399
 
3400
+ class PauseAction < Action
3401
+
3402
+ def initialize(h={})
3403
+
3404
+ options = {
3405
+ delay_in_milli_seconds: 0, delay_in_seconds: 1, use_alarm: false
3406
+ }
3407
+ super(h)
3408
+
3409
+ end
3410
+
3411
+ def to_s()
3412
+
3413
+ su = Subunit.new(units={minutes:60, hours:60},
3414
+ seconds: @h[:delay_in_seconds])
3415
+
3416
+ ms = @h[:delay_in_milli_seconds]
3417
+
3418
+ duration = if su.to_h.has_key?(:minutes) or (ms < 1) then
3419
+ su.strfunit("%X")
3420
+ else
3421
+ "%s %s ms" % [su.strfunit("%X"), ms]
3422
+ end
3423
+
3424
+ "Wait " + duration
3425
+ end
3426
+
3427
+ end
3428
+
3146
3429
  class MediaAction < Action
3147
3430
 
3148
3431
  def initialize(h={})
@@ -3805,7 +4088,11 @@ class SetVolumeAction < VolumeAction
3805
4088
  super(options.merge h)
3806
4089
 
3807
4090
  end
3808
-
4091
+
4092
+ def to_s()
4093
+ volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
4094
+ 'Volume Change ' + "Notification = %s%%" % volume
4095
+ end
3809
4096
  end
3810
4097
 
3811
4098
  class Constraint < MacroObject
@@ -3872,6 +4159,21 @@ class BatteryLevelConstraint < Constraint
3872
4159
  super(options.merge h)
3873
4160
 
3874
4161
  end
4162
+
4163
+ def to_s()
4164
+
4165
+ operator = if @h[:greater_than] then
4166
+ '>'
4167
+ elsif @h[:equals]
4168
+ '='
4169
+ else
4170
+ '<'
4171
+ end
4172
+
4173
+ level = @h[:battery_level]
4174
+
4175
+ "Battery %s %s%%" % [operator, level]
4176
+ end
3875
4177
 
3876
4178
  end
3877
4179
 
@@ -3923,6 +4225,11 @@ class ExternalPowerConstraint < Constraint
3923
4225
  super(options.merge h)
3924
4226
 
3925
4227
  end
4228
+
4229
+ def to_s()
4230
+ connection = @h[:external_power] ? 'Connected' : 'Disconnected'
4231
+ 'Power ' + connection
4232
+ end
3926
4233
 
3927
4234
  end
3928
4235
 
@@ -3941,6 +4248,12 @@ class BluetoothConstraint < Constraint
3941
4248
  super(options.merge h)
3942
4249
 
3943
4250
  end
4251
+
4252
+ def to_s()
4253
+ device = @h[:device_name] #== 'Any Device' ? 'Any' : @h[:device_name]
4254
+ "Device Connected (%s)" % device
4255
+ end
4256
+
3944
4257
 
3945
4258
  end
3946
4259
 
@@ -4265,6 +4578,10 @@ class DeviceLockedConstraint < Constraint
4265
4578
  super(options.merge h)
4266
4579
 
4267
4580
  end
4581
+
4582
+ def to_s()
4583
+ 'Device ' + (@h[:locked] ? 'Locked' : 'Unlocked')
4584
+ end
4268
4585
 
4269
4586
  end
4270
4587
 
@@ -4403,18 +4720,26 @@ end
4403
4720
  # Category: MacroDroid Specific
4404
4721
  #
4405
4722
  class TriggerThatInvokedConstraint < Constraint
4406
-
4723
+ using ColouredText
4724
+
4407
4725
  def initialize(h={})
4408
4726
 
4727
+ puts ('h: ' + h.inspect).green
4728
+ @trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
4729
+
4409
4730
  options = {
4410
4731
  not: false,
4411
4732
  si_guid_that_invoked: -4951291100076165433,
4412
4733
  trigger_name: 'Shake Device'
4413
4734
  }
4414
4735
 
4415
- super(options.merge h)
4736
+ super(options.merge filter(options,h))
4416
4737
 
4417
4738
  end
4739
+
4740
+ def to_s()
4741
+ 'Trigger Fired: ' + @trigger.to_s
4742
+ end
4418
4743
 
4419
4744
  end
4420
4745
 
@@ -4451,6 +4776,11 @@ class HeadphonesConnectionConstraint < Constraint
4451
4776
  super(options.merge h)
4452
4777
 
4453
4778
  end
4779
+
4780
+ def to_s()
4781
+ connection = @h[:connected] ? 'Connected' : 'Disconnected'
4782
+ 'Headphones ' + connection
4783
+ end
4454
4784
 
4455
4785
  end
4456
4786
 
@@ -4588,9 +4918,15 @@ class VolumeConstraint < Constraint
4588
4918
  option: 0
4589
4919
  }
4590
4920
 
4591
- super(options.merge h)
4921
+ super(options.merge filter(options, h))
4592
4922
 
4593
4923
  end
4924
+
4925
+ def to_s()
4926
+ a = ['Volume On', 'Vibrate Only' 'Silent', 'Vibrate or Silent']
4927
+
4928
+ "Ringer Volume\n " + a[@h[:option]]
4929
+ end
4594
4930
 
4595
4931
  end
4596
4932
 
@@ -4640,6 +4976,10 @@ class ScreenOnOffConstraint < Constraint
4640
4976
  super(options.merge h)
4641
4977
 
4642
4978
  end
4979
+
4980
+ def to_s()
4981
+ 'Screen ' + (@h[:screen_on] ? 'On' : 'Off')
4982
+ end
4643
4983
 
4644
4984
  end
4645
4985
 
@@ -4693,6 +5033,14 @@ class LightLevelConstraint < Constraint
4693
5033
  super(options.merge h)
4694
5034
 
4695
5035
  end
5036
+
5037
+ def to_s()
5038
+
5039
+ operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'
5040
+ condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
5041
+ 'Light Sensor ' + condition
5042
+
5043
+ end
4696
5044
 
4697
5045
  end
4698
5046
 
@@ -4725,5 +5073,136 @@ class ProximitySensorConstraint < Constraint
4725
5073
  super(options.merge h)
4726
5074
 
4727
5075
  end
5076
+
5077
+ def to_s()
5078
+ 'Proximity Sensor: ' + (@h[:near] ? 'Near' : 'Far')
5079
+ end
5080
+
5081
+ end
5082
+
5083
+
5084
+ # ----------------------------------------------------------------------------
5085
+
5086
+
5087
+ class DroidSim
5088
+
5089
+ class Service
5090
+ def initialize(callback)
5091
+ @callback = callback
5092
+ end
5093
+ end
5094
+
5095
+ class Application < Service
5096
+
5097
+ def closed()
5098
+ end
5099
+ def launched()
5100
+ end
5101
+ end
5102
+
5103
+ class Battery < Service
5104
+
5105
+ def level()
5106
+ end
5107
+
5108
+ def temperature()
5109
+ end
5110
+
5111
+ end
5112
+ class Bluetooth < Service
5113
+
5114
+ def enable()
5115
+ @callback.on_bluetooth_enabled()
5116
+ end
5117
+
5118
+ #def enabled
5119
+ # @callback.on_bluetooth_enabled()
5120
+ #end
5121
+
5122
+ def enabled?
5123
+ end
5124
+
5125
+ def disabled
5126
+ end
5127
+
5128
+ def disabled?
5129
+ end
5130
+ end
5131
+
5132
+ class Calendar < Service
5133
+ def event(starts, ends)
5134
+ end
5135
+ end
5136
+
5137
+ class DayTime < Service
5138
+
5139
+ def initialie(s)
5140
+ end
5141
+ end
5142
+
5143
+ class Headphones < Service
5144
+ def inserted
5145
+ end
5146
+
5147
+ def removed
5148
+ end
5149
+ end
5150
+
5151
+ class Webhook < Service
5152
+
5153
+ def url()
5154
+ @url
5155
+ end
5156
+
5157
+ def url=(s)
5158
+ @url = s
5159
+ end
5160
+ end
5161
+
5162
+ class Wifi < Service
5163
+ def enabled
5164
+ end
5165
+
5166
+ def disabled
5167
+ end
5168
+
5169
+ def ssid_in_range()
5170
+ end
5171
+
5172
+ def ssid_out_of_range()
5173
+ end
5174
+ end
5175
+
5176
+ class Power < Service
5177
+ def connected()
5178
+ end
5179
+
5180
+ def disconnected()
5181
+ end
5182
+
5183
+ def button_toggle()
5184
+ end
5185
+ end
5186
+
5187
+ class Popup < Service
5188
+ def message(s)
5189
+ puts s
5190
+ end
5191
+ end
5192
+
5193
+
5194
+ attr_reader :bluetooth, :popup
5195
+
5196
+ def initialize()
5197
+
5198
+ @bluetooth = Bluetooth.new self
5199
+ @popup = Popup.new self
5200
+
5201
+ end
5202
+
5203
+ def on_bluetooth_enabled()
5204
+
5205
+ end
5206
+
4728
5207
 
4729
5208
  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.2
4
+ version: 0.7.7
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-05 00:00:00.000000000 Z
38
+ date: 2020-09-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: glw
@@ -101,22 +101,22 @@ dependencies:
101
101
  name: subunit
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 0.6.0
107
104
  - - "~>"
108
105
  - !ruby/object:Gem::Version
109
106
  version: '0.6'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 0.6.1
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 0.6.0
117
114
  - - "~>"
118
115
  - !ruby/object:Gem::Version
119
116
  version: '0.6'
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 0.6.1
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: geozone
122
122
  requirement: !ruby/object:Gem::Requirement
@@ -141,22 +141,22 @@ dependencies:
141
141
  name: rxfhelper
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - "~>"
145
- - !ruby/object:Gem::Version
146
- version: '1.0'
147
144
  - - ">="
148
145
  - !ruby/object:Gem::Version
149
- version: 1.0.5
146
+ version: 1.1.0
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.1'
150
150
  type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '1.0'
157
154
  - - ">="
158
155
  - !ruby/object:Gem::Version
159
- version: 1.0.5
156
+ version: 1.1.0
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.1'
160
160
  - !ruby/object:Gem::Dependency
161
161
  name: chronic_cron
162
162
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file