adiwg-json_schemas 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3efe57bb1de467638869ac6d30ffb62f9bb5b00
4
- data.tar.gz: 5aaaad63299cf3eabf4242b8ea870b287363cab2
3
+ metadata.gz: e02358e3428ecb2d56fbf91c17ac0e4f0053d077
4
+ data.tar.gz: aab6f7ed078b693d53abc174ddbc05526965197d
5
5
  SHA512:
6
- metadata.gz: 5496880df10514786f6efa6e6b56d67f4cfafd9c11e2615e2453731f1cd96dddcb6b405e91f0e1de239523ef76719220c74f1fd1f9f79837abd8b22044d12530
7
- data.tar.gz: b24ab50266b9bcfe064f62eff5f0e66791d49e664eedb07ea706016000bf15f4aa2ca3e38e6e3264ca2ca456212cd39436428342f0b4a2d698ba57990f53d245
6
+ metadata.gz: e39803ab5f10610c376eebfea86fb302b89e5d61434c70614504a48c5e56da520bb135271dd611c140563098506b376fe9d9177a6c86b09494db99f0b3b23855
7
+ data.tar.gz: c6a3ed9fa8c54299a9c8d40db1c151e24e480d506caa17044dab95b564536f32f13463439aa7a8c33e7a45073dd8ceb7ce4e72a4901410fbd6bd860dc8a0ea40
data/.travis.yml CHANGED
@@ -3,6 +3,5 @@ rvm:
3
3
  - 2.1.0
4
4
  - 2.0.0
5
5
  - 1.9.3
6
- - jruby-18mode
7
6
  - jruby-19mode
8
7
  - ruby-head
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "json-schema"
23
+ spec.add_development_dependency "json-schema", "~> 2.2"
24
24
  spec.add_development_dependency "test-unit"
25
25
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version":{
3
3
  "name":"adiwgJSON",
4
- "version":"0.7.0"
4
+ "version":"0.8.0"
5
5
  },
