uc3-dmp-id 0.0.21 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,21 +44,14 @@ module Uc3DmpId
44
44
  # Load the JSON schema that corresponds with the mode
45
45
  # ------------------------------------------------------------------------------------
46
46
  def _load_schema(mode:)
47
- schema = "#{_schema_dir}/schemas/#{mode}.json"
48
- file = schema if File.exist?(schema)
49
- return nil if mode.nil? || file.nil? || !File.exist?(file)
50
47
 
51
- JSON.parse(File.read(file))
52
- rescue JSON::ParserError
53
- nil
54
- end
48
+ puts "Loading schema -- Uc3DmpId::Schemas::#{mode.to_s.downcase.capitalize}"
55
49
 
56
- # The location of th JSON schema files
57
- # ------------------------------------------------------------------------------------
58
- def _schema_dir
59
- # TODO: Switch this to the gem dirctory, not sure if this is the same as the Layer below
60
- '/opt/ruby'
50
+ # Instatiate the matching schema
51
+ schema = "Uc3DmpId::Schemas::#{mode.to_s.downcase.capitalize}".split('::').inject(Object) { |o,c| o.const_get c }
52
+ schema.respond_to?(:load) ? schema.load : nil
61
53
  end
54
+
62
55
  end
63
56
  end
64
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.21'
4
+ VERSION = '0.0.23'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
@@ -116,13 +116,13 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - README.md
119
- - lib/schemas/amend.json
120
- - lib/schemas/author.json
121
119
  - lib/uc3-dmp-id.rb
122
120
  - lib/uc3-dmp-id/creator.rb
123
121
  - lib/uc3-dmp-id/deleter.rb
124
122
  - lib/uc3-dmp-id/finder.rb
125
123
  - lib/uc3-dmp-id/helper.rb
124
+ - lib/uc3-dmp-id/schemas/amend.rb
125
+ - lib/uc3-dmp-id/schemas/author.rb
126
126
  - lib/uc3-dmp-id/updater.rb
127
127
  - lib/uc3-dmp-id/validator.rb
128
128
  - lib/uc3-dmp-id/version.rb
