MrMurano 1.10.3 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/MrMurano/Solution-Services.rb +40 -17
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Solution-ServiceEventHandler_spec.rb +4 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf5ccffebdadc594e4bbee2043d852e75ccf2880
|
4
|
+
data.tar.gz: c4a286c251447baad93cdc7eaa25867968dcd66b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b88a0b7797d4382613e566482a2de65772c592d76d1937c1032ad2beee144b8becfca6444f17a6aaf1f65a41665c9a1c6e7952736479cd8e32eddb2d969072
|
7
|
+
data.tar.gz: eeabfe027720df8f0c3d02deae524382a755e83ac0e8875057ef643efaf1e99acba143e920f260c22185e7030c643fd85fe2db8ea313d2731854ba5e34915465
|
@@ -11,21 +11,12 @@ module MrMurano
|
|
11
11
|
# Things that servers do that is common.
|
12
12
|
class ServiceBase < SolutionBase
|
13
13
|
|
14
|
-
def mkalias(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"/#{$cfg['solution.id']}_#{name[:name]}"
|
21
|
-
elsif name.has_key? :service and name.has_key? :event then
|
22
|
-
"/#{$cfg['solution.id']}_#{name[:service]}_#{name[:event]}"
|
23
|
-
else
|
24
|
-
raise "unknown keys. #{name}"
|
25
|
-
end
|
26
|
-
else
|
27
|
-
raise "unknown type. #{name}"
|
28
|
-
end
|
14
|
+
def mkalias(remote)
|
15
|
+
raise "Needs to be implemented in child"
|
16
|
+
end
|
17
|
+
|
18
|
+
def mkname(remote)
|
19
|
+
raise "Needs to be implemented in child"
|
29
20
|
end
|
30
21
|
|
31
22
|
def list
|
@@ -59,10 +50,11 @@ module MrMurano
|
|
59
50
|
:solution_id => $cfg['solution.id'],
|
60
51
|
:script => script,
|
61
52
|
:alias=>mkalias(remote),
|
62
|
-
:name=>
|
53
|
+
:name=>mkname(remote),
|
63
54
|
})
|
55
|
+
debug "f: #{local} >> #{pst.reject{|k,_| k==:script}.to_json}"
|
64
56
|
# try put, if 404, then post.
|
65
|
-
put(mkalias(remote), pst) do |request, http|
|
57
|
+
put('/'+mkalias(remote), pst) do |request, http|
|
66
58
|
response = http.request(request)
|
67
59
|
case response
|
68
60
|
when Net::HTTPSuccess
|
@@ -163,6 +155,21 @@ module MrMurano
|
|
163
155
|
"#{name}.lua"
|
164
156
|
end
|
165
157
|
|
158
|
+
def mkalias(remote)
|
159
|
+
if remote.has_key? :name then
|
160
|
+
[$cfg['solution.id'], remote[:name]].join('_')
|
161
|
+
else
|
162
|
+
raise "Missing parts! #{remote.to_json}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def mkname(remote)
|
167
|
+
if remote.has_key? :name then
|
168
|
+
remote[:name]
|
169
|
+
else
|
170
|
+
raise "Missing parts! #{remote.to_json}"
|
171
|
+
end
|
172
|
+
end
|
166
173
|
|
167
174
|
def toRemoteItem(from, path)
|
168
175
|
name = path.basename.to_s.sub(/\..*/, '')
|
@@ -184,6 +191,22 @@ module MrMurano
|
|
184
191
|
@location = $cfg['location.eventhandlers']
|
185
192
|
end
|
186
193
|
|
194
|
+
def mkalias(remote)
|
195
|
+
if remote.has_key? :service and remote.has_key? :event then
|
196
|
+
[$cfg['solution.id'], remote[:service], remote[:event]].join('_')
|
197
|
+
else
|
198
|
+
raise "Missing parts! #{remote.to_json}"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def mkname(remote)
|
203
|
+
if remote.has_key? :service and remote.has_key? :event then
|
204
|
+
[remote[:service], remote[:event]].join('_')
|
205
|
+
else
|
206
|
+
raise "Missing parts! #{remote.to_json}"
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
187
210
|
def list
|
188
211
|
ret = get()
|
189
212
|
# eventhandler.skiplist is a list of whitespace seperated dot-paired values.
|
data/lib/MrMurano/version.rb
CHANGED
@@ -102,7 +102,7 @@ end
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "uploads over old version" do
|
105
|
-
stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/
|
105
|
+
stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_data_datapoint").
|
106
106
|
with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
|
107
107
|
'Content-Type'=>'application/json'}).
|
108
108
|
to_return(body: "")
|
@@ -116,8 +116,8 @@ end
|
|
116
116
|
tio.close
|
117
117
|
|
118
118
|
ret = @srv.upload(tio.path, {:id=>"9K0",
|
119
|
-
:
|
120
|
-
:
|
119
|
+
:service=>'data',
|
120
|
+
:event=>'datapoint',
|
121
121
|
:solution_id=>"XYZ",
|
122
122
|
})
|
123
123
|
expect(ret)
|
@@ -125,7 +125,7 @@ end
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it "uploads when nothing is there" do
|
128
|
-
stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/
|
128
|
+
stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_device_datapoint").
|
129
129
|
with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
|
130
130
|
'Content-Type'=>'application/json'}).
|
131
131
|
to_return(status: 404)
|
@@ -143,8 +143,6 @@ end
|
|
143
143
|
tio.close
|
144
144
|
|
145
145
|
ret = @srv.upload(tio.path, {:id=>"9K0",
|
146
|
-
:name=>"debug",
|
147
|
-
:alias=>"XYZ_debug",
|
148
146
|
:solution_id=>"XYZ",
|
149
147
|
:service=>"device",
|
150
148
|
:event=>"datapoint",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MrMurano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|