ruby-macrodroid 0.7.5 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34125d78f367eeff973953934d50436f964bb073ffef48591ce2f09012fc2a01
4
- data.tar.gz: 5bb75988f4d979cb80f57c912d8448837848b3d4a5b34a3e524f8fdad3ff62de
3
+ metadata.gz: eb309319c4f87ebf642930e2a926a18292804c87a877724af262bcc1eecd8589
4
+ data.tar.gz: 697d9e182f7907219c005e5869b88a93d65c01a3bb3a5c1c2a5768d1da0a86cf
5
5
  SHA512:
6
- metadata.gz: 223c51744d7dde5e4a7130d3141696df1dc4a8cda0227e0f11324c3ac71e53226c95e8acd1ae27ed62ec46d8c1c8b81060e9135d923285e59e89572985dd146c
7
- data.tar.gz: 39490d0ceeb2bfce5c413607d1ea5a1ca87e8942bdcbfd51ecf32f2baac1a1c6fec7bf8909eda8716cc6b397ef847d4c15de6eca9892f9d244f1724d4956a1fe
6
+ metadata.gz: 9d24dea588d1ddf7106f73ecc9a3593739df4ac6bd23f74601c33f7c183b929d243bbcb473175bccfb728df734a877aa1025676bd3ea972f024093ca310a4e9f
7
+ data.tar.gz: f7ff237c1a4d962d0579d996b80ce4513f0272430fb4b6cd0f095c24c9260113cfd7cebe117a22bc2c871b48f0c68f881174d2ccbf8f1decc615581dcbd5d5e8
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -112,6 +112,7 @@ require 'rowx'
112
112
  require 'uuid'
113
113
  require 'glw'
114
114
  require 'geozone'
115
+ require 'geocoder'
115
116
  require 'subunit'
116
117
  require 'rxfhelper'
117
118
  require 'chronic_cron'
@@ -748,7 +749,13 @@ EOF
748
749
  puts 'GeofenceTrigger found'.highlight if $debug
749
750
  GeofenceTrigger.new(h, geofences: @geofences)
750
751
  else
751
- klass.new h
752
+ puts 'before klass'
753
+ h2 = h.merge( macro: self)
754
+ puts 'h2: ' + h2.inspect
755
+ r = klass.new h2
756
+
757
+ r
758
+
752
759
  end
753
760
 
754
761
  end
@@ -918,13 +925,23 @@ class MacroDroid
918
925
  name = e.text.to_s.strip
919
926
  item = e.element('item')
920
927
  coordinates = item.text('coordinates')
921
- latitude, longitude = coordinates.split(/, */,2)
922
- radius = item.text('radius')
928
+ location = item.text('location')
929
+
930
+ if not coordinates and location then
931
+ results = Geocoder.search(location)
932
+ coordinates = results[0].coordinates.join(', ') if results.any?
933
+ end
934
+
935
+ if coordinates then
936
+ latitude, longitude = coordinates.split(/, */,2)
937
+ radius = item.text('radius')
938
+ end
923
939
 
924
940
  id = UUID.new.generate
925
941
 
