ruby-macrodroid 0.9.0 → 0.9.5

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.
@@ -421,27 +421,33 @@ class WebHookTrigger < Trigger
421
421
  h = if obj.is_a? Hash then
422
422
  obj
423
423
  elsif obj.is_a? Array
424
+
424
425
  e, macro = obj
425
426
  txt = e.text('item/description')
426
- {url: (txt || e.text), macro: macro}
427
+
428
+ h2 = if txt then
429
+ {url: (txt || e.text)}
430
+ else
431
+ a = e.xpath('item/*')
432
+ a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h
433
+ end
434
+
435
+ h2.merge(macro: macro)
427
436
  end
428
437
 
429
438
  if h[:url] then
430
- h[:identifier] = h[:url][/https:\/\/trigger.macrodroid.com\/(?:\w+\-){4}\w+\/([^$]+)/,1]
439
+ h[:identifier] = h[:url]\
440
+ [/https:\/\/trigger.macrodroid.com\/(?:\w+\-){4}\w+\/([^$]+)/,1]
441
+ elsif h[:identifier].nil? or h[:identifier].empty? then
442
+ h[:identifier] = h[:macro].title.downcase.gsub(/ +/,'-')
431
443
  end
432
444
 
433
-
434
445
  options = {
435
446
  identifier: ''
436
447
  }
437
448
 
438
449
  @deviceid = h[:macro].deviceid
439
-
440
-
441
- if h[:identifier].nil? or h[:identifier].empty? then
442
- h[:identifier] = h[:macro].title.downcase.gsub(/ +/,'-')
443
- end
444
-
450
+
445
451
  super(options.merge filter(options,h))
446
452
  @list << 'identifier'
447
453
 
@@ -1393,8 +1399,21 @@ end
1393
1399
  #
1394
1400
  class ProximityTrigger < SensorsTrigger
1395
1401
 
1396
- def initialize(h={})
1402
+ def initialize(obj=nil)
1397
1403
 
1404
+ h = if obj.is_a? Hash then
1405
+ obj
1406
+ elsif obj.is_a? Array
1407
+ e, macro = obj
1408
+ txt = e.text('item/description')
1409
+ {option: (txt || e.text), macro: macro}
1410
+ end
1411
+
1412
+ options = {
1413
+ near: true,
1414
+ selected_option: 0
1415
+ }
1416
+
1398
1417
  if h[:distance] then
1399
1418
 
1400
1419
  case h[:distance].to_sym
@@ -1403,15 +1422,14 @@ class ProximityTrigger < SensorsTrigger
1403
1422
  end
1404
1423
  end
1405
1424
 
1406
- options = {
1407
- near: true,
1408
- selected_option: 0
1409
- }
1410
-
1411
1425
  super(options.merge h)
1412
1426
 
1413
1427
  end
1414
1428
 
1429
+ def match?(detail={}, model=nil)
1430
+ @h[:selected_option] == detail[:option].to_i
1431
+ end
1432
+
1415
1433
  def to_s(colour: false)
1416
1434
 
1417
1435
  distance = if @h[:near] then
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.0
4
+ version: 0.9.5
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-02 00:00:00.000000000 Z
38
+ date: 2020-10-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