adiwg-mdtranslator 2.0.0rc11 → 2.0.0rc13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Rakefile +1 -0
  4. data/adiwg-mdtranslator.gemspec +2 -0
  5. data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +32 -18
  6. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +96 -96
  7. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb +35 -35
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +102 -105
  9. data/lib/adiwg/mdtranslator/readers/mdReaders.rb +49 -49
  10. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_additionalDocumentation.rb +0 -0
  11. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_boundingBox.rb +0 -0
  12. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_browseGraphic.rb +0 -0
  13. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_citation.rb +0 -0
  14. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_contacts.rb +0 -0
  15. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_dateTime.rb +0 -0
  16. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_distributionInfo.rb +0 -0
  17. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_extent.rb +0 -0
  18. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geoCoordSystem.rb +0 -0
  19. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geoProperties.rb +0 -0
  20. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geographicElement.rb +0 -0
  21. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_metadata.rb +0 -0
  22. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_metadataInfo.rb +0 -0
  23. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_onlineResource.rb +0 -0
  24. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_resourceIdentifier.rb +0 -0
  25. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_resourceInfo.rb +0 -0
  26. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_responsibleParty.rb +0 -0
  27. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_body.rb +41 -0
  28. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_citation.rb +32 -0
  29. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_id.rb +35 -0
  30. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_identifier.rb +46 -0
  31. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_provenance.rb +59 -0
  32. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_purpose.rb +32 -0
  33. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_rights.rb +43 -0
  34. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +106 -0
  35. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_titles.rb +42 -0
  36. data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +56 -198
  37. data/lib/adiwg/mdtranslator/readers/sbJson/version.rb +14 -0
  38. data/lib/adiwg/mdtranslator/version.rb +3 -1
  39. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_codelist.rb +38 -38
  40. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_date.rb +1 -1
  41. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +1 -1
  42. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_abstract.rb +27 -0
  43. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +6 -6
  44. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +90 -12
  45. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +12 -4
  46. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_date.rb +4 -4
  47. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +16 -17
  48. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_materialRequest.rb +6 -2
  49. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_provenance.rb +2 -18
  50. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb +13 -0
  51. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +3 -2
  52. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_webLink.rb +23 -2
  53. metadata +59 -22
  54. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +0 -52
  55. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbce410a9f43321f9019509cb844144ff5ca950b
4
- data.tar.gz: b9576143da46802dda31de1d03b0f56c6049c3b1
3
+ metadata.gz: e6dae2d4d0b4f056465097adf48a786332a8e1ac
4
+ data.tar.gz: 4d120c45abcf7459c45271c4e4a626e4bc2aa426
5
5
  SHA512:
6
- metadata.gz: c9c62887d1941434a579619e3bed5a691c77652e87280e7e667d2683ae6d6a0cdab75caba2af26e824c50e1ab906e89b3625ee089e2ec75858ea300dddd5ac5e
7
- data.tar.gz: aeb48e161931209ec8a077d1509ea8072eebd0e95727dd2f0ab3a45be0a9f67626563428983135f05732937453e838f712b1be5d0dbbabd8a339e92d7a1e87a5
6
+ metadata.gz: 59a2afd957514a20c5d2497d6627a08516dcfb40df807fb9fcbd6039263bb83ec512717b141abfe43153b91fe4430877e360964bdcdb51c82e195826c9017941
7
+ data.tar.gz: 1e080a421fad0efb0139437922a021d5b7402c252ed2dda1ca3fbd0695eed882309c2f345a4170e015606142689a17364914b1784df99c7ccce3610568412c4f
data/.travis.yml CHANGED
@@ -3,7 +3,6 @@ sudo: false
3
3
  language: ruby
4
4
  before_install: 'gem install bundler'
5
5
  rvm:
6
- - 2.1
7
6
  - 2.2
8
7
  - "2.3.3"
9
8
  - "2.4.0"
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ Rake::TestTask.new do |t|
5
5
  t.libs << 'test'