926
942
  h = {
927
943
  name: name,
944
+ location: location,
928
945
  longitude: longitude,
929
946
  latitude: latitude,
930
947
  radius: radius,
@@ -1038,10 +1055,11 @@ class GeofenceMap
1038
1055
 
1039
1056
  attr_accessor :name, :longitude, :latitude, :radius, :id
1040
1057
 
1041
- def initialize(id: '', longitude: '', latitude: '', name: '', radius: '')
1058
+ def initialize(id: '', longitude: '', latitude: '', name: '', radius: '',
1059
+ location: nil)
1042
1060
 
1043
- @id, @latitude, @longitude, @name, @radius = id, latitude, \
1044
- longitude, name, radius
1061
+ @id, @latitude, @longitude, @name, @radius, @location = id, latitude, \
1062
+ longitude, name, radius, location
1045
1063
 
1046
1064
  end
1047
1065
 
@@ -1059,8 +1077,13 @@ class GeofenceMap
1059
1077
 
1060
1078
  def to_s()
1061
1079
 
1062
- coordinates = "%s, %s" % [@longitude, @latitude]
1063
- "%s\n coordinates: %s\n radius: %s" % [@name, coordinates, @radius]
1080
+ lines = []
1081
+ coordinates = "%s, %s" % [@latitude, @longitude]
1082
+ lines << "%s" % @name
1083
+ lines << " location: %s" % @location if @location
1084
+ lines << " coordinates: %s" % coordinates
1085
+ lines << " radius: %s" % @radius
1086
+ lines.join("\n")
1064
1087
 
1065
1088
  end
1066
1089
 
@@ -1069,7 +1092,7 @@ end
1069
1092
  class MacroObject
1070
1093
  using ColouredText
1071
1094
 
1072
- attr_reader :type
1095
+ attr_reader :type, :siguid
1073
1096
  attr_accessor :options
1074
1097
 
1075
1098
  def initialize(h={})
@@ -1105,6 +1128,10 @@ class MacroObject
1105
1128
 
1106
1129
  end
1107
1130
 
1131
+ def siguid()
1132
+ @h[:siguid]
1133
+ end
1134
+
1108
1135
  def to_s()
1109
1136
  "#<%s %s>" % [self.class, @h.inspect]
1110
1137
  end
@@ -1321,6 +1348,24 @@ class ExternalPowerTrigger < Trigger
1321
1348
  super(options.merge h)
1322
1349
 
1323
1350
  end
1351
+
1352
+ def to_s()
1353
+
1354
+ return 'Power Disconnected' unless @h[:power_connected]
1355
+
1356
+ status = 'Power Connectd'
1357
+ options = if @h[:power_connected_options].all? then
1358
+ 'Any'
1359
+ else
1360
+
1361
+ a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)']
1362
+ @h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\
1363
+ .compact.map {|i| a[i] }.join(' + ')
1364
+
1365
+ end
1366
+
1367
+ "%s: %s" % [status, options]
1368
+ end
1324
1369
 
1325
1370
  end
1326
1371
 
@@ -2097,7 +2142,7 @@ class GeofenceTrigger < Trigger
2097
2142
  def initialize( h={}, geofences: {})
2098
2143
 
2099
2144
  if h[:name] then
2100
- puts ('geofences2: ' + geofences.inspect)
2145
+ puts ('geofences2: ' + geofences.inspect) if $debug
2101
2146
  found = geofences.find {|x| x.name.downcase == h[:name].downcase}
2102
2147
  h[:geofence_id] = found.id if found
2103
2148
 
@@ -2409,12 +2454,15 @@ class Action < MacroObject
2409
2454
 
2410
2455
  attr_reader :constraints
2411
2456
 
2412
- def initialize(h={})
2457
+ def initialize(h={})
2458
+
2459
+ macro = h[:macro]
2460
+ h.delete :macro
2413
2461
  super(h)
2414
2462
 
2415
2463
  # fetch the constraints
2416
2464
  @constraints = @h[:constraint_list].map do |constraint|
2417
- object(constraint.to_snake_case)
2465
+ object(constraint.to_snake_case.merge(macro: macro))
2418
2466
  end
2419
2467
  end
2420
2468
 
@@ -2593,22 +2641,23 @@ end
2593
2641
  class IfConditionAction < Action
2594
2642
 
2595
2643
  def initialize(h={})
2596
-
2644
+
2597
2645
  options = {
2598
2646
  a: true,
2599
2647
  constraint_list: ''
2600
2648
  }
2649
+
2650
+ macro = h[:macro]
2651
+ h2 = options.merge(filter(options,h).merge(macro: macro))
2601
2652
 
2602
- super(options.merge h)
2653
+ super(h2)
2603
2654
 
2604
2655
  end
2605
2656
 
2606
2657
  def to_s()
2607
2658
 
2608
2659
  operator = @h[:is_or_condition] ? 'OR' : 'AND'
2609
- r = 'If ' + @constraints.map(&:to_s).join(" %s " % operator)
2610
- puts 'if ... @h ' + @h.inspect
2611
- r
2660
+ 'If ' + @constraints.map(&:to_s).join(" %s " % operator)
2612
2661
 
2613
2662
  end
2614
2663
  end
@@ -2730,7 +2779,7 @@ class SetHotspotAction < ConnectivityAction
2730
2779
 
2731
2780
  def to_s()
2732
2781
  action = @h[:turn_wifi_on] ? 'Enable' : 'Disable'
2733
- action + ' Hotspot'
2782
+ action + ' HotSpot'
2734
2783
  end
2735
2784
  end
2736
2785
 
@@ -3992,7 +4041,11 @@ class SetVolumeAction < VolumeAction
3992
4041
  super(options.merge h)
3993
4042
 
3994
4043
  end
