circuitdata 0.2.7 → 0.2.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c722d677313d0c1212c654764e69496766c3afe3
4
- data.tar.gz: ff759d59645c447bf16a7201a8f2b4ae973850c0
3
+ metadata.gz: 632b6dce93cc547fc056096f00efcc01f79bbab3
4
+ data.tar.gz: fa0edc6a62b0099464d26f46ccb6b071d459a50f
5
5
  SHA512:
6
- metadata.gz: 0aaf62b7010faa06a2dad0972d429d84672e4c72527cdeb6f79ee79b0aa5c0aed6b44ed4e535f3dc6d1fdf940f575a1ffa9642df67e2ba4d6456fdcb24fb7d3a
7
- data.tar.gz: 5c496657b8e001bab99a5b9918b44e4dd95cdc8972fd6f926827ffe2c43473e3df1d7886f7403f5ef4d744353f9e178a81fdf4485bd8d4f3e56ea24e22b066b1
6
+ metadata.gz: c641c9e7691ffe865cc3e2f7640d9d4d97e4d08094c41f34e6a668b2f10fa64ad745fee64b3e66733fbd4b71ce6e8d0b3b4a601d01f22251ff06bc1c58b55c0f
7
+ data.tar.gz: 95407595a7864527031ba43e056e5e415e6e52fb6ceed2d86a967a38198fddf37974b60ae6cafadb1885ca566bc7b5045a9894b47681a2170d4bd3ef6b8ceb00
@@ -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
- prod = JSON::Validator.fully_validate($jsonschema_v1, productfile, :errors_as_objects => true)
38
- if prod.count > 0
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 validate the product file against the CircuitData json schema"
41
- prod.each do |valerror|
42
- returnarray[:validationserrors][valerror[:fragment]] = [] unless returnarray[:validationserrors].has_key? valerror[:fragment]
43
- begin
44
- scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema\\sfile[\\s\\S]*)$").captures
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
- if not checksfile.nil?
52
- checks = JSON::Validator.fully_validate($jsonschema_v1, checksfile, :errors_as_objects => true)
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 to check agains (profile or capability) against the CircuitData json schema"
56
- checks.each do |valerror|
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
- return returnarray
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
- enforcedvalidate = JSON::Validator.fully_validate(enforcedschema.to_json, productfile, :errors_as_objects => true)
232
- if enforcedvalidate.count > 0
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] = "The product to check did not meet the requirements"
235
- enforcedvalidate.each do |valerror|
236
- returnarray[:enforcederrors][valerror[:fragment]] = [] unless returnarray[:enforcederrors].has_key? valerror[:fragment]
237
- begin
238
- scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
239
- rescue
240
- keep = valerror[:message]
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
- restrictedvalidate = JSON::Validator.fully_validate(restrictedschema.to_json, productfile, :errors_as_objects => true)
251
- if restrictedvalidate.count > 0
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] = "The product to check did not meet the requirements"
254
- restrictedvalidate.each do |valerror|
255
- returnarray[:restrictederrors][valerror[:fragment]] = [] unless returnarray[:restrictederrors].has_key? valerror[:fragment]
256
- begin
257
- scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
258
- rescue
259
- keep = valerror[:message]
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
- capabilitiesvalidate = JSON::Validator.fully_validate(capabilityschema.to_json, productfile, :errors_as_objects => true)
269
- if capabilitiesvalidate.count > 0
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] = "The product to check did not meet the requirements"
272
- capabilitiesvalidate.each do |valerror|
273
- returnarray[:capabilitieserrors][valerror[:fragment]] = [] unless returnarray[:capabilitieserrors].has_key? valerror[:fragment]
274
- begin
275
- scrap, keep, scrap2 = valerror[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures
276
- rescue
277
- keep = valerror[:message]
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
@@ -1,3 +1,3 @@
1
1
  module Circuitdata
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuitdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Lydersen