6
6
  "contact":[
7
7
  {
@@ -341,8 +341,45 @@
341
341
  ],
342
342
  "metadata":{
343
343
  "metadataInfo":{
344
- "metadataIdentifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
345
- "parentMetadataIdentifier":"D5D16D06-TFDE-lE01-9427-000C548U45JA",
344
+ "metadataIdentifier":{
345
+ "identifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
346
+ "type":"uuid"
347
+ },
348
+ "parentMetadata":{
349
+ "title":"Changing Arctic Ecosystems Initiative (CAE)",
350
+ "date":[
351
+ {
352
+ "date":"2011-09-14",
353
+ "dateType":"publication"
354
+ }
355
+ ],
356
+ "identifier":[
357
+ {
358
+ "identifier":"D5B16D06-CFEB-E011-8260-000C2952247E",
359
+ "type":"uuid"
360
+ },
361
+ {
362
+ "identifier":"ALCC2018-99",
363
+ "type":"project"
364
+ }
365
+ ],
366
+ "responsibleParty":[
367
+ {
368
+ "contactId":"1",
369
+ "role":"pointOfContact"
370
+ }
371
+ ],
372
+ "presentationForm":[
373
+ "documentDigital"
374
+ ],
375
+ "onlineResource":[
376
+ {
377
+ "uri":"http://alaska.usgs.gov/rex/adiwg/public/projects/316?format=xml",
378
+ "protocol":"http",
379
+ "description":"Project metadata record for CAE"
380
+ }
381
+ ]
382
+ },
346
383
  "metadataScope":[
347
384
  "dataset",
348
385
  "project"
@@ -341,8 +341,45 @@
341
341
  ],
342
342
  "metadata":{
343
343
  "metadataInfo":{
344
- "metadataIdentifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
345
- "parentMetadataIdentifier":"D5D16D06-TFDE-lE01-9427-000C548U45JA",
344
+ "metadataIdentifier":{
345
+ "identifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
346
+ "type":"uuid"
347
+ },
348
+ "parentMetadata":{
349
+ "title":"Changing Arctic Ecosystems Initiative (CAE)",
350
+ "date":[
351
+ {
352
+ "date":"2011-09-14",
353
+ "dateType":"publication"
354
+ }
355
+ ],
356
+ "identifier":[
357
+ {
358
+ "identifier":"D5B16D06-CFEB-E011-8260-000C2952247E",
359
+ "type":"uuid"
360
+ },
361
+ {
362
+ "identifier":"ALCC2018-99",
363
+ "type":"project"
364
+ }
365
+ ],
366
+ "responsibleParty":[
367
+ {
368
+ "contactId":"1",
369
+ "role":"pointOfContact"
370
+ }
371
+ ],
372
+ "presentationForm":[
373
+ "documentDigital"
374
+ ],
375
+ "onlineResource":[
376
+ {
377
+ "uri":"http://alaska.usgs.gov/rex/adiwg/public/projects/316?format=xml",
378
+ "protocol":"http",
379
+ "description":"Project metadata record for CAE"
380
+ }
381
+ ]
382
+ },
346
383
  "metadataScope":[
347
384
  "dataset",
348
385
  "project"
@@ -412,6 +449,13 @@
412
449
  "identifier":"10/1256.0011",
413
450
  "type":"doi"
414
451
  },
452
+ {
453
+ "identifier":"id with nil type",
454
+ "type":""
455
+ },
456
+ {
457
+ "identifier":"id with missing type"
458
+ },
415
459
  {
416
460
  "identifier":"978-1490564098",
417
461
  "type":"isbn"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version":{
3
3
  "name":"adiwgJSON",
4
- "version":"0.7.0"
4
+ "version":"0.8.0"
5
5
  },
6
6
  "contact":[
7
7
  {
@@ -92,7 +92,10 @@
92
92
  ],
93
93
  "metadata":{
94
94
  "metadataInfo":{
95
- "metadataIdentifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
95
+ "metadataIdentifier":{
96
+ "identifier":"D5D16D06-CEEB-E011-8260-000C2952247E",
97
+ "type":"uuid"
98
+ },
96
99
  "metadataScope":[
97
100
  "project"
98
101
  ],
@@ -0,0 +1,42 @@
1
+ =begin
2
+ * Description: Patches json-schema gem to work on windows
3
+ * Author: Josh Bradley
4
+ * Date: 2014-09-17
5
+ * License: Public Domain
6
+ =end
7
+
8
+ module JSON
9
+
10
+ class Validator
11
+
12
+ def load_ref_schema(parent_schema,ref)
13
+ uri = URI.parse(ref)
14
+ if uri.relative?
15
+ uri = parent_schema.uri.clone
16
+
17
+ # Check for absolute path
18
+ path = ref.split("#")[0]
19
+
20
+ # This is a self reference and thus the schema does not need to be
21
+ # re-loaded
22
+ if path.nil? || path == ''
23
+ return
24
+ end
25
+
26
+ if path && path[0,1] == '/'
27
+ uri.path = Pathname.new(path).cleanpath.to_s
28
+ else
29
+ uri = parent_schema.uri.merge(path)
30
+ end
31
+ uri.fragment = ''
32
+ end
33
+
34
+ if Validator.schemas[uri.to_s].nil?
35
+ schema = JSON::Schema.new(JSON::Validator.parse(open(uri.to_s.chomp('#')).read), uri, @options[:version])
36
+ Validator.add_schema(schema)
37
+ build_schemas(schema)
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -1,6 +1,6 @@
1
1
  module ADIWG
2
2
  module JsonSchemas
3
3
  # Current schema version number
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
6
6
  end
data/schema/schema.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "id": "schema.json#",
3
3
  "$schema": "http://json-schema.org/draft-04/schema#",
4
+ "version": "0.8.0",
4
5
  "description": "schema for ADIwg JSON metadata",
5
6
  "type": "object",
6
7
  "required": ["version", "contact", "metadata"],
@@ -11,10 +11,10 @@
11
11
  "additionalProperties": false,
12
12
  "properties": {
13
13
  "metadataIdentifier": {
14
- "type": "string"
14
+ "$ref": "citation.json#/definitions/identifier"
15
15
  },
16
- "parentMetadataIdentifier": {
17
- "type": "string"
16
+ "parentMetadata": {
17
+ "$ref": "citation.json#/definitions/citationFull"
18
18
  },
19
19
  "metadataScope": {
20
20
  "type": "array",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": {
3
3
  "name": "adiwgJSON",
4
- "version": "0.7.0"
4
+ "version": "0.8.0"
5
5
  },
6
6
  "contact": [
7
7
  {
@@ -38,8 +38,42 @@
38
38
  ],
39
39
  "metadata": {
40
40
  "metadataInfo": {
41
- "metadataIdentifier": "",
42
- "parentMetadataIdentifier": "",
41
+ "metadataIdentifier": {
42
+ "identifier": "",
43
+ "type": ""
44
+ },
45
+ "parentMetadata": {
46
+ "title": "",
47
+ "date": [
48
+ {
49
+ "date": "0000-00-00",
50
+ "dateType": ""
51
+ }
52
+ ],
53
+ "edition": "",
54
+ "responsibleParty": [
55
+ {
56
+ "contactId": "",
57
+ "role": ""
58
+ }
59
+ ],
60
+ "presentationForm": [""],
61
+ "identifier": [
62
+ {
63
+ "identifier": "",
64
+ "type": ""
65
+ }
66
+ ],
67
+ "onlineResource": [
68
+ {
69
+ "uri": "http://thisisanexample.com",
70
+ "protocol": "",
71
+ "name": "",
72
+ "description": "",
73
+ "function": ""
74
+ }
75
+ ]
76
+ },
43
77
  "metadataScope": [""],
44
78
  "metadataContact": [
45
79
  {
@@ -49,8 +83,8 @@
49
83
  ],
50
84
  "metadataCreationDate": "0000-00-00",
51
85
  "metadataLastUpdate": "0000-00-00",
86
+ "metadataCharacterSet": "utf8",
52
87
  "metadataUri": "http://thisisanexample.com",
53
- "metadataCharacterSet": "",
54
88
  "metadataStatus": "",
55
89
  "metadataMaintenance": {
56
90
  "maintenanceFrequency": "",
@@ -80,15 +114,6 @@
80
114
  }
81
115
  ],
82
116
  "presentationForm": [""],
83
- "onlineResource": [
84
- {
85
- "uri": "http://thisisanexample.com",
86
- "protocol": "",
87
- "name": "",
88
- "description": "",
89
- "function": ""
90
- }
91
- ],
92
117
  "identifier": [
93
118
  {
94
119
  "identifier": "",
@@ -118,6 +143,15 @@
118
143
  ]
119
144
  }
120
145
  }
146
+ ],
147
+ "onlineResource": [
148
+ {
149
+ "uri": "http://thisisanexample.com",
150
+ "protocol": "",
151
+ "name": "",
152
+ "description": "",
153
+ "function": ""
154
+ }
121
155
  ]
122
156
  },
123
157
  "pointOfContact": [
@@ -191,6 +225,15 @@
191
225
  ]
192
226
  }
193
227
  }
228
+ ],
229
+ "onlineResource": [
230
+ {
231
+ "uri": "http://thisisanexample.com",
232
+ "protocol": "",
233
+ "name": "",
234
+ "description": "",
235
+ "function": ""
236
+ }
194
237
  ]
195
238
  }
196
239
  }
@@ -224,7 +267,7 @@
224
267
  "fileName": "",
225
268
  "fileDescription": "",
226
269
  "fileType": "",
227
- "fileLink": "http://thisisanexample.com"
270
+ "fileUri": "http://thisisanexample.com"
228
271
  }
229
272
  ],
230
273
  "constraint": {
@@ -292,6 +335,15 @@
292
335
  ]
293
336
  }
294
337
  }
338
+ ],
339
+ "onlineResource": [
340
+ {
341
+ "uri": "http://thisisanexample.com",
342
+ "protocol": "",
343
+ "name": "",
344
+ "description": "",
345
+ "function": ""
346
+ }
295
347
  ]
