ruby-macrodroid 0.7.1 → 0.7.2

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: a2f43b1d737df8ffc21bb31f9a7df56964963ba3b88a6e51e008c45ca0d4e5f6
4
- data.tar.gz: 6e587a62b683867b37f28dfba70728971e19647cfa803a804ea123c1eb0955b3
3
+ metadata.gz: 70dd1172a7d2ad827ff72771851910b140616b3f41fd7843ef65dc5bdf55fd5e
4
+ data.tar.gz: d5ef7e748dd16bfbc83e0ca05932a2b7723c61ea2ee2fbc8f69ef1c77c651ef0
5
5
  SHA512:
6
- metadata.gz: b247e2d22eac6c837d9bcacf38697b63ab80a41c2affca2adb7389b39423813c9d1816f9c9dd697a013ad75b5417ca2143ca4e040be819a09a67a939765aae2f
7
- data.tar.gz: 1a91db74afbbfbe1622d3e19241c9a99ddd05c0ef975e7ac037102104497d12a191c305a4ceb9ab0f5d7d7d476060398b4648ea927bc3135ab52b5633f562e0f
6
+ metadata.gz: 91746fa312b8c1c5069c16f5c7337b1f6f438af8afecedc5e6469f21e00f98108788f3248d8d93284d9829858b0bf11ce5ad1591bba4a7f8f4ed1005a71c111c
7
+ data.tar.gz: bd1cefc341fd57809b563f1a4f21f013b3fe3e93143cef0c07862bdfe738ca6479e39c86a80355c110bd786da5b63849cc59616c7d67be58750c4ff2c68a47c3
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 'subunit'
115
116
  require 'rxfhelper'
116
117
  require 'chronic_cron'
117
118
 
@@ -177,7 +178,16 @@ class TriggersNlp
177
178
  get /^location (entered|exited) \(([^\)]+)/i do |direction, name|
178
179
  enter_area = direction.downcase.to_sym == :entered
179
180
  [GeofenceTrigger, {name: name, enter_area: enter_area}]
180
- end
181
+ end
182
+
183
+ # eg. Proximity Sensor (Near)
184
+ #
185
+ get /^Proximity Sensor \(([^\)]+)\)/i do |distance|
186
+
187
+ [ProximityTrigger, {distance: distance}]
188
+ end
189
+
190
+
181
191
 
182
192
  end
183
193
 
@@ -269,7 +279,33 @@ class ActionsNlp
269
279
  #
270
280
  get /webhook|HTTP GET/i do
271
281
  [OpenWebPageAction, {}]
272
- end
282
+ end
283
+
284
+ #a: Keep Device Awake Screen On Until Disabled
285
+ #
286
+ get /Keep Device Awake Screen On Until Disabled/i do
287
+ [KeepAwakeAction, {enabled: true, permanent: true, screen_option: 0}]
288
+ end
289
+
290
+
291
+ #a: Keep Device Awake Screen On 1h 1m 1s
292
+ #
293
+ get /Keep Device Awake Screen On ([^$]+)/i do |duration|
294
+
295
+ a = duration.split.map(&:to_i)
296
+ secs = Subunit.new(units={minutes:60, hours:60, seconds: 60}, a).to_i
297
+
298
+ h = {
299
+ permanent: true, screen_option: 0, seconds_to_stay_awake_for: secs
300
+ }
301
+ [KeepAwakeAction, h]
302
+ end
303
+
304
+ #a: Disable Keep Awake
305
+ #
306
+ get /Disable Keep Awake/i do
307
+ [KeepAwakeAction, {enabled: false, screen_option: 0}]
308
+ end
273
309
 
274
310
 
275
311
  end
@@ -642,11 +678,11 @@ EOF
642
678
 
643
679
  a = [
644
680
  'm: ' + @title,
645
- 't: ' + @triggers.map(&:to_s).join(", "),
646
- 'a: ' + @actions.map(&:to_s).join(", "),
681
+ 't: ' + @triggers.map(&:to_summary).join(", "),
682
+ 'a: ' + @actions.map(&:to_summary).join(", "),
647
683
  ]
648
684
 
649
- a << 'c: ' + @constraints.map(&:to_s).join(", ") if @constraints.any?
685
+ a << 'c: ' + @constraints.map(&:to_summary).join(", ") if @constraints.any?
650
686
 
651
687
  a.join("\n") + "\n"
652
688
 
@@ -813,7 +849,16 @@ class MacroDroid
813
849
  end
814
850
 
815
851
  def to_s()
816
- @macros.map(&:to_s).join("\n")
852
+
853
+ lines = []
854
+
855
+ if @geofences.any? then
856
+ lines << @geofences.map {|_, value| 'g: ' + value.to_s}.join("\n\n") + "\n"
857
+ end
858
+
859
+ lines << @macros.map(&:to_s).join("\n")
860
+ lines.join("\n")
861
+
817
862
  end
818
863
 
819
864
  def to_summary()
@@ -964,6 +1009,13 @@ class GeofenceMap
964
1009
  name: @name,
965
1010
  radius: @radius
966
1011
  }
1012
+
1013
+ end
1014
+
1015
+ def to_s()
1016
+
1017
+ coordinates = "%s, %s" % [@longitude, @latitude]
1018
+ "%s\n coordinates: %s\n radius: %s" % [@name, coordinates, @radius]
967
1019
 
968
1020
  end
969
1021
 
@@ -1011,6 +1063,8 @@ class MacroObject
1011
1063
  def to_s()
