MuranoCLI 3.0.2 → 3.0.4

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -59
  3. data/Gemfile +9 -3
  4. data/MuranoCLI.gemspec +11 -4
  5. data/bin/murano +2 -90
  6. data/lib/MrMurano.rb +5 -1
  7. data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
  8. data/lib/MrMurano/Solution.rb +12 -15
  9. data/lib/MrMurano/SolutionId.rb +1 -5
  10. data/lib/MrMurano/SyncAllowed.rb +2 -2
  11. data/lib/MrMurano/SyncUpDown.rb +6 -3
  12. data/lib/MrMurano/progress.rb +11 -2
  13. data/lib/MrMurano/verbosing.rb +3 -2
  14. data/lib/MrMurano/version.rb +2 -2
  15. data/spec/Account-Passwords_spec.rb +34 -48
  16. data/spec/Account_spec.rb +58 -63
  17. data/spec/Business_spec.rb +151 -139
  18. data/spec/ConfigFile_spec.rb +15 -11
  19. data/spec/ConfigMigrate_spec.rb +23 -12
  20. data/spec/Config_spec.rb +57 -54
  21. data/spec/Content_spec.rb +233 -201
  22. data/spec/GatewayBase_spec.rb +35 -27
  23. data/spec/GatewayDevice_spec.rb +149 -149
  24. data/spec/GatewayResource_spec.rb +115 -102
  25. data/spec/GatewaySettings_spec.rb +69 -62
  26. data/spec/Http_spec.rb +66 -56
  27. data/spec/MakePretties_spec.rb +82 -73
  28. data/spec/Mock_spec.rb +38 -29
  29. data/spec/ProjectFile_spec.rb +118 -106
  30. data/spec/Setting_spec.rb +24 -15
  31. data/spec/Solution-ServiceConfig_spec.rb +168 -140
  32. data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
  33. data/spec/Solution-ServiceModules_spec.rb +314 -232
  34. data/spec/Solution-UsersRoles_spec.rb +136 -86
  35. data/spec/Solution_spec.rb +78 -50
  36. data/spec/SyncRoot_spec.rb +26 -24
  37. data/spec/SyncUpDown_spec.rb +268 -249
  38. data/spec/Verbosing_spec.rb +95 -93
  39. data/spec/Webservice-Cors_spec.rb +141 -95
  40. data/spec/Webservice-Endpoint_spec.rb +382 -346
  41. data/spec/Webservice-File_spec.rb +148 -109
  42. data/spec/Webservice-Setting_spec.rb +47 -41
  43. data/spec/cmd_business_spec.rb +17 -17
  44. data/spec/cmd_common.rb +27 -7
  45. data/spec/cmd_config_spec.rb +31 -20
  46. data/spec/cmd_content_spec.rb +80 -68
  47. data/spec/cmd_cors_spec.rb +11 -5
  48. data/spec/cmd_device_spec.rb +16 -14
  49. data/spec/cmd_domain_spec.rb +10 -8
  50. data/spec/cmd_exchange_spec.rb +3 -3
  51. data/spec/cmd_init_spec.rb +100 -101
  52. data/spec/cmd_keystore_spec.rb +17 -12
  53. data/spec/cmd_link_spec.rb +22 -37
  54. data/spec/cmd_password_spec.rb +11 -7
  55. data/spec/cmd_setting_application_spec.rb +47 -33
  56. data/spec/cmd_setting_product_spec.rb +32 -27
  57. data/spec/cmd_status_spec.rb +125 -114
  58. data/spec/cmd_syncdown_spec.rb +70 -65
  59. data/spec/cmd_syncup_spec.rb +19 -15
  60. data/spec/cmd_usage_spec.rb +14 -10
  61. metadata +29 -15
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.22 /coding: utf-8
1
+ # Last Modified: 2017.09.12 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -12,7 +12,7 @@ require 'MrMurano/Solution-Services'
12
12
  require '_workspace'
13
13
 
14
14
  RSpec.describe MrMurano::EventHandler do
15
- include_context "WORKSPACE"
15
+ include_context 'WORKSPACE'
16
16
  before(:example) do
17
17
  $cfg = MrMurano::Config.new
18
18
  $cfg.load
@@ -28,49 +28,49 @@ RSpec.describe MrMurano::EventHandler do
28
28
  # the only different is if it uses application.id or product.id.