3995
-
4044
+
4045
+ def to_s()
4046
+ volume = @h[:stream_index_array].zip(@h[:stream_volume_array]).to_h[true]
4047
+ 'Volume Change ' + "Notification = %s%%" % volume
4048
+ end
3996
4049
  end
3997
4050
 
3998
4051
  class Constraint < MacroObject
@@ -4620,18 +4673,26 @@ end
4620
4673
  # Category: MacroDroid Specific
4621
4674
  #
4622
4675
  class TriggerThatInvokedConstraint < Constraint
4623
-
4676
+ using ColouredText
4677
+
4624
4678
  def initialize(h={})
4625
4679
 
4680
+ puts ('h: ' + h.inspect).green
4681
+ @trigger = h[:macro].triggers.find {|x| x.siguid == h[:si_guid_that_invoked] }
4682
+
4626
4683
  options = {
4627
4684
  not: false,
4628
4685
  si_guid_that_invoked: -4951291100076165433,
4629
4686
  trigger_name: 'Shake Device'
4630
4687
  }
4631
4688
 
4632
- super(options.merge h)
4689
+ super(options.merge filter(options,h))
4633
4690
 
4634
4691
  end
4692
+
4693
+ def to_s()
4694
+ 'Trigger Fired: ' + @trigger.to_s
4695
+ end
4635
4696
 
4636
4697
  end
4637
4698
 
@@ -4965,3 +5026,130 @@ class ProximitySensorConstraint < Constraint
4965
5026
  end
4966
5027
 
4967
5028
  end
5029
+
5030
+
5031
+ # ----------------------------------------------------------------------------
5032
+
5033
+
5034
+ class DroidSim
5035
+
5036
+ class Service
5037
+ def initialize(callback)
5038
+ @callback = callback
5039
+ end
5040
+ end
5041
+
5042
+ class Application < Service
5043
+
5044
+ def closed()
5045
+ end
5046
+ def launched()
5047
+ end
5048
+ end
5049
+
5050
+ class Battery < Service
5051
+
5052
+ def level()
5053
+ end
5054
+
5055
+ def temperature()
5056
+ end
5057
+
5058
+ end
5059
+ class Bluetooth < Service
5060
+
5061
+ def enable()
5062
+ @callback.on_bluetooth_enabled()
5063
+ end
5064
+
5065
+ #def enabled
5066
+ # @callback.on_bluetooth_enabled()
5067
+ #end
5068
+
5069
+ def enabled?
5070
+ end
5071
+
5072
+ def disabled
5073
+ end
5074
+
5075
+ def disabled?
5076
+ end
5077
+ end
5078
+
5079
+ class Calendar < Service
5080
+ def event(starts, ends)
5081
+ end
5082
+ end
5083
+
5084
+ class DayTime < Service
5085
+
5086
+ def initialie(s)
5087
+ end
5088
+ end
5089
+
5090
+ class Headphones < Service
5091
+ def inserted
5092
+ end
5093
+
5094
+ def removed
5095
+ end
5096
+ end
5097
+
5098
+ class Webhook < Service
5099
+
5100
+ def url()
5101
+ @url
5102
+ end
5103
+
5104
+ def url=(s)
5105
+ @url = s
5106
+ end
5107
+ end
5108
+
5109
+ class Wifi < Service
5110
+ def enabled
5111
+ end
5112
+
5113
+ def disabled
5114
+ end
5115
+
5116
+ def ssid_in_range()
5117
+ end
5118
+
5119
+ def ssid_out_of_range()
5120
+ end
5121
+ end
5122
+
5123
+ class Power < Service
5124
+ def connected()
5125
+ end
5126
+
5127
+ def disconnected()
5128
+ end
5129
+
5130
+ def button_toggle()
5131
+ end
5132
+ end
5133
+
5134
+ class Popup < Service
5135
+ def message(s)
5136
+ puts s
5137
+ end
5138
+ end
5139
+
5140
+
5141
+ attr_reader :bluetooth, :popup
5142
+
5143
+ def initialize()
5144
+
5145
+ @bluetooth = Bluetooth.new self
5146
+ @popup = Popup.new self
5147
+
5148
+ end
5149
+
5150
+ def on_bluetooth_enabled()
5151
+
5152
+ end
5153
+
5154
+
5155
+ 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.5
4
+ version: 0.7.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-09 00:00:00.000000000 Z
38
+ date: 2020-09-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: glw
metadata.gz.sig CHANGED
Binary file