circuitdata 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/circuitdata.rb +115 -48
- data/lib/circuitdata/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 632b6dce93cc547fc056096f00efcc01f79bbab3
|
4
|
+
data.tar.gz: fa0edc6a62b0099464d26f46ccb6b071d459a50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c641c9e7691ffe865cc3e2f7640d9d4d97e4d08094c41f34e6a668b2f10fa64ad745fee64b3e66733fbd4b71ce6e8d0b3b4a601d01f22251ff06bc1c58b55c0f
|
7
|
+
data.tar.gz: 95407595a7864527031ba43e056e5e415e6e52fb6ceed2d86a967a38198fddf37974b60ae6cafadb1885ca566bc7b5045a9894b47681a2170d4bd3ef6b8ceb00
|
data/lib/circuitdata.rb
CHANGED
@@ -23,6 +23,8 @@ module Circuitdata
|
|
23
23
|
returnarray[:errormessage] = "Could not access the file to test"
|
24
24
|
return returnarray
|
25
25
|
end
|
26
|
+
end
|
27
|
+
unless checksfile.is_a? Hash
|
26
28
|
if not checksfile.nil?
|
27
29
|
if not File.exist?(checksfile)
|
28
30
|
returnarray[:error] = true
|
@@ -34,26 +36,23 @@ module Circuitdata
|
|
34
36
|
|
35
37
|
# Validate the original files against the CircuitData schema
|
36
38
|
if validate_origins
|
37
|
-
|
38
|
-
|
39
|
+
$error = false
|
40
|
+
begin
|
41
|
+
prod = JSON::Validator.fully_validate($jsonschema_v1, productfile, :errors_as_objects => true)
|
42
|
+
rescue JSON::Schema::ReadFailed
|
43
|
+
$errors = true
|
39
44
|
returnarray[:error] = true
|
40
|
-
returnarray[:errormessage] = "Could not
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
rescue
|
46
|
-
keep = valerror[:message]
|
47
|
-
end
|
48
|
-
returnarray[:validationserrors][valerror[:fragment]] << keep
|
49
|
-
end
|
45
|
+
returnarray[:errormessage] = "Could not read the schema #{$jsonschema_v1}"
|
46
|
+
rescue JSON::Schema::SchemaError
|
47
|
+
$errors = true
|
48
|
+
returnarray[:error] = true
|
49
|
+
returnarray[:errormessage] = "Something was wrong with the schema #{$jsonschema_v1}"
|
50
50
|
end
|
51
|
-
|
52
|
-
|
53
|
-
if checks.count > 0
|
51
|
+
unless $errors
|
52
|
+
if prod.count > 0
|
54
53
|
returnarray[:error] = true
|
55
|
-
returnarray[:errormessage] = "Could not validate the file
|
56
|
-
|
54
|
+
returnarray[:errormessage] = "Could not validate the product file against the CircuitData json schema"
|
55
|
+
prod.each do |valerror|
|
57
56
|
returnarray[:validationserrors][valerror[:fragment]] = [] unless returnarray[:validationserrors].has_key? valerror[:fragment]
|
58
57
|
begin
|
59
58
|
scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema\\sfile[\\s\\S]*)$").captures
|
@@ -62,7 +61,36 @@ module Circuitdata
|
|
62
61
|
end
|
63
62
|
returnarray[:validationserrors][valerror[:fragment]] << keep
|
64
63
|
end
|
65
|
-
|
64
|
+
end
|
65
|
+
end
|
66
|
+
if not checksfile.nil?
|
67
|
+
$error = false
|
68
|
+
begin
|
69
|
+
checks = JSON::Validator.fully_validate($jsonschema_v1, checksfile, :errors_as_objects => true)
|
70
|
+
rescue JSON::Schema::ReadFailed
|
71
|
+
$errors = true
|
72
|
+
returnarray[:error] = true
|
73
|
+
returnarray[:errormessage] = "Could not read the schema #{$jsonschema_v1}"
|
74
|
+
rescue JSON::Schema::SchemaError
|
75
|
+
$errors = true
|
76
|
+
returnarray[:error] = true
|
77
|
+
returnarray[:errormessage] = "Something was wrong with the schema #{$jsonschema_v1}"
|
78
|
+
end
|
79
|
+
unless $errors
|
80
|
+
if checks.count > 0
|
81
|
+
returnarray[:error] = true
|
82
|
+
returnarray[:errormessage] = "Could not validate the file to check agains (profile or capability) against the CircuitData json schema"
|
83
|
+
checks.each do |valerror|
|
84
|
+
returnarray[:validationserrors][valerror[:fragment]] = [] unless returnarray[:validationserrors].has_key? valerror[:fragment]
|
85
|
+
begin
|
86
|
+
scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema\\sfile[\\s\\S]*)$").captures
|
87
|
+
rescue
|
88
|
+
keep = valerror[:message]
|
89
|
+
end
|
90
|
+
returnarray[:validationserrors][valerror[:fragment]] << keep
|
91
|
+
end
|
92
|
+
return returnarray
|
93
|
+
end
|
66
94
|
end
|
67
95
|
end
|
68
96
|
end
|
@@ -228,18 +256,31 @@ module Circuitdata
|
|
228
256
|
|
229
257
|
# Test enforced
|
230
258
|
if $has_enforced
|
231
|
-
|
232
|
-
|
259
|
+
$error = false
|
260
|
+
begin
|
261
|
+
enforcedvalidate = JSON::Validator.fully_validate(enforcedschema.to_json, productfile, :errors_as_objects => true)
|
262
|
+
rescue JSON::Schema::ReadFailed
|
263
|
+
$errors = true
|
233
264
|
returnarray[:error] = true
|
234
|
-
returnarray[:errormessage] = "
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
265
|
+
returnarray[:errormessage] = "Could not read the schema #{$jsonschema_v1}"
|
266
|
+
rescue JSON::Schema::SchemaError
|
267
|
+
$errors = true
|
268
|
+
returnarray[:error] = true
|
269
|
+
returnarray[:errormessage] = "Something was wrong with the schema #{$jsonschema_v1}"
|
270
|
+
end
|
271
|
+
unless $errors
|
272
|
+
if enforcedvalidate.count > 0
|
273
|
+
returnarray[:error] = true
|
274
|
+
returnarray[:errormessage] = "The product to check did not meet the requirements"
|
275
|
+
enforcedvalidate.each do |valerror|
|
276
|
+
returnarray[:enforcederrors][valerror[:fragment]] = [] unless returnarray[:enforcederrors].has_key? valerror[:fragment]
|
277
|
+
begin
|
278
|
+
scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
|
279
|
+
rescue
|
280
|
+
keep = valerror[:message]
|
281
|
+
end
|
282
|
+
returnarray[:enforcederrors][valerror[:fragment]] << keep
|
241
283
|
end
|
242
|
-
returnarray[:enforcederrors][valerror[:fragment]] << keep
|
243
284
|
end
|
244
285
|
end
|
245
286
|
end
|
@@ -247,36 +288,62 @@ module Circuitdata
|
|
247
288
|
|
248
289
|
# Test restricted
|
249
290
|
if $has_restrictions
|
250
|
-
|
251
|
-
|
291
|
+
$error = false
|
292
|
+
begin
|
293
|
+
restrictedvalidate = JSON::Validator.fully_validate(restrictedschema.to_json, productfile, :errors_as_objects => true)
|
294
|
+
rescue JSON::Schema::ReadFailed
|
295
|
+
$errors = true
|
252
296
|
returnarray[:error] = true
|
253
|
-
returnarray[:errormessage] = "
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
297
|
+
returnarray[:errormessage] = "Could not read the schema #{$jsonschema_v1}"
|
298
|
+
rescue JSON::Schema::SchemaError
|
299
|
+
$errors = true
|
300
|
+
returnarray[:error] = true
|
301
|
+
returnarray[:errormessage] = "Something was wrong with the schema #{$jsonschema_v1}"
|
302
|
+
end
|
303
|
+
unless $errors
|
304
|
+
if restrictedvalidate.count > 0
|
305
|
+
returnarray[:error] = true
|
306
|
+
returnarray[:errormessage] = "The product to check did not meet the requirements"
|
307
|
+
restrictedvalidate.each do |valerror|
|
308
|
+
returnarray[:restrictederrors][valerror[:fragment]] = [] unless returnarray[:restrictederrors].has_key? valerror[:fragment]
|
309
|
+
begin
|
310
|
+
scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
|
311
|
+
rescue
|
312
|
+
keep = valerror[:message]
|
313
|
+
end
|
314
|
+
returnarray[:restrictederrors][valerror[:fragment]] << keep
|
260
315
|
end
|
261
|
-
returnarray[:restrictederrors][valerror[:fragment]] << keep
|
262
316
|
end
|
263
317
|
end
|
264
318
|
end
|
265
319
|
|
266
320
|
# Test capabilites
|
267
321
|
if $has_capabilities
|
268
|
-
|
269
|
-
|
322
|
+
$error = false
|
323
|
+
begin
|
324
|
+
capabilitiesvalidate = JSON::Validator.fully_validate(capabilityschema.to_json, productfile, :errors_as_objects => true)
|
325
|
+
rescue JSON::Schema::ReadFailed
|
326
|
+
$errors = true
|
270
327
|
returnarray[:error] = true
|
271
|
-
returnarray[:errormessage] = "
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
328
|
+
returnarray[:errormessage] = "Could not read the schema #{$jsonschema_v1}"
|
329
|
+
rescue JSON::Schema::SchemaError
|
330
|
+
$errors = true
|
331
|
+
returnarray[:error] = true
|
332
|
+
returnarray[:errormessage] = "Something was wrong with the schema #{$jsonschema_v1}"
|
333
|
+
end
|
334
|
+
unless $errors
|
335
|
+
if capabilitiesvalidate.count > 0
|
336
|
+
returnarray[:error] = true
|
337
|
+
returnarray[:errormessage] = "The product to check did not meet the requirements"
|
338
|
+
capabilitiesvalidate.each do |valerror|
|
339
|
+
returnarray[:capabilitieserrors][valerror[:fragment]] = [] unless returnarray[:capabilitieserrors].has_key? valerror[:fragment]
|
340
|
+
begin
|
341
|
+
scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
|
342
|
+
rescue
|
343
|
+
keep = valerror[:message]
|
344
|
+
end
|
345
|
+
returnarray[:capabilitieserrors][valerror[:fragment]] << keep
|
278
346
|
end
|
279
|
-
returnarray[:capabilitieserrors][valerror[:fragment]] << keep
|
280
347
|
end
|
281
348
|
end
|
282
349
|
end
|
data/lib/circuitdata/version.rb
CHANGED