6
6
  t.test_files = FileList[
7
7
  'test/readers/mdJson/tc*.rb',
8
+ 'test/readers/sbJson/tc*.rb',
8
9
  'test/writers/iso19115-2/tc*.rb',
9
10
  'test/writers/iso19110/tc*.rb',
10
11
  'test/writers/mdJson/tc*.rb',
@@ -36,5 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "adiwg-mdjson_schemas", ">= 2.2"
37
37
  spec.add_runtime_dependency "adiwg-mdcodes", "~> 2.1"
38
38
  spec.add_runtime_dependency "jbuilder", "~> 2.5"
39
+ spec.add_runtime_dependency "kramdown", "~> 1.13"
40
+ spec.add_runtime_dependency "coderay", "~> 1.1"
39
41
 
40
42
  end
@@ -140,23 +140,37 @@ module AdiwgDateTimeFun
140
140
  return sDuration
141
141
  end
142
142
 
143
- def self.stringFromDateObject(obj)
144
-
145
- date = obj[:date]
146
- if date.nil?
147
- date = obj[:dateTime]
148
- end
149
- dateRes = obj[:dateResolution]
150
- unless date.nil?
151
- case dateRes
152
- when 'Y', 'YM', 'YMD'
153
- dateStr = stringDateFromDateTime(date, dateRes)
154
- else
155
- dateStr = stringDateTimeFromDateTime(date, dateRes)
156
- end
157
- end
158
-
159
- return dateStr
160
- end
143
+ def self.stringDateFromDateObject(obj)
144
+
145
+ date = obj[:date]
146
+ if date.nil?
147
+ date = obj[:dateTime]
148
+ end
149
+ dateRes = obj[:dateResolution]
150
+ unless date.nil?
151
+ dateStr = stringDateFromDateTime(date, dateRes)
152
+ end
153
+ return dateStr
154
+
155
+ end
156
+
157
+ def self.stringDateTimeFromDateObject(obj)
158
+
159
+ date = obj[:date]
160
+ if date.nil?
161
+ date = obj[:dateTime]
162
+ end
163
+ dateRes = obj[:dateResolution]
164
+ unless date.nil?
165
+ case dateRes
166
+ when 'Y', 'YM', 'YMD'
167
+ dateStr = stringDateFromDateTime(date, dateRes)
168
+ else
169
+ dateStr = stringDateTimeFromDateTime(date, dateRes)
170
+ end
171
+ end
172
+
173
+ return dateStr
174
+ end
161
175
 
162
176
  end
@@ -1,20 +1,20 @@
1
1
  # mdJson reader - process and direct mdJson ingest to internal data structure
2
2
 
3
3
  # History:
4
- # Stan Smith 2016-11-12 refactor for mdTranslator 2.0
5
- # Stan Smith 2016-10-09 modify 'findContact' to also return contact index and type
6
- # Stan Smith 2016-10-07 refactored 'readerModule' to remove mdJson version checking
7
- # Stan Smith 2015-07-14 added support for mdJson version numbers
8
- # Stan Smith 2015-07-14 refactored to remove global namespace constants
9
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
10
- # Stan Smith 2015-06-12 added method to lookup contact in contact array
11
- # Stan Smith 2014-12-11 refactored to handle namespacing readers and writers
12
- # Stan Smith 2014-12-03 changed class name to MdJsonReader from AdiwgJsonReader
13
- # Stan Smith 2014-12-01 add data dictionary
14
- # Stan Smith 2014-08-18 add json name/version to internal object
15
- # Stan Smith 2014-07-08 moved json schema version testing to 'adiwg_1_get_version'
16
- # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
17
- # Stan Smith 2014-06-05 capture an test json version
4
+ # Stan Smith 2016-11-12 refactor for mdTranslator 2.0
5
+ # Stan Smith 2016-10-09 modify 'findContact' to also return contact index and type
6
+ # Stan Smith 2016-10-07 refactored 'readerModule' to remove mdJson version checking
7
+ # Stan Smith 2015-07-14 added support for mdJson version numbers
8
+ # Stan Smith 2015-07-14 refactored to remove global namespace constants
9
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
10
+ # Stan Smith 2015-06-12 added method to lookup contact in contact array
11
+ # Stan Smith 2014-12-11 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-12-03 changed class name to MdJsonReader from AdiwgJsonReader
13
+ # Stan Smith 2014-12-01 add data dictionary
14
+ # Stan Smith 2014-08-18 add json name/version to internal object
15
+ # Stan Smith 2014-07-08 moved json schema version testing to 'adiwg_1_get_version'
16
+ # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
17
+ # Stan Smith 2014-06-05 capture an test json version
18
18
  # Stan Smith 2014-04-23 add json schema version to internal object
19
19
  # Stan Smith 2013-08-23 split out metadata to module_metadata
20
20
  # Stan Smith 2013-08-19 split out contacts to module_contacts
@@ -26,97 +26,97 @@ require_relative 'version'
26
26
  require_relative 'modules/module_mdJson'
27
27
 
28
28
  module ADIWG
29
- module Mdtranslator
30
- module Readers
31
- module MdJson
29
+ module Mdtranslator
30
+ module Readers
31
+ module MdJson
32
32
 
33
- def self.readFile(file, hResponseObj)
33
+ def self.readFile(file, hResponseObj)
34
34
 
35
- # parse mdJson file
36
- begin
37
- hMdJson = JSON.parse(file)
38
- rescue JSON::JSONError => err
39
- hResponseObj[:readerStructureMessages] << 'Parsing mdJson Failed - see following message(s):\n'
40
- hResponseObj[:readerStructureMessages] << err.to_s.slice(0,300)
41
- hResponseObj[:readerStructurePass] = false
42
- return {}
43
- end
35
+ # parse mdJson file
36
+ begin
37
+ hMdJson = JSON.parse(file)
38
+ rescue JSON::JSONError => err
39
+ hResponseObj[:readerStructureMessages] << 'Parsing mdJson Failed - see following message(s):\n'
40
+ hResponseObj[:readerStructureMessages] << err.to_s.slice(0, 300)
41
+ hResponseObj[:readerStructurePass] = false
42
+ return {}
43
+ end
44
44
 
45
- # file must contain an mdJson object
46
- if hMdJson.empty?
47
- hResponseObj[:readerStructureMessages] << 'mdJson object is empty'
48
- hResponseObj[:readerStructurePass] = false
49
- return {}
50
- end
45
+ # file must contain an mdJson object
46
+ if hMdJson.empty?
47
+ hResponseObj[:readerStructureMessages] << 'mdJson object is empty'
48
+ hResponseObj[:readerStructurePass] = false
49
+ return {}
50
+ end
51
51
 
52
- # schema - (required)
53
- unless hMdJson.has_key?('schema')
54
- hResponseObj[:readerStructureMessages] << 'mdJson is missing schema object'
55
- hResponseObj[:readerStructurePass] = false
56
- return {}
57
- end
52
+ # schema - (required)
53
+ unless hMdJson.has_key?('schema')
54
+ hResponseObj[:readerStructureMessages] << 'mdJson is missing schema object'
55
+ hResponseObj[:readerStructurePass] = false
56
+ return {}
57
+ end
58
58
 
59
- # schema - name (required) (must = 'mdJson')
60
- unless hMdJson['schema'].has_key?('name')
61
- hResponseObj[:readerStructureMessages] << 'mdJson schema:name attribute is missing'
62
- hResponseObj[:readerStructurePass] = false
63
- return {}
64
- end
65
- schemaName = hMdJson['schema']['name']
66
- if schemaName.nil? || schemaName == ''
67
- hResponseObj[:readerStructureMessages] << 'mdJson schema name is missing'
68
- hResponseObj[:readerStructurePass] = false
69
- return {}
70
- end
71
- unless schemaName.downcase == 'mdjson'
72
- hResponseObj[:readerStructureMessages] << "mdJson schema name is '#{schemaName}', should be mdJson"
73
- hResponseObj[:readerStructurePass] = false
74
- return {}
75
- end
59
+ # schema - name (required) (must = 'mdJson')
60
+ unless hMdJson['schema'].has_key?('name')
61
+ hResponseObj[:readerStructureMessages] << 'mdJson schema:name attribute is missing'
62
+ hResponseObj[:readerStructurePass] = false
63
+ return {}
64
+ end
65
+ schemaName = hMdJson['schema']['name']
66
+ if schemaName.nil? || schemaName == ''
67
+ hResponseObj[:readerStructureMessages] << 'mdJson schema name is missing'
68
+ hResponseObj[:readerStructurePass] = false
69
+ return {}
70
+ end
71
+ unless schemaName.downcase == 'mdjson'
72
+ hResponseObj[:readerStructureMessages] << "mdJson schema name is '#{schemaName}', should be mdJson"
73
+ hResponseObj[:readerStructurePass] = false
74
+ return {}
75
+ end
76
76
 
77
- # schema - version (required)
78
- unless hMdJson['schema'].has_key?('version')
79
- hResponseObj[:readerStructureMessages] << 'mdJson schema:version attribute is missing'
80
- hResponseObj[:readerStructurePass] = false
81
- return {}
82
- end
83
- requestedVersion = hMdJson['schema']['version']
84
- if requestedVersion.nil? || requestedVersion == ''
85
- hResponseObj[:readerStructureMessages] << 'mdJson schema version is missing'
86
- hResponseObj[:readerStructurePass] = false
87
- return {}
88
- end
77
+ # schema - version (required)
78
+ unless hMdJson['schema'].has_key?('version')
79
+ hResponseObj[:readerStructureMessages] << 'mdJson schema:version attribute is missing'
80
+ hResponseObj[:readerStructurePass] = false
81
+ return {}
82
+ end
83
+ requestedVersion = hMdJson['schema']['version']
84
+ if requestedVersion.nil? || requestedVersion == ''
85
+ hResponseObj[:readerStructureMessages] << 'mdJson schema version is missing'
86
+ hResponseObj[:readerStructurePass] = false
87
+ return {}
88
+ end
89
89
 
90
- # schema - 2.0.0 =< requested version =< current version
91
- currentVersion = ADIWG::Mdtranslator::Readers::MdJson::VERSION
92
- hResponseObj[:readerVersionRequested] = requestedVersion
93
- hResponseObj[:readerVersionUsed] = currentVersion
94
- aCurVersion = currentVersion.split('.')
95
- aReqVersion = requestedVersion.split('.')
96
- approved = false
97
- if aReqVersion[0] == aCurVersion[0]
98
- if aReqVersion[1] <= aCurVersion[1]
99
- approved = true
100
- end
101
- end
102
- unless approved
103
- hResponseObj[:readerStructureMessages] << "mdJson schema version '#{requestedVersion}' is not supported"
104
- hResponseObj[:readerStructurePass] = false
105
- return {}
106
- end
90
+ # schema - 2.0.0 =< requested version =< current version
91
+ currentVersion = ADIWG::Mdtranslator::Readers::MdJson::VERSION
92
+ hResponseObj[:readerVersionRequested] = requestedVersion
93
+ hResponseObj[:readerVersionUsed] = currentVersion
94
+ aCurVersion = currentVersion.split('.')
95
+ aReqVersion = requestedVersion.split('.')
96
+ approved = false
97
+ if aReqVersion[0] == aCurVersion[0]
98
+ if aReqVersion[1] <= aCurVersion[1]
99
+ approved = true
100
+ end
101
+ end
102
+ unless approved
103
+ hResponseObj[:readerStructureMessages] << "mdJson schema version '#{requestedVersion}' is not supported"
104
+ hResponseObj[:readerStructurePass] = false
105
+ return {}
106
+ end
107
107
 
108
- # validate file against mdJson schema definition
109
- validate(hMdJson, hResponseObj)
110
- unless hResponseObj[:readerValidationPass]
111
- return {}
112
- end
108
+ # validate file against mdJson schema definition
109
+ validate(hMdJson, hResponseObj)
110
+ unless hResponseObj[:readerValidationPass]
111
+ return {}
112
+ end
113
113
 
114
- # unpack the mdJson into the internal object
115
- return MdJson.unpack(hMdJson, hResponseObj)
116
-
117
- end
114
+ # unpack the mdJson into the internal object
115
+ return MdJson.unpack(hMdJson, hResponseObj)
118
116
 
119
117
  end
120
- end
121
- end
118
+
119
+ end
120
+ end
121
+ end
122
122
  end
@@ -17,43 +17,43 @@ require 'json-schema'
17
17
  require 'adiwg-mdjson_schemas'
18
18
 
19
19
  module ADIWG
20
- module Mdtranslator
21
- module Readers
22
- module MdJson
23
-
24
- # validate json against the adiwg-json_schemas
25
- # only a single schema version is supported at this time
26
- def self.validate(file, responseObj)
27
-
28
- bStrict = false
29
- if responseObj[:readerValidationLevel] == 'strict'
30
- bStrict = true
31
- end
32
- ADIWG::MdjsonSchemas::Utils.load_schemas(false)
33
-
34
- begin
35
- aErrors = []
36
- aErrors = JSON::Validator.fully_validate('schema.json', file, :strict=>bStrict)
37
-
38
- if aErrors.length > 0
39
- responseObj[:readerValidationPass] = false
40
- responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
41
- responseObj[:readerValidationMessages] << aErrors
42
- return
43
- end
44
-
45
- rescue JSON::Schema::ValidationError
46
- responseObj[:readerValidationPass] = false
47
- responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
48
- responseObj[:readerValidationMessages] << $!.message
49
- return
50
- end
51
-
52
- end
20
+ module Mdtranslator
21
+ module Readers
22
+ module MdJson
23
+
24
+ # validate json against the adiwg-json_schemas
25
+ # only a single schema version is supported at this time
26
+ def self.validate(file, responseObj)
27
+
28
+ bStrict = false
29
+ if responseObj[:readerValidationLevel] == 'strict'
30
+ bStrict = true
31
+ end
32
+ ADIWG::MdjsonSchemas::Utils.load_schemas(false)
33
+
34
+ begin
35
+ aErrors = []
36
+ aErrors = JSON::Validator.fully_validate('schema.json', file, :strict => bStrict)
37
+
38
+ if aErrors.length > 0
39
+ responseObj[:readerValidationPass] = false
40
+ responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
41
+ responseObj[:readerValidationMessages] << aErrors
42
+ return
43
+ end
44
+
45
+ rescue JSON::Schema::ValidationError
46
+ responseObj[:readerValidationPass] = false
47
+ responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
48
+ responseObj[:readerValidationMessages] << $!.message
49
+ return
50
+ end
53
51
 
54
52
  end
55
- end
56
- end
53
+
54
+ end
55
+ end
56
+ end
57
57
  end
58
58
 
59
59
 
@@ -12,125 +12,122 @@ require_relative 'module_dataDictionary'
12
12
  require_relative 'module_metadataRepository'
13
13
 
14
14
  module ADIWG
15
- module Mdtranslator
16
- module Readers
17
- module MdJson
18
-
19
- module MdJson
15
+ module Mdtranslator
16
+ module Readers
17
+ module MdJson
20
18
 
21
- def self.unpack(hMdJson, responseObj)
19
+ module MdJson
22
20
 
23
- # return nil object if input is empty
24
- if hMdJson.empty?
25
- responseObj[:readerExecutionMessages] << 'mdJson object is empty'
26
- responseObj[:readerExecutionPass] = false
27
- return nil
21
+ def self.unpack(hMdJson, responseObj)
22
+
23
+ # return nil object if input is empty
24
+ if hMdJson.empty?
25
+ responseObj[:readerExecutionMessages] << 'mdJson object is empty'
26
+ responseObj[:readerExecutionPass] = false
27
+ return nil
28
+ end
29
+
30
+ # instance classes needed in script
31
+ intMetadataClass = InternalMetadata.new
32
+ intObj = intMetadataClass.newBase
33
+
34
+ # mdJson - schema {schema} (required)
35
+ if hMdJson.has_key?('schema')
36
+ hObject = hMdJson['schema']
37
+ unless hObject.empty?
38
+ hReturn = Schema.unpack(hObject, responseObj)
39
+ unless hReturn.nil?
40
+ intObj[:schema] = hReturn
28
41
  end
29
-
30
- # instance classes needed in script
31
- intMetadataClass = InternalMetadata.new
32
- intObj = intMetadataClass.newBase
33
-
34
- # mdJson - schema {schema} (required)
35
- if hMdJson.has_key?('schema')
36
- hObject = hMdJson['schema']
37
- unless hObject.empty?
38
- hReturn = Schema.unpack(hObject, responseObj)
39
- unless hReturn.nil?
40
- intObj[:schema] = hReturn
41
- end
42
- end
42
+ end
43
+ end
44
+ if intObj[:schema].empty?
45
+ responseObj[:readerExecutionMessages] << 'mdJson object is missing schema'
46
+ responseObj[:readerExecutionPass] = false
47
+ return nil
48
+ end
49
+
50
+ # mdJson - contact [] {contact} (required)
51
+ if hMdJson.has_key?('contact')
52
+ aItems = hMdJson['contact']
53
+ aItems.each do |item|
54
+ hReturn = Contact.unpack(item, responseObj)
55
+ unless hReturn.nil?
56
+ intObj[:contacts] << hReturn
57
+ @contacts = intObj[:contacts]
43
58
  end
44
- if intObj[:schema].empty?
45
- responseObj[:readerExecutionMessages] << 'mdJson object is missing schema'
46
- responseObj[:readerExecutionPass] = false
47
- return nil
59
+ end
60
+ end
61
+ if intObj[:contacts].empty?
62
+ responseObj[:readerExecutionMessages] << 'mdJson object is missing contact'
63
+ responseObj[:readerExecutionPass] = false
64
+ return nil
65
+ end
66
+
67
+ # mdJson - metadata {metadata}
68
+ if hMdJson.has_key?('metadata')
69
+ hObject = hMdJson['metadata']
70
+ unless hObject.empty?
71
+ hReturn = Metadata.unpack(hObject, responseObj)
72
+ unless hReturn.nil?
73
+ intObj[:metadata] = hReturn
48
74
  end
49
-
50
- # mdJson - contact [] {contact} (required)
51
- if hMdJson.has_key?('contact')
52
- aItems = hMdJson['contact']
53
- aItems.each do |item|
54
- hReturn = Contact.unpack(item, responseObj)
55
- unless hReturn.nil?
56
- intObj[:contacts] << hReturn
57
- @contacts = intObj[:contacts]
58
- end
59
- end
75
+ end
76
+ end
77
+
78
+ # mdJson - data dictionary [] {dataDictionary}
79
+ if hMdJson.has_key?('dataDictionary')
80
+ aItems = hMdJson['dataDictionary']
81
+ aItems.each do |hItem|
82
+ hReturn = DataDictionary.unpack(hItem, responseObj)
83
+ unless hReturn.nil?
84
+ intObj[:dataDictionaries] << hReturn
60
85
  end
61
- if intObj[:contacts].empty?
62
- responseObj[:readerExecutionMessages] << 'mdJson object is missing contact'
63
- responseObj[:readerExecutionPass] = false
64
- return nil
86
+ end
87
+ end
88
+
89
+ # metadata - metadata distribution [] {metadataDistribution}
90
+ if hMdJson.has_key?('metadataRepository')
91
+ aItems = hMdJson['metadataRepository']
92
+ aItems.each do |item|
93
+ hReturn = MetadataRepository.unpack(item, responseObj)
94
+ unless hReturn.nil?
95
+ intObj[:metadataRepositories] << hReturn
65
96
  end
97
+ end
98
+ end
66
99
 
67
- # mdJson - metadata {metadata}
68
- if hMdJson.has_key?('metadata')
69
- hObject = hMdJson['metadata']
70
- unless hObject.empty?
71
- hReturn = Metadata.unpack(hObject, responseObj)
72
- unless hReturn.nil?
73
- intObj[:metadata] = hReturn
74
- end
75
- end
76
- end
100
+ return intObj
77
101
 
78
- # mdJson - data dictionary [] {dataDictionary}
79
- if hMdJson.has_key?('dataDictionary')
80
- aItems = hMdJson['dataDictionary']
81
- aItems.each do |hItem|
82
- hReturn = DataDictionary.unpack(hItem, responseObj)
83
- unless hReturn.nil?
84
- intObj[:dataDictionaries] << hReturn
85
- end
86
- end
87
- end
102
+ end
88
103
 
89
- # metadata - metadata distribution [] {metadataDistribution}
90
- if hMdJson.has_key?('metadataRepository')
91
- aItems = hMdJson['metadataRepository']
92
- aItems.each do |item|
93
- hReturn = MetadataRepository.unpack(item, responseObj)
94
- unless hReturn.nil?
95
- intObj[:metadataRepositories] << hReturn
96
- end
97
- end
98
- end
104
+ # find the array pointer and type for a contact
105
+ def self.findContact(contactId)
99
106
 
100
- return intObj
101
-
102
- end
103
-
104
- # find the array pointer and type for a contact
105
- def self.findContact(contactId)
106
-
107
- contactIndex = nil
108
- contactType = nil
109
- i = 0
110
- @contacts.each do |contact|
111
- if contact[:contactId] == contactId
112
- contactIndex = i
113
- if contact[:isOrganization]
114
- contactType = 'organization'
115
- else
116
- contactType = 'individual'
117
- end
118
- end
119
- i += 1
107
+ contactIndex = nil
108
+ contactType = nil
109
+ @contacts.each_with_index do |contact, i|
110
+ if contact[:contactId] == contactId
111
+ contactIndex = i
112
+ if contact[:isOrganization]
113
+ contactType = 'organization'
114
+ else
115
+ contactType = 'individual'
120
116
  end
117
+ end
118
+ end
119
+ return contactIndex, contactType
121
120
 
122
- return contactIndex, contactType
123
-
124
- end
121
+ end
125
122
 
126
- # set contacts array for reader test modules
127
- def self.setContacts(contacts)
128
- @contacts = contacts
129
- end
130
-
131
- end
123
+ # set contacts array for reader test modules
124
+ def self.setContacts(contacts)
125
+ @contacts = contacts
126
+ end
132
127
 
133
128
  end
134
- end
135
- end
129
+
130
+ end
131
+ end
132
+ end
136
133
  end