@@ -1,330 +0,0 @@
1
- {
2
- "$id": "https://github.com/CDLUC3/dmp-hub-sam/layer/ruby/config/schemas/amend.json",
3
- "title": "RDA DMP Common Standard Schema",
4
- "description": "JSON Schema for the RDA DMP Common Standard",
5
- "type": "object",
6
- "properties": {
7
- "dmp": {
8
- "$id": "#/properties/dmp",
9
- "type": "object",
10
- "title": "The DMP Schema",
11
- "properties": {
12
- "dmp_id": {
13
- "$id": "#/properties/dmp/properties/dmp_id",
14
- "type": "object",
15
- "title": "The DMP Identifier Schema",
16
- "description": "Identifier for the DMP itself",
17
- "properties": {
18
- "identifier": {
19
- "$id": "#/properties/dmp/properties/dmp_id/properties/identifier",
20
- "type": "string",
21
- "title": "The DMP Identifier Value Schema",
22
- "description": "Identifier for a DMP",
23
- "examples": ["https://doi.org/10.1371/journal.pcbi.1006750"]
24
- },
25
- "type": {
26
- "$id": "#/properties/dmp/properties/dmp_id/properties/type",
27
- "type": "string",
28
- "enum": [
29
- "handle",
30
- "doi",
31
- "ark",
32
- "url",
33
- "other"
34
- ],
35
- "title": "The DMP Identifier Type Schema",
36
- "description": "The DMP Identifier Type. Allowed values: handle, doi, ark, url, other",
37
- "examples": ["doi"]
38
- }
39
- },
40
- "required": [
41
- "identifier",
42
- "type"
43
- ]
44
- },
45
- "modified": {
46
- "$id": "#/properties/dmp/properties/modified",
47
- "type": "string",
48
- "format": "date-time",
49
- "title": "The DMP Modification Schema",
50
- "description": "Must be set each time DMP is modified. Indicates DMP version. Encoded using the relevant ISO 8601 Date and Time compliant string.",
51
- "examples": ["2020-03-14T10:53:49"]
52
- },
53
- "title": {
54
- "$id": "#/properties/dmp/properties/title",
55
- "type": "string",
56
- "title": "The DMP Title Schema",
57
- "description": "Title of a DMP",
58
- "examples": ["DMP for our new project"]
59
- },
60
- "anyOf": [
61
- {
62
- "dmproadmap_related_identifiers": {
63
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers",
64
- "type": "array",
65
- "title": "Related identifiers for the DMP",
66
- "description": "Identifiers for objects related to the DMP (e.g. datasets, publications, etc.)",
67
- "items": {
68
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers/items",
69
- "type": "object",
70
- "title": "A related identifier",
71
- "properties": {
72
- "descriptor": {
73
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers/items/properties/descriptor",
74
- "type": "string",
75
- "enum": [
76
- "is_cited_by",
77
- "cites",
78
- "is_supplement_to",
79
- "is_supplemented_by",
80
- "is_described_by",
81
- "describes",
82
- "has_metadata",
83
- "is_metadata_for",
84
- "is_part_of",
85
- "has_part",
86
- "is_referenced_by",
87
- "references",
88
- "is_documented_by",
89
- "documents",
90
- "is_new_version_of",
91
- "is_previous_version_of"
92
- ]
93
- },
94
- "identifier": {
95
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers/items/properties/identifier",
96
- "type": "string",
97
- "title": "A unique identifier for the item",
98
- "description": "Identifier for a DMP",
99
- "examples": ["https://doi.org/10.1371/journal.pcbi.1006750"]
100
- },
101
- "type": {
102
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers/items/properties/type",
103
- "type": "string",
104
- "enum": [
105
- "handle",
106
- "doi",
107
- "ark",
108
- "url",
109
- "other"
110
- ]
111
- },
112
- "work_type": {
113
- "$id": "#/properties/dmp/properties/dmproadmap_related_identifiers/items/properties/work_type",
114
- "type": "string",
115
- "enum": [
116
- "article",
117
- "book",
118
- "dataset",
119
- "metadata_template",
120
- "other",
121
- "output_management_plan",
122
- "paper",
123
- "preprint",
124
- "preregistration",
125
- "protocol",
126
- "software",
127
- "supplemental_information"
128
- ]
129
- }
130
- },
131
- "required": [
132
- "descriptor",
133
- "identifier",
134
- "type",
135
- "work_type"
136
- ]
137
- }
138
- }
139
- },
140
- {
141
- "project": {
142
- "$id": "#/properties/dmp/properties/project",
143
- "type": "array",
144
- "title": "The DMP Project Schema",
145
- "description": "Project related to a DMP",
146
- "items": {
147
- "$id": "#/properties/dmp/properties/project/items",
148
- "type": "object",
149
- "title": "The DMP Project Items Schema",
150
- "properties": {
151
- "funding": {
152
- "$id": "#/properties/dmp/properties/project/items/properties/funding",
153
- "type": "array",
154
- "title": "The DMP Project Funding Schema",
155
- "description": "Funding related with a project",
156
- "items": {
157
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items",
158
- "type": "object",
159
- "title": "The DMP Project Funding Items Schema",
160
- "properties": {
161
- "dmproadmap_funded_affiliations": {
162
- "$id": "#/properties/dmp/properties/project/items/properties/funding//items/properties/dmproadmap_funded_affiliations",
163
- "type": "array",
164
- "title": "Institutions named on the grant",
165
- "description": "The institutions who received the funding",
166
- "items": {
167
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items/properties/dmproadmap_funded_affiliations/items",
168
- "type": "object",
169
- "title": "An institution that received funding",
170
- "properties": {
171
- "affiliation_id": {
172
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items/properties/dmproadmap_funded_affiliations/items/properties/affiliation_id",
173
- "type": "object",
174
- "title": "The funded affiliation's ID",
175
- "description": "Affiliation ID of the associated project",
176
- "properties": {
177
- "identifier": {
178
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items/properties/dmproadmap_funded_affiliations/items/properties/affiliation_id/properties/identifier",
179
- "type": "string",
180
- "title": "The affiliation ID",
181
- "description": "ROR ID or URL. Recommended to use Research Organization Registry (ROR). See: https://ror.org",
182
- "examples": ["https://ror.org/00pjdza24", "https://cdlib.org"]
183
- },
184
- "type": {
185
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items/properties/dmproadmap_funded_affiliations/items/properties/affiliation_id/properties/type",
186
- "type": "string",
187
- "enum": [
188
- "doi",
189
- "ror",
190
- "url"
191
- ],
192
- "title": "The affiliation ID Type Schema",
193
- "description": "Identifier type. Allowed values: doi, ror, url",
194
- "examples": ["ror"]
195
- }
196
- },
197
- "required": [
198
- "identifier",
199
- "type"
200
- ]
201
- },
202
- "name": {
203
- "$id": "#/properties/dmp/properties/project/items/properties/funding/items/properties/dmproadmap_funded_affiliations/items/properties/name",
204
- "type": "string",
205
- "title": "The name of the instituion / organization",
206
- "description": "Project title",
207
- "examples": ["Our New Project"]
208
- }
209
- }
210
- }
211
- },
212
- "dmproadmap_opportunity_number": {
213
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/dmproadmap_opportunity_number",
214
- "type": "string",
215
- "title": "The funder's opportunity / award number",
216
- "description": "The funder's number used to identify the award or call for submissions",
217
- "examples": ["Award-123"]
218
- },
219
- "dmproadmap_project_number": {
220
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/dmproadmap_project_number",
221
- "type": "string",
222
- "title": "The funder's identifier for the research project",
223
- "description": "The funder's identifier used to identify the research project",
224
- "examples": ["prj-XYZ987-UCB"]
225
- },
226
- "funder_id": {
227
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/funder_id",
228
- "type": "object",
229
- "title": "The Funder ID Schema",
230
- "description": "Funder ID of the associated project",
231
- "properties": {
232
- "identifier": {
233
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/funder_id/properties/identifier",
234
- "type": "string",
235
- "title": "The Funder ID Value Schema",
236
- "description": "Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/",
237
- "examples": ["501100002428"]
238
- },
239
- "type": {
240
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/funder_id/properties/type",
241
- "type": "string",
242
- "enum": [
243
- "fundref",
244
- "ror",
245
- "url",
246
- "other"
247
- ],
248
- "title": "The Funder ID Type Schema",
249
- "description": "Identifier type. Allowed values: fundref, url, other",
250
- "examples": ["fundref"]
251
- }
252
- },
253
- "required": [
254
- "identifier",
255
- "type"
256
- ]
257
- },
258
- "funding_status": {
259
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/funding_status",
260
- "type": "string",
261
- "enum": [
262
- "planned",
263
- "applied",
264
- "granted",
265
- "rejected"
266
- ],
267
- "title": "The Funding Status Schema",
268
- "description": "To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected",
269
- "examples": ["granted"]
270
- },
271
- "grant_id": {
272
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/grant_id",
273
- "type": "object",
274
- "title": "The Funding Grant ID Schema",
275
- "description": "Grant ID of the associated project",
276
- "properties": {
277
- "identifier": {
278
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/grant_id/properties/identifier",
279
- "type": "string",
280
- "title": "The Funding Grant ID Value Schema",
281
- "description": "Grant ID",
282
- "examples": ["776242"]
283
- },
284
- "type": {
285
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/grant_id/properties/type",
286
- "type": "string",
287
- "title": "The Funding Grant ID Type Schema",
288
- "enum": [
289
- "url",
290
- "other"
291
- ],
292
- "description": "Identifier type. Allowed values: url, other",
293
- "examples": ["other"]
294
- }
295
- },
296
- "required": [
297
- "identifier",
298
- "type"
299
- ]
300
- },
301
- "name": {
302
- "$id": "#/properties/dmp/properties/project/items/properties/funding/properties/name",
303
- "type": "string",
304
- "title": "The name of the funding instituion / organization",
305
- "description": "Name",
306
- "examples": ["National Science Foundation"]
307
- }
308
- },
309
- "required": [
310
- "funding_status",
311
- "name"
312
- ]
313
- }
314
- }
315
- }
316
- }
317
- }
318
- }
319
- ]
320
- },
321
- "required": [
322
- "dmp_id",
323
- "modified",
324
- "title"
325
- ]
326
- }
327
- },
328
- "additionalProperties": false,
329
- "required": ["dmp"]
330
- }