ruby-macrodroid 0.8.4 → 0.8.10

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.
@@ -50,6 +50,19 @@ class Trigger < MacroObject
50
50
  detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
51
51
 
52
52
  end
53
+
54
+ def to_s(colour: false)
55
+
56
+ h = @h.clone
57
+ h.delete :macro
58
+ @s ||= "#<%s %s>" % [self.class, h.inspect]
59
+ operator = @h[:is_or_condition] ? 'OR' : 'AND'
60
+ constraints = @constraints.map \
61
+ {|x| 'c: ' + x.to_summary(colour: colour, indent: 1)}.join(" %s " % operator)
62
+
63
+ @constraints.any? ? @s + "\n" + constraints : @s
64
+
65
+ end
53
66
 
54
67
  end
55
68
 
@@ -134,7 +147,9 @@ class ApplicationLaunchedTrigger < Trigger
134
147
  end
135
148
 
136
149
  def to_s(colour: false)
137
- 'ApplicationLaunchedTrigger ' + @h.inspect
150
+ a = @h[:application_name_list]
151
+ apps = a.length > 1 ? "[%s]" % a.join(', ') : a.first
152
+ 'Application Launched' + "\n " + apps
138
153
  end
139
154
 
140
155
  alias to_summary to_s
@@ -966,10 +981,17 @@ class MusicPlayingTrigger < DeviceEventsTrigger
966
981
  end
967
982
 
968
983
  def to_s(colour: false)
969
- 'MusicPlayingTrigger ' + @h.inspect
984
+
985
+ event = @h[:option] == 0 ? 'Started' : 'Stopped'
986
+ @s = 'Music/Sound Playing' + "\n %s" % event #+ @h.inspect
987
+ super()
988
+
970
989
  end
971
990
 
972
- alias to_summary to_s
991
+ def to_summary(colour: false)
992
+ event = @h[:option] == 0 ? 'Started' : 'Stopped'
993
+ @s = 'Music/Sound Playing' + " (%s)" % event #+ @h.inspect
994
+ end
973
995
  end
974
996
 
975
997
 
@@ -1130,7 +1152,7 @@ class NotificationTrigger < DeviceEventsTrigger
1130
1152
 
1131
1153
  def to_s(colour: false)
1132
1154
  s = (@h[:package_name_list] + @h[:application_name_list]).uniq.join(', ')
1133
- 'Notification Received ' + "\n Any Content (%s)" % s
1155
+ 'Notification Received ' + "\n Any Content (%s)" % s
1134
1156
  end
1135
1157
 
1136
1158
  alias to_summary to_s
@@ -1377,7 +1399,8 @@ class ProximityTrigger < SensorsTrigger
1377
1399
  'Far'
1378
1400
  end
1379
1401
 
1380
- "Proximity Sensor (%s)" % distance
1402
+ @s = "Proximity Sensor (%s)" % distance
1403
+ super()
1381
1404
  end
1382
1405
 
1383
1406
  alias to_summary to_s
@@ -1404,6 +1427,10 @@ class ShakeDeviceTrigger < SensorsTrigger
1404
1427
  def to_s(colour: false)
1405
1428
  'Shake Device'
1406
1429
  end
1430
+
1431
+ def to_summary(colour: false)
1432
+ 'Shake Device'
1433
+ end
1407
1434
 
1408
1435
  end
1409
1436
 
@@ -1602,3 +1629,34 @@ class SwipeTrigger < Trigger
1602
1629
 
1603
1630
  alias to_summary to_s
1604
1631
  end
1632
+
1633
+
1634
+
1635
+
1636
+ # Category: User Input
1637
+ #
1638
+ class WidgetPressedTrigger < Trigger
1639
+
1640
+ def initialize(h={})
1641
+
1642
+ options = {
1643
+ :swipe_start_area=>0, :swipe_motion=>0, :cleared=>true,
1644
+ :image_id=>2130968576, :image_package_name=>"com.android.providers.settings",
1645
+ :image_resource_name=>"com.android.providers.settings", :widget_label=>"",
1646
+ :widget_type=>4
1647
+ }
1648
+
1649
+ super(options.merge h)
1650
+
1651
+ end
1652
+
1653
+ def to_s(colour: false)
1654
+ # 4 == cutom , 0 = green, 1 = blue, 2 = red, 3 = yellow
1655
+ style = %w(Green Blue Red Yellow Custom)[@h[:widget_type]]
1656
+ @s = "Widget Button (%s)" % [style] #+ @h.inspect
1657
+ super()
1658
+ end
1659
+
1660
+ alias to_summary to_s
1661
+ end
1662
+
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.8.4
4
+ version: 0.8.10
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-18 00:00:00.000000000 Z
38
+ date: 2020-09-28 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: glw
@@ -186,6 +186,7 @@ files:
186
186
  - lib/ruby-macrodroid.rb
187
187
  - lib/ruby-macrodroid/actions.rb
188
188
  - lib/ruby-macrodroid/base.rb
189
+ - lib/ruby-macrodroid/macro.rb
189
190
  - lib/ruby-macrodroid/triggers.rb
190
191
  homepage: https://github.com/jrobertson/ruby-macrodroid
191
192
  licenses:
metadata.gz.sig CHANGED
Binary file