29
29
  @srv = MrMurano::EventHandlerSolnApp.new
30
30
  #@srv = MrMurano::EventHandlerSolnPrd.new
31
- allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
31
+ allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
32
32
  end
33
33
 
34
- it "initializes" do
34
+ it 'initializes' do
35
35
  uri = @srv.endpoint('/')
36
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/")
36
+ expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/')
37
37
  end
38
38
 
39
- it "lists" do
39
+ it 'lists' do
40
40
  body = {
41
41
  items: [
42
42
  {
43
- id: "9K0",
44
- name: "debug",
45
- alias: "XYZ_debug",
46
- solution_id: "XYZ",
47
- service: "device",
48
- event: "datapoint",
49
- created_at: "2016-07-07T19:16:19.479Z",
50
- updated_at: "2016-09-12T13:26:55.868Z",
43
+ id: '9K0',
44
+ name: 'debug',
45
+ alias: 'XYZ_debug',
46
+ solution_id: 'XYZ',
47
+ service: 'device',
48
+ event: 'datapoint',
49
+ created_at: '2016-07-07T19:16:19.479Z',
50
+ updated_at: '2016-09-12T13:26:55.868Z',
51
51
  },
52
52
  ],
53
53
  total: 1,
54
54
  }
55
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler").
56
- with(headers: {
57
- 'Authorization'=>'token TTTTTTTTTT',
58
- 'Content-Type'=>'application/json',
59
- }).to_return(body: body.to_json)
55
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler')
56
+ .with(headers: {
57
+ 'Authorization' => 'token TTTTTTTTTT',
58
+ 'Content-Type' => 'application/json',
59
+ }).to_return(body: body.to_json)
60
60
  ret = @srv.list
61
61
  expect(ret).to eq(body[:items])
62
62
  end
63
63
 
64
- it "fetches, with header" do
64
+ it 'fetches, with header' do
65
65
  body = {
66
- id: "9K0",
67
- name: "debug",
68
- alias: "XYZ_debug",
69
- solution_id: "XYZ",
70
- service: "device",
71
- event: "datapoint",
72
- created_at: "2016-07-07T19:16:19.479Z",
73
- updated_at: "2016-09-12T13:26:55.868Z",
66
+ id: '9K0',
67
+ name: 'debug',
68
+ alias: 'XYZ_debug',
69
+ solution_id: 'XYZ',
70
+ service: 'device',
71
+ event: 'datapoint',
72
+ created_at: '2016-07-07T19:16:19.479Z',
73
+ updated_at: '2016-09-12T13:26:55.868Z',
74
74
  script: %{--#EVENT device datapoint
75
75
  -- lua code is here
76
76
  function foo(bar)
@@ -78,25 +78,25 @@ function foo(bar)
78
78
  end
79
79
  },
80
80
  }
81
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0").
82
- with(headers: {
83
- 'Authorization'=>'token TTTTTTTTTT',
84
- 'Content-Type'=>'application/json',
85
- }).to_return(body: body.to_json)
81
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0')
82
+ .with(headers: {
83
+ 'Authorization' => 'token TTTTTTTTTT',
84
+ 'Content-Type' => 'application/json',
85
+ }).to_return(body: body.to_json)
86
86
  ret = @srv.fetch('9K0')
87
87
  expect(ret).to eq(body[:script])
88
88
  end
89
89
 
90
- it "fetches, with header into block" do
90
+ it 'fetches, with header into block' do
91
91
  body = {
92
- id: "9K0",
93
- name: "debug",
94
- alias: "XYZ_debug",
95
- solution_id: "XYZ",
96
- service: "device",
97
- event: "datapoint",
98
- created_at: "2016-07-07T19:16:19.479Z",
99
- updated_at: "2016-09-12T13:26:55.868Z",
92
+ id: '9K0',
93
+ name: 'debug',
94
+ alias: 'XYZ_debug',
95
+ solution_id: 'XYZ',
96
+ service: 'device',
97
+ event: 'datapoint',
98
+ created_at: '2016-07-07T19:16:19.479Z',
99
+ updated_at: '2016-09-12T13:26:55.868Z',
100
100
  script: %{
101
101
  --#EVENT device datapoint
102
102
  -- lua code is here
@@ -105,37 +105,39 @@ end
105
105
  end
106
106
  },
107
107
  }