1012
1064
  "#<%s %s>" % [self.class, @h.inspect]
1013
1065
  end
1066
+
1067
+ alias to_summary to_s
1014
1068
 
1015
1069
  protected
1016
1070
 
@@ -1982,7 +2036,7 @@ class GeofenceTrigger < Trigger
1982
2036
  direction = @h[:enter_area] ? 'Entry' : 'Exit'
1983
2037
 
1984
2038
  found = @geofences.find {|x| x.id == @h[:geofence_id]}
1985
- puts 'found: ' + found.inspect
2039
+ puts 'found: ' + found.inspect if @debug
1986
2040
  label = found ? found.name : 'error: name not found'
1987
2041
 
1988
2042
  "Geofence %s (%s)" % [direction, label]
@@ -2030,8 +2084,28 @@ class ActivityRecognitionTrigger < SensorsTrigger
2030
2084
  }
2031
2085
 
2032
2086
  super(options.merge h)
2087
+
2088
+ @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still']
2033
2089
 
2034
2090
  end
2091
+
2092
+ def to_s()
2093
+ activity = @activity[@h[:selected_index]]
2094
+ 'Activity - ' + activity
2095
+ end
2096
+
2097
+ def to_summary
2098
+
2099
+ activity = @activity[@h[:selected_index]]
2100
+ s = if activity.length > 10 then
2101
+ activity[0..7] + '..'
2102
+ else
2103
+ activity
2104
+ end
2105
+
2106
+ 'Activity - ' + s
2107
+
2108
+ end
2035
2109
 
2036
2110
  end
2037
2111
 
@@ -2041,14 +2115,33 @@ class ProximityTrigger < SensorsTrigger
2041
2115
 
2042
2116
  def initialize(h={})
2043
2117
 
2118
+ if h[:distance] then
2119
+
2120
+ case h[:distance].to_sym
2121
+ when :near
2122
+ options[:near] = true
2123
+ end
2124
+ end
2125
+
2044
2126
  options = {
2045
2127
  near: true,
2046
2128
  selected_option: 0
2047
2129
  }
2048
2130
 
2049
- super(options.merge h)
2131
+ super(options.merge filter(options,h))
2050
2132
 
2051
2133
  end
2134
+
2135
+ def to_s()
2136
+
2137
+ distance = if @h[:near] then
2138
+ 'Near'
2139
+ else
2140
+ 'Far'
2141
+ end
2142
+
2143
+ "Proximity Sensor (%s)" % distance
2144
+ end
2052
2145
 
2053
2146
  end
2054
2147
 
@@ -2652,6 +2745,10 @@ class SpeakTextAction < DeviceAction
2652
2745
  super(options.merge h)
2653
2746
 
2654
2747
  end
2748
+
2749
+ def to_s()
2750
+ "Speak Text (%s)" % @h[:text_to_say]
2751
+ end
2655
2752
 
2656
2753
  end
2657
2754
 
@@ -3553,6 +3650,10 @@ end
3553
3650
 
3554
3651
  # Category: Screen
3555
3652
  #
3653
+ # options:
3654
+ # keep awake, screen on => enabled: true
3655
+ # disable keep awake => enabled: false
3656
+ #
3556
3657
  class KeepAwakeAction < ScreenAction
3557
3658
 
3558
3659
  def initialize(h={})
@@ -3567,7 +3668,30 @@ class KeepAwakeAction < ScreenAction
3567
3668
  super(options.merge h)
3568
3669
 
3569
3670
  end
3570
-
3671
+
3672
+ def to_s()
3673
+
3674
+ screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
3675
+
3676
+ if @h[:enabled] then
3677
+
3678
+ whenx = if @h[:seconds_to_stay_awake_for] == 0 then
3679
+
3680
+ 'Until Disabled'
3681
+
3682
+ else
3683
+ scnds = @h[:seconds_to_stay_awake_for]
3684
+ Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
3685
+ end
3686
+
3687
+ 'Keep Device Awake ' + screen + ' ' + whenx
3688
+
3689
+ else
3690
+ 'Disable Keep Awake'
3691
+ end
3692
+
3693
+
3694
+ end
3571
3695
  end
3572
3696
 
3573
3697
  # Category: Screen
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.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -97,6 +97,26 @@ dependencies:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0.7'
100
+ - !ruby/object:Gem::Dependency
101
+ name: subunit
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.6.0
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.6'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 0.6.0
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '0.6'
100
120
  - !ruby/object:Gem::Dependency
101
121
  name: geozone
102
122
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- !a��,�Y�냽�:�̶CC�q �$|\M�.^�D��`b��菎U�q�#��r�-#��>Ħ�?� �jLֿ��㛆@V���.p���kP��7H��`��/����_i����gD����lP��0��E��@��F�sQ��Llcf��o�g��yT��&��E�����r��zԤj��P;�,큁��_tdByWђ�SG�c���ɷ"��_DR vC٪53�� A��TB�:F��?f{1h%�:��(P���,� �a0U��@� [3VT��DC��u>/!+�#�ʞ�
1
+ �W��V�$�)v_n��`-�N�)`��y�j#�a�ģG���$�odV'���k$j���^(NГWh���>3�n"ڈ$C�T�I:̅oO��I��Y�J����<U٢vc���0p�]>M�����AB��xB�U�� ���k'���{t�@���jj]�� {�JΊVDx0[����)r�j�TV���؁�sawKcl8�u%�,����h�>�/JV1Y1B�>U����=��K8�C�ԙE� �O