projectsimulator 0.1.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/projectsimulator.rb +56 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb11152fdb739b57353cb3a2c426465b20ecde48075f0e25bd4a3212c2d47d1b
|
4
|
+
data.tar.gz: 854bf9dd30fcc841211ab8c6a8424e9fc2a0e214755cc8b80951d5c35afd9905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 262fbd34450b87dff84eb25f0d65857e524f8aa16d2ad1e1f1079ce13c35c3793b056f40b974008d67f38cfa38e3ae91c95b2b5df496ae16500d41d4466acd72
|
7
|
+
data.tar.gz: 6c2db15265e494622f67b285ecd509ab656248ac01199a47d8796f41d9226c0e3fe7fa6b4fbae781972f169faa848b0577e1a51e75165422bf7c90c519b491d3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/projectsimulator.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# file: projectsimulator.rb
|
4
4
|
|
5
|
+
|
5
6
|
require 'easydom'
|
6
7
|
require 'app-routes'
|
7
8
|
|
@@ -47,7 +48,7 @@ module ProjectSimulator
|
|
47
48
|
def request(s)
|
48
49
|
|
49
50
|
params = {request: s}
|
50
|
-
requests(
|
51
|
+
requests(params)
|
51
52
|
h = find_request(s)
|
52
53
|
|
53
54
|
method(h.first[-1]).call(h)
|
@@ -99,6 +100,19 @@ module ProjectSimulator
|
|
99
100
|
location = dev_location(device)
|
100
101
|
{type: :get_device, action: 'switch', location: location, device: device}
|
101
102
|
end
|
103
|
+
|
104
|
+
# e.g. fetch the livingroom temperature reading
|
105
|
+
#
|
106
|
+
get /fetch the ([^ ]+) +([^ ]+) +(?:reading)$/ do |location, device|
|
107
|
+
{type: :get_device, action: 'reading', location: location, device: device}
|
108
|
+
end
|
109
|
+
|
110
|
+
# e.g. fetch the temperature reading
|
111
|
+
#
|
112
|
+
get /fetch the ([^ ]+) +(?:reading)$/ do |device|
|
113
|
+
location = dev_location(device)
|
114
|
+
{type: :get_device, action: 'reading', location: location, device: device}
|
115
|
+
end
|
102
116
|
|
103
117
|
end
|
104
118
|
|
@@ -112,4 +126,45 @@ module ProjectSimulator
|
|
112
126
|
alias find_request run_route
|
113
127
|
|
114
128
|
end
|
129
|
+
|
130
|
+
class Controller
|
131
|
+
|
132
|
+
attr_reader :macros
|
133
|
+
attr_accessor :title
|
134
|
+
|
135
|
+
def initialize(mcs, debug: false)
|
136
|
+
|
137
|
+
@debug = debug
|
138
|
+
@syslog = []
|
139
|
+
|
140
|
+
@macros = mcs.macros
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
def trigger(name, detail={time: $env[:time]})
|
146
|
+
|
147
|
+
macros = @macros.select do |macro|
|
148
|
+
|
149
|
+
puts 'macro: ' + macro.inspect if @debug
|
150
|
+
|
151
|
+
valid_trigger = macro.match?(name, detail)
|
152
|
+
|
153
|
+
puts 'valid_trigger: ' + valid_trigger.inspect if @debug
|
154
|
+
|
155
|
+
if valid_trigger then
|
156
|
+
@syslog << [Time.now, :trigger, name]
|
157
|
+
@syslog << [Time.now, :macro, macro.title]
|
158
|
+
end
|
159
|
+
|
160
|
+
valid_trigger
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
puts 'macros: ' + macros.inspect if @debug
|
165
|
+
|
166
|
+
macros.flat_map(&:run)
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
115
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: projectsimulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
2GrtfOXGVOS+2jvmCQC6vU+ew9WBxiDUbebI95TeTwMs2o0cs3IASXX5rIn4TPcz
|
36
36
|
SCccB3fVg2yfsy5DivaWaZwg
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
38
|
+
date: 2020-08-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: easydom
|
metadata.gz.sig
CHANGED
Binary file
|