ruby-macrodroid 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d378de53e069fe32854e621ab9b72b08a0785f99957f57cf4933d650287be069
4
- data.tar.gz: 856870eab31f6fffd85f55f1a61315dbec075f9bcbe89b8111e15eca5a064b54
3
+ metadata.gz: 73bd85e05b55cb8139d501f96e7f0692a052d4544dcd518b73e4e1168ffcb0dd
4
+ data.tar.gz: 92d7670d08882e34f16085ca22da3a5affc8aa84c3eb89b3f6ec2800c4172501
5
5
  SHA512:
6
- metadata.gz: 42ec4a29e2a2976767cd62eaa3630388acd4777a07ea72ba95549d2ba0f184d8e8e8fb433385d1610c796c4bcecd9dc613372f702fe9c15e626c0717d26a13ab
7
- data.tar.gz: 7fec30fda5d214a892b703ba5cf9ea3e1c9d0b6a5d7bf72221c6fa286558807d7f629c7fc0f6c0b858161873dc2e1a3323c7598fc3c61788848f72e848cabea8
6
+ metadata.gz: 7361a05b044e4d759728a91d86952f6273a8bfbfc72ff1ac9965f97cd858dd8ad3902cb4cb72f4e0557a291627a631a75d7f4ef0a04481969b8ac91bcd3eb48e
7
+ data.tar.gz: b7ef1815fe2b3e4ff42de13e34c8a663e58a55681aba9e38533c5175ab9a9b197755205175abfe2a013331150bb2f19d4949e41de4f9e3874ea6a4a3981172e2
Binary file
data.tar.gz.sig CHANGED
@@ -1,4 +1 @@
1
- 0���ʙ"�_s9��Ӟ\d�K�}�oA
2
- *��Q���Rr�{
3
- ����zPi���8�W��:�-�!�N�f��,�Mb������Y�yV������ti/s,��y��~b,���rĘ�`qJ�a��5�6� �,i�YWbD���N�{.�J(�%9��4eO��لP'b�m3?�{r�����Ri�Vm_]�� B�i?rl����Ԓ}
4
- ���qi�����hD=x�r[
1
+ ����ժ�+j��h�������m.����wLw;4�C�.g|���9�)���h�!��J�K�|]�������/���X��_p�k�:�h��I�H-�F���$��;B���C';���ʛe��>�%9�ヘ���"tҨ�(��uaOk\��"hfb�+���d೉�\�[+��1K95s�^�q�*e5��Y���]O.eT���,9ɩ&I� g��9�G�p)�m��7?Z^&�?�ڜ+��[J$����Se�`>jnz���!��g�-7� �ϝ�u��P`#��_ɕy���B�D���}6+��[0��ۨЮ�U�b�.�NX���M�69]S���ٗY'L�3������4zL�JH`|S��+���"��Q���rA@��`BG
@@ -38,6 +38,7 @@ require 'rxfhelper'
38
38
  require 'chronic_cron'
39
39
 
40
40
 
41
+ # PASTE_START
41
42
 
42
43
  MODEL =<<EOF
43
44
  device
@@ -145,8 +146,9 @@ class MacroDroid
145
146
  puts 'before RowX.new' if @debug
146
147
 
147
148
  s2 = s.gsub(/^g:/,'geofence:').gsub(/^m:/,'macro:')\
148
- .gsub(/^v:/,'variable:').gsub(/^t:/,'trigger:')\
149
- .gsub(/^a:/,'action:').gsub(/^c:/,'constraint:').gsub(/^#.*/,'')
149
+ .gsub(/^d:/,'description:').gsub(/^v:/,'variable:')\
150
+ .gsub(/^t:/,'trigger:').gsub(/^a:/,'action:')\
151
+ .gsub(/^c:/,'constraint:').gsub(/^#.*/,'')
150
152
 
151
153
  a = s2.split(/(?=^macro:)/)
152
154
 
@@ -577,6 +579,7 @@ class DroidSim
577
579
 
578
580
  end
579
581
 
582
+ # PASTE_END
580
583
 
581
584
  require 'ruby-macrodroid/base'
582
585
  require 'ruby-macrodroid/triggers'
@@ -1066,7 +1066,17 @@ end
1066
1066
  class VibrateAction < DeviceSettingsAction
1067
1067
 
1068
1068
  def initialize(h={})
1069
-
1069
+
1070
+ pattern = [
1071
+ 'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing',
1072
+ 'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
1073
+ 'Mini Blip', 'Micro Blip'
1074
+ ]
1075
+
1076
+ if h[:pattern] then
1077
+ h[:vibrate_pattern] = pattern.map(&:downcase).index h[:pattern]
1078
+ end
1079
+
1070
1080
  options = {
1071
1081
  vibrate_pattern: 1
1072
1082
  }
@@ -2381,8 +2391,46 @@ end
2381
2391
  # disable keep awake => enabled: false
2382
2392
  #
2383
2393
  class KeepAwakeAction < ScreenAction
2394
+ using ColouredText
2384
2395
 
2385
- def initialize(h={})
2396
+ def initialize(obj=nil)
2397
+
2398
+
2399
+ h = if obj.is_a? Hash then
2400
+
2401
+ obj
2402
+
2403
+ elsif obj.is_a? Array
2404
+
2405
+ puts 'obj: ' + obj.inspect if $debug
2406
+ e, macro = obj
2407
+
2408
+ a = e.xpath('item/*')
2409
+
2410
+ txt = e.text('item/description')
2411
+
2412
+ h2 = if txt then
2413
+
2414
+ raw_duration = (txt || e.text).to_s
2415
+ puts 'raw_duration: ' + raw_duration.inspect
2416
+ duration = raw_duration[/Screen On - ([^$]+)/i]
2417
+ {duration: duration}
2418
+
2419
+ elsif a.any? then
2420
+ a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h
2421
+ end
2422
+
2423
+ h2.merge(macro: macro)
2424
+
2425
+ end
2426
+
2427
+ puts ('h: ' + h.inspect).debug #if $debug
2428
+
2429
+ if h[:duration] then
2430
+
2431
+ h[:seconds_to_stay_awake_for] = Subunit.hms_to_seconds(h[:duration])
2432
+
2433
+ end
2386
2434
 
2387
2435
  options = {
2388
2436
  enabled: true,
@@ -192,6 +192,10 @@ class ActionsNlp
192
192
  [SpeakTextAction, {}]
193
193
  end
194
194
 
195
+ get /^Vibrate \(([^\)]+)/i do |pattern|
196
+ [VibrateAction, {pattern: pattern}]
197
+ end
198
+
195
199
  # e.g. Display Notification: Hi there: This is the body of the message
196
200
  get /^Display Notification: ([^:]+): [^$]+$/i do |subject, text|
197
201
  [NotificationAction, {subject: subject, text: text}]
@@ -285,6 +289,10 @@ class ActionsNlp
285
289
  [KeepAwakeAction, h]
286
290
  end
287
291
 
292
+ get /Keep Device Awake$/i do
293
+ [KeepAwakeAction, params]
294
+ end
295
+
288
296
  #a: Disable Keep Awake
289
297
  #
290
298
  get /Disable Keep Awake/i do
@@ -326,10 +334,44 @@ class ConstraintsNlp
326
334
  end
327
335
 
328
336
  def constraints(params)
337
+
338
+ # Device State
339
+
340
+ get /^Device (locked|unlocked)/i do |state|
341
+ [DeviceLockedConstraint, {locked: state.downcase == 'locked'}]
342
+ end
329
343
 
330
344
  get /^airplane mode (.*)/i do |state|
331
345
  [AirplaneModeConstraint, {enabled: (state =~ /^enabled|on$/i) == 0}]
332
346
  end
347
+
348
+ #
349
+
350
+ # -- Sensors -----------------------------------
351
+ #
352
+ get /^Light Sensor (Less|Greater) than (50.0)lx/i do |operator, val|
353
+
354
+ level, option = operator.downcase == 'less' ? [-1,0] : [1,1]
355
+
356
+ h = {
357
+ light_level: level,
358
+ light_level_float: val,
359
+ option: option
360
+ }
361
+
362
+ [LightLevelConstraint, h]
363
+ end
364
+
365
+ get /^Proximity Sensor: (Near|Far)/i do |distance|
366
+ [ProximitySensorConstraint, {near: distance.downcase == 'near'}]
367
+ end
368
+
369
+
370
+ # -- Screen and Speaker ---------------------------
371
+ #
372
+ get /^Screen (On|Off)/i do |state|
373
+ [ScreenOnOffConstraint, {screen_on: state.downcase == 'on'}]
374
+ end
333
375
 
334
376
  end
335
377
 
@@ -523,6 +565,21 @@ class Macro
523
565
 
524
566
  @title = node.text('macro') || node.attributes[:name]
525
567
 
568
+ d = node.element('description')
569
+
570
+ if d then
571
+
572
+ desc = []
573
+ desc << d.text.strip
574
+
575
+ if d.element('item/description') then
576
+ desc << d.text('item/description').strip
577
+ end
578
+
579
+ @description = desc.join("\n")
580
+
581
+ end
582
+
526
583
  node.xpath('variable').each {|e| set_var(*e.text.to_s.split(/: */,2)) }
527
584
 
528
585
  #@description = node.attributes[:description]
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.9.2
4
+ version: 0.9.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-10-05 00:00:00.000000000 Z
38
+ date: 2020-10-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: glw
metadata.gz.sig CHANGED
Binary file