296
348
  }
297
349
  ],
@@ -319,9 +371,9 @@
319
371
  ]
320
372
  },
321
373
  "spatialReferenceSystem": {
322
- "name": [" "],
374
+ "name": [""],
323
375
  "epsgNumber": [0],
324
- "wkt": [" "]
376
+ "wkt": [""]
325
377
  },
326
378
  "spatialRepresentation": [""],
327
379
  "spatialResolution": [
@@ -337,6 +389,130 @@
337
389
  "description": "",
338
390
  "geographicElement": [
339
391
  {
392
+ "type": "Point",
393
+ "bbox": [0, 0, 0, 0],
394
+ "coordinates": [0, 0, 0],
395
+ "crs": {
396
+ "type": "name",
397
+ "properties": {
398
+ "name": ""
399
+ }
400
+ }
401
+ }, {
402
+ "type": "LineString",
403
+ "bbox": [0, 0, 0, 0],
404
+ "coordinates": [
405
+ [0, 0, 0],
406
+ [0, 0, 0]
407
+ ],
408
+ "crs": {
409
+ "type": "name",
410
+ "properties": {
411
+ "name": ""
412
+ }
413
+ }
414
+ }, {
415
+ "type": "Polygon",
416
+ "bbox": [0, 0, 0, 0],
417
+ "coordinates": [
418
+ [
419
+ [0, 0, 0],
420
+ [0, 0, 0],
421
+ [0, 0, 0],
422
+ [0, 0, 0]
423
+ ],
424
+ [
425
+ [0, 0, 0],
426
+ [0, 0, 0],
427
+ [0, 0, 0],
428
+ [0, 0, 0]
429
+ ]
430
+ ],
431
+ "crs": {
432
+ "type": "name",
433
+ "properties": {
434
+ "name": ""
435
+ }
436
+ }
437
+ }, {
438
+ "type": "MultiPoint",
439
+ "bbox": [0, 0, 0, 0],
440
+ "coordinates": [
441
+ [0, 0, 0],
442
+ [0, 0, 0]
443
+ ],
444
+ "crs": {
445
+ "type": "name",
446
+ "properties": {
447
+ "name": ""
448
+ }
449
+ }
450
+ }, {
451
+ "type": "MultiLineString",
452
+ "bbox": [0, 0, 0, 0],
453
+ "coordinates": [
454
+ [
455
+ [0, 0, 0],
456
+ [0, 0, 0],
457
+ [0, 0, 0],
458
+ [0, 0, 0]
459
+ ],
460
+ [
461
+ [0, 0, 0],
462
+ [0, 0, 0],
463
+ [0, 0, 0],
464
+ [0, 0, 0]
465
+ ]
466
+ ],
467
+ "crs": {
468
+ "type": "name",
469
+ "properties": {
470
+ "name": ""
471
+ }
472
+ }
473
+ }, {
474
+ "type": "MultiPolygon",
475
+ "bbox": [0, 0, 0, 0],
476
+ "coordinates": [
477
+ [
478
+ [
479
+ [0, 0, 0],
480
+ [0, 0, 0],
481
+ [0, 0, 0],
482
+ [0, 0, 0]
483
+ ],
484
+ [
485
+ [0, 0, 0],
486
+ [0, 0, 0],
487
+ [0, 0, 0],
488
+ [0, 0, 0]
489
+ ]
490
+ ],
491
+ [
492
+ [
493
+ [0, 0, 0],
494
+ [0, 0, 0],
495
+ [0, 0, 0],
496
+ [0, 0, 0]
497
+ ],
498
+ [
499
+ [0, 0, 0],
500
+ [0, 0, 0],
501
+ [0, 0, 0],
502
+ [0, 0, 0]
503
+ ]
504
+ ]
505
+ ],
506
+ "crs": {
507
+ "type": "name",
508
+ "properties": {
509
+ "name": ""
510
+ }
511
+ }
512
+ }, {
513
+ "type": "GeometryCollection",
514
+ "geometries": []
515
+ }, {
340
516
  "type": "Feature",
341
517
  "id": "",
342
518
  "bbox": [0, 0, 0, 0],
@@ -407,6 +583,7 @@
407
583
  "identifier": [
408
584
  {
409
585
  "identifier": "",
586
+ "type": "",
410
587
  "authority": {
411
588
  "title": "",
412
589
  "date": [
@@ -790,4 +967,4 @@
790
967
  }
791
968
  ]
792
969
  }
793
- }
970
+ }
data/test/tc_schemas.rb CHANGED
@@ -10,12 +10,29 @@ require 'json'
10
10
  require 'json-schema'
11
11
  require File.join(File.dirname(__FILE__),'..','lib', 'adiwg-json_schemas.rb')
12
12
 
13
+ #json-schema patch
14
+ require File.join(File.dirname(__FILE__),'..','lib', 'adiwg', 'json_schemas', 'validator.rb')
15
+
13
16
  class TestExamples < Test::Unit::TestCase
14
17
 
15
18
  @@dir = File.join(File.dirname(__FILE__),'..','schema/')
16
19
  @@ex = File.join(File.dirname(__FILE__),'..','examples/')
17
20
  @@schema = File.join(File.dirname(__FILE__),'..','schema','schema.json')
18
21
 
22
+ def test_schemas
23
+ #Validate the schemas themselves
24
+ puts "\nValidating schemas, Please wait... \n"
25
+ schemas = `git ls-files #{@@dir}`.split($/)
26
+ errors = Array.new
27
+
28
+ schemas.each do |schema|
29
+ error = JSON::Validator.fully_validate('http://json-schema.org/draft-04/schema', schema)
30
+ errors += error
31
+ end
32
+
33
+ assert(errors.empty?, errors.join("/n"))
34
+ end
35
+
19
36
  def test_data_template
20
37
  errors = JSON::Validator.fully_validate(@@schema, @@dir + '../templates/adiwg_metadata_template.json', :strict => false)
21
38
  assert(errors.empty?, errors.join("/n"))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adiwg-json_schemas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bradley, Stan Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: json-schema
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: test-unit
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +111,7 @@ files:
111
111
  - lib/adiwg-json_schemas.rb
112
112
  - lib/adiwg/json_schemas.rb
113
113
  - lib/adiwg/json_schemas/utils.rb
114
+ - lib/adiwg/json_schemas/validator.rb
114
115
  - lib/adiwg/json_schemas/version.rb
115
116
  - schema/schema.json
116
117
  - schema/schema/citation.json