108
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0").
109
- with(headers: {
110
- 'Authorization'=>'token TTTTTTTTTT',
111
- 'Content-Type'=>'application/json',
112
- }).to_return(body: body.to_json)
108
+ stub_request(
109
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0'
110
+ ).with(headers: {
111
+ 'Authorization' => 'token TTTTTTTTTT',
112
+ 'Content-Type' => 'application/json',
113
+ }).to_return(body: body.to_json)
113
114
  ret = nil
114
115
  @srv.fetch('9K0') { |sc| ret = sc }
115
116
  expect(ret).to eq(body[:script])
116
117
  end
117
118
 
118
- it "fetches, without header" do
119
+ it 'fetches, without header' do
119
120
  body = {
120
- id: "9K0",
121
- name: "debug",
122
- alias: "XYZ_debug",
123
- solution_id: "XYZ",
124
- service: "device",
125
- event: "datapoint",
126
- created_at: "2016-07-07T19:16:19.479Z",
127
- updated_at: "2016-09-12T13:26:55.868Z",
121
+ id: '9K0',
122
+ name: 'debug',
123
+ alias: 'XYZ_debug',
124
+ solution_id: 'XYZ',
125
+ service: 'device',
126
+ event: 'datapoint',
127
+ created_at: '2016-07-07T19:16:19.479Z',
128
+ updated_at: '2016-09-12T13:26:55.868Z',
128
129
  script: %{-- lua code is here
129
130
  function foo(bar)
130
131
  return bar + 1
131
132
  end
132
133
  },
133
134
  }
134
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0").
135
- with(headers: {
136
- 'Authorization'=>'token TTTTTTTTTT',
137
- 'Content-Type'=>'application/json',
138
- }).to_return(body: body.to_json)
135
+ stub_request(
136
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0'
137
+ ).with(headers: {
138
+ 'Authorization' => 'token TTTTTTTTTT',
139
+ 'Content-Type' => 'application/json',
140
+ }).to_return(body: body.to_json)
139
141
 
140
142
  ret = @srv.fetch('9K0')
141
143
  expect(ret).to eq(%{--#EVENT device datapoint
@@ -146,23 +148,25 @@ end
146
148
  })
147
149
  end
148
150
 
149
- it "removes" do
150
- stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0").
151
- with(headers: {
152
- 'Authorization'=>'token TTTTTTTTTT',
153
- 'Content-Type'=>'application/json',
154
- }).to_return(body: "")
151
+ it 'removes' do
152
+ stub_request(
153
+ :delete, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/9K0'
154
+ ).with(headers: {
155
+ 'Authorization' => 'token TTTTTTTTTT',
156
+ 'Content-Type' => 'application/json',
157
+ }).to_return(body: '')
155
158
 
156
159
  ret = @srv.remove('9K0')
157
160
  expect(ret).to eq({})
158
161
  end
159
162
 
160
- it "uploads over old version" do
161
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_data_datapoint").
162
- with(headers: {
163
- 'Authorization'=>'token TTTTTTTTTT',
164
- 'Content-Type'=>'application/json',
165
- }).to_return(body: "")
163
+ it 'uploads over old version' do
164
+ stub_request(
165
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_data_datapoint'
166
+ ).with(headers: {
167
+ 'Authorization' => 'token TTTTTTTTTT',
168
+ 'Content-Type' => 'application/json',
169
+ }).to_return(body: '')
166
170
 
167
171
  Tempfile.open('foo') do |tio|
168
172
  tio << %{
@@ -174,27 +178,28 @@ end
174
178
  tio.close
175
179
 
176
180
  ret = @srv.upload(tio.path,
177
- MrMurano::EventHandler::EventHandlerItem.new(
178
- id: "9K0",
179
- service: 'data',
180
- event: 'datapoint',
181
- solution_id: "XYZ",
182
- ))
181
+ MrMurano::EventHandler::EventHandlerItem.new(
182
+ id: '9K0',
183
+ service: 'data',
184
+ event: 'datapoint',
185
+ solution_id: 'XYZ',
186
+ ))
183
187
  expect(ret)
184
188
  end
185
189
  end
186
190
 
187
- it "uploads when nothing is there" do
188
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_device_datapoint").
189
- with(headers: {
190
- 'Authorization'=>'token TTTTTTTTTT',
191
- 'Content-Type'=>'application/json',
192
- }).to_return(status: 404)
193
- stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/").
194
- with(headers: {
195
- 'Authorization'=>'token TTTTTTTTTT',
196
- 'Content-Type'=>'application/json',
197
- }).to_return(body: "")
191
+ it 'uploads when nothing is there' do
192
+ stub_request(:put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/XYZ_device_datapoint')
193
+ .with(headers: {
194
+ 'Authorization' => 'token TTTTTTTTTT',
195
+ 'Content-Type' => 'application/json',
196
+ }).to_return(status: 404)
197
+
198
+ stub_request(:post, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/')
199
+ .with(headers: {
200
+ 'Authorization' => 'token TTTTTTTTTT',
201
+ 'Content-Type' => 'application/json',
202
+ }).to_return(body: '')
198
203
 
199
204
  Tempfile.open('foo') do |tio|
200
205
  tio << %{
@@ -206,161 +211,154 @@ end
206
211
  tio.close
207
212
 
208
213
  ret = @srv.upload(tio.path,
209
- MrMurano::EventHandler::EventHandlerItem.new(
210
- id: "9K0",
211
- service: 'device',
212
- event: 'datapoint',
213
- solution_id: "XYZ",
214
- ))
214
+ MrMurano::EventHandler::EventHandlerItem.new(
215
+ id: '9K0',
216
+ service: 'device',
217
+ event: 'datapoint',
218
+ solution_id: 'XYZ',
219
+ ))
215
220
  expect(ret)
216
221
  end
217
-
218
222
  end
219
223
 
220
- context "compares" do
224
+ context 'compares' do
221
225
  before(:example) do
222
- @iA = {
223
- id: "9K0",
224
- name: "debug",
225
- alias: "XYZ_debug",
226
- solution_id: "XYZ",
227
- service: "device",
228
- event: "datapoint",
229
- created_at: "2016-07-07T19:16:19.479Z",
230
- updated_at: "2016-09-12T13:26:55.868Z",
226
+ @i_a = {
227
+ id: '9K0',
228
+ name: 'debug',
229
+ alias: 'XYZ_debug',
230
+ solution_id: 'XYZ',
231
+ service: 'device',
232
+ event: 'datapoint',
233
+ created_at: '2016-07-07T19:16:19.479Z',
234
+ updated_at: '2016-09-12T13:26:55.868Z',
231
235
  }
232
- @iB = {
233
- id: "9K0",
234
- name: "debug",
235
- alias: "XYZ_debug",
236
- solution_id: "XYZ",
237
- service: "device",
238
- event: "datapoint",
239
- created_at: "2016-07-07T19:16:19.479Z",
240
- updated_at: "2016-09-12T13:26:55.868Z",
236
+ @i_b = {
237
+ id: '9K0',
238
+ name: 'debug',
239
+ alias: 'XYZ_debug',
240
+ solution_id: 'XYZ',
241
+ service: 'device',
242
+ event: 'datapoint',
243
+ created_at: '2016-07-07T19:16:19.479Z',
244
+ updated_at: '2016-09-12T13:26:55.868Z',
241
245
  }
242
246
  end
243
- it "both have updated_at" do
244
- ret = @srv.docmp(@iA, @iB)
247
+ it 'both have updated_at' do
248
+ ret = @srv.docmp(@i_a, @i_b)
245
249
  expect(ret).to eq(false)
246
250
  end
247
251
 
248
- it "iA is a local file" do
252
+ it 'i_a is a local file' do
249
253
  Tempfile.open('foo') do |tio|
250
- tio << "something"
254
+ tio << 'something'
251
255
  tio.close
252
- iA = @iA.reject { |k, _v| k == :updated_at }.merge({
253
- local_path: Pathname.new(tio.path),
254
- })
255
- ret = @srv.docmp(iA, @iB)
256
+ i_a = @i_a.reject { |k, _v| k == :updated_at }.merge(local_path: Pathname.new(tio.path))
257
+ ret = @srv.docmp(i_a, @i_b)
256
258
  expect(ret).to eq(true)
257
259
 
258
- iB = @iB.merge( { updated_at: Pathname.new(tio.path).mtime.getutc })
259
- ret = @srv.docmp(iA, iB)
260
+ i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
261
+ ret = @srv.docmp(i_a, i_b)
260
262
  expect(ret).to eq(false)
261
263
  end
262
264
  end
263
265
 
264
- it "iB is a local file" do
266
+ it 'i_b is a local file' do
265
267
  Tempfile.open('foo') do |tio|
266
- tio << "something"
268
+ tio << 'something'
267
269
  tio.close
268
- iB = @iB.reject{ |k, _v| k == :updated_at }.merge({
269
- local_path: Pathname.new(tio.path),
270
- })
271
- ret = @srv.docmp(@iA, iB)
270
+ i_b = @i_b.reject { |k, _v| k == :updated_at }.merge(local_path: Pathname.new(tio.path))
271
+ ret = @srv.docmp(@i_a, i_b)
272
272
  expect(ret).to eq(true)
273
273
 
274
- iA = @iA.merge({ updated_at: Pathname.new(tio.path).mtime.getutc })
275
- ret = @srv.docmp(iA, iB)
274
+ i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
275
+ ret = @srv.docmp(i_a, i_b)
276
276
  expect(ret).to eq(false)
277
277
  end
278
278
  end
279
279
  end
280
280
 
281
- context "Lookup functions" do
282
- it "gets local name" do
283
- ret = @srv.tolocalname({ name: "bob" }, nil)
281
+ context 'Lookup functions' do
282
+ it 'gets local name' do
283
+ ret = @srv.tolocalname({ name: 'bob' }, nil)
284
284
  expect(ret).to eq('bob.lua')
285
285
  end
286
286
 
287
- it "gets synckey" do
288
- ret = @srv.synckey({ service: 'device', event: 'datapoint' })
289
- expect(ret).to eq("device_datapoint")
287
+ it 'gets synckey' do
288
+ ret = @srv.synckey(service: 'device', event: 'datapoint')
289
+ expect(ret).to eq('device_datapoint')
290
290
  end
291
291
 
292
- it "gets searchfor" do
293
- $cfg['eventhandler.searchFor'] = %{a b c/**/d/*.bob}
292
+ it 'gets searchfor' do
293
+ $cfg['eventhandler.searchFor'] = %(a b c/**/d/*.bob)
294
294
  ret = @srv.searchFor
295
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
295
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
296
296
  end
297
297
 
298
- it "gets ignoring" do
299
- $cfg['eventhandler.ignoring'] = %{a b c/**/d/*.bob}
298
+ it 'gets ignoring' do
299
+ $cfg['eventhandler.ignoring'] = %(a b c/**/d/*.bob)
300
300
  ret = @srv.ignoring
301
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
301
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
302
302
  end
303
303
 
304
- it "raises on alias without service" do
305
- expect {
304
+ it 'raises on alias without service' do
305
+ expect do
306
306
  @srv.mkname(MrMurano::EventHandler::EventHandlerItem.new(event: 'bob'))
307
- }.to raise_error %{Missing parts! {"event":"bob"}}
307
+ end.to raise_error %(Missing parts! {"event":"bob"})
308
308
  end
309
309
 
310
- it "raises on alias without event" do
311
- expect {
310
+ it 'raises on alias without event' do
311
+ expect do
312
312
  @srv.mkalias(MrMurano::EventHandler::EventHandlerItem.new(service: 'bob'))
313
- }.to raise_error %{Missing parts! {"service":"bob"}}
313
+ end.to raise_error %(Missing parts! {"service":"bob"})
314
314
  end
315
315
 
316
- it "raises on name without service" do
317
- expect {
316
+ it 'raises on name without service' do
317
+ expect do
318
318
  @srv.mkalias(MrMurano::EventHandler::EventHandlerItem.new(event: 'bob'))
319
- }.to raise_error %{Missing parts! {"event":"bob"}}
319
+ end.to raise_error %(Missing parts! {"event":"bob"})
320
320
  end
321
321
 
322
- it "raises on name without event" do
323
- expect {
322
+ it 'raises on name without event' do
323
+ expect do
324
324
  @srv.mkname(MrMurano::EventHandler::EventHandlerItem.new(service: 'bob'))
325
- }.to raise_error %{Missing parts! {"service":"bob"}}
325
+ end.to raise_error %(Missing parts! {"service":"bob"})
326
326
  end
327
327
  end
328
328
 
329
- context "to_remote_item" do
329
+ context 'to_remote_item' do
330
330
  before(:example) do
331
331
  allow(@srv).to receive(:warning)
332
332
  end
333
333
 
334
- it "reads one" do
334
+ it 'reads one' do
335
335
  Tempfile.open('foo') do |tio|
336
- tio << %{--#EVENT device datapoint
336
+ tio << %(--#EVENT device datapoint
337
337
  -- do something.
338
338
  Tsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}
339
- }.gsub(/^\s+/,'')
339
+ ).gsub(/^\s+/, '')
340
340
  tio.close
341
341
 
342
342
  ret = @srv.to_remote_item(nil, tio.path)
343
343
  expect(ret).to eq(
344
- {
345
- service: 'device',
346
- event: 'datapoint',
347
- svc_alias: nil,
348
- type: nil,
349
- line: 0,
350
- line_end: 3,
351
- local_path: Pathname.new(tio.path),
352
- script: %{--#EVENT device datapoint\n-- do something.\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n},
353
- }
344
+ service: 'device',
345
+ event: 'datapoint',
346
+ svc_alias: nil,
347
+ type: nil,
348
+ line: 0,
349
+ line_end: 3,
350
+ local_path: Pathname.new(tio.path),
351
+ script: %(--#EVENT device datapoint\n-- do something.\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n)
354
352
  )
355
353
  end
356
354
  end
357
355
 
358
- it "skips all when no header found" do
356
+ it 'skips all when no header found' do
359
357
  Tempfile.open('foo') do |tio|
360
- tio << %{
358
+ tio << %(
361
359
  -- do something.
362
360
  Tsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}
363
- }.gsub(/^\s+/,'')
361
+ ).gsub(/^\s+/, '')
364
362
  tio.close
365
363
 
366
364
  ret = @srv.to_remote_item(nil, tio.path)
@@ -368,13 +366,13 @@ end
368
366
  end
369
367
  end
370
368
 
371
- it "skips junk at begining" do
369
+ it 'skips junk at begining' do
372
370
  Tempfile.open('foo') do |tio|
373
- tio << %{
371
+ tio << %(
374
372
  -- do something.
375
373
  --#EVENT device datapoint
376
374
  Tsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}
377
- }.gsub(/^\s+/,'')
375
+ ).gsub(/^\s+/, '')
378
376
  tio.close
379
377
 
380
378
  ret = @srv.to_remote_item(nil, tio.path)
@@ -387,14 +385,14 @@ end
387
385
  line: 1,
388
386
  line_end: 3,
389
387
  local_path: Pathname.new(tio.path),
390
- script: %{--#EVENT device datapoint\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n},
391
- ))
388
+ script: %(--#EVENT device datapoint\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n),
389
+ )
390
+ )
392
391
  end
393
392
  end
394
-
395
393
  end
396
394
 
397
- context "Matching" do
395
+ context 'Matching' do
398
396
  before(:example) do
399
397
  @an_item = {
400
398
  service: 'bob',
@@ -402,26 +400,26 @@ end
402
400
  local_path: Pathname.new('a/relative/path.lua'),
403
401
  }
404
402
  end
405
- context "service" do
406
- it "any event" do
403
+ context 'service' do
404
+ it 'any event' do
407
405
  ret = @srv.match(@an_item, '#bob#')
408
406
  expect(ret).to be true
409
407
  ret = @srv.match(@an_item, '#email#')
410
408
  expect(ret).to be false
411
409
  end
412
- it "exact event" do
410
+ it 'exact event' do
413
411
  ret = @srv.match(@an_item, '#bob#built')
414
412
  expect(ret).to be true
415
413
  ret = @srv.match(@an_item, '#email#built')
416
414
  expect(ret).to be false
417
415
  end
418
416
  end
419
- context "any service" do
420
- it "any event" do
417
+ context 'any service' do
418
+ it 'any event' do
421
419
  ret = @srv.match(@an_item, '##')
422
420
  expect(ret).to be true
423
421
  end
424
- it "exact event" do
422
+ it 'exact event' do
425
423
  ret = @srv.match(@an_item, '##built')
426
424
  expect(ret).to be true
427
425
  ret = @srv.match(@an_item, '##sent')