datacite 0.1.1 → 0.2.3

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
  SHA256:
3
- metadata.gz: 443df070a95f905f5d8f82cc5b5d1120ae857259acdd275a41ae370f6c9ee769
4
- data.tar.gz: babea5a17ae9a4548bb4ed6f5b0782eb825c2fff926efdfa57be082d5ba03c45
3
+ metadata.gz: 5b4e07720b65e4a47881eb7d5905c6050c4104b6c9a728fa234d2199b4c52986
4
+ data.tar.gz: 74edad75a1c915582b4867fb69b45e12972fd2b88720652d3afbdefff50e25ba
5
5
  SHA512:
6
- metadata.gz: 1fe003ed073178d8b9c96604f8c8a2d45159f1423cf23a8499cc24f4da078fbf1e6c0044dde978ca4ca47bbf6a7ece1e1038e54c0170c89e24993ee18b8a67f1
7
- data.tar.gz: b1e7a45cb9c39449464be45292ad2370f253d1c3ea14dac39601f17e6234e68fde6bdcf3c665346d5af241edc65eeb6c7d29de43a35529a8a47a8a375737fe89
6
+ metadata.gz: 8337bda82aabb3d4bac9f5546777c22f49705bbae2e6b8c450a017635be9b0b003cb99b76e062f3e1f042e0f30995195ed48e0dde2eaf8e53ac57120b858ba8c
7
+ data.tar.gz: 7423c99f2869c1dd25999606e810aefb4469295dd4141e6b65fc929cab3e8113fa1e42c5dd844b4fc0aba099558546ad3d6d4f414a107c34127f257b7c5efa54
@@ -0,0 +1,12 @@
1
+ ## Why was this change made?
2
+
3
+
4
+
5
+ ## How was this change tested?
6
+
7
+
8
+
9
+ ## Which documentation and/or configurations were updated?
10
+
11
+
12
+
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datacite (0.1.1)
4
+ datacite (0.2.3)
5
5
  dry-monads (~> 1.3)
6
6
  faraday (~> 1.4)
7
7
  faraday_middleware (~> 1.0)
8
+ json_schema (~> 0.21.0)
8
9
  zeitwerk (~> 2.4)
9
10
 
10
11
  GEM
@@ -17,14 +18,12 @@ GEM
17
18
  crack (0.4.5)
18
19
  rexml
19
20
  diff-lcs (1.4.4)
20
- dry-core (0.7.0)
21
+ dry-core (0.7.1)
21
22
  concurrent-ruby (~> 1.0)
22
- dry-equalizer (0.3.0)
23
- dry-monads (1.3.5)
23
+ dry-monads (1.4.0)
24
24
  concurrent-ruby (~> 1.0)
25
- dry-core (~> 0.4, >= 0.4.4)
26
- dry-equalizer
27
- faraday (1.5.0)
25
+ dry-core (~> 0.7)
26
+ faraday (1.7.1)
28
27
  faraday-em_http (~> 1.0)
29
28
  faraday-em_synchrony (~> 1.0)
30
29
  faraday-excon (~> 1.1)
@@ -32,6 +31,7 @@ GEM
32
31
  faraday-net_http (~> 1.0)
33
32
  faraday-net_http_persistent (~> 1.1)
34
33
  faraday-patron (~> 1.0)
34
+ faraday-rack (~> 1.0)
35
35
  multipart-post (>= 1.2, < 3)
36
36
  ruby2_keywords (>= 0.0.4)
37
37
  faraday-em_http (1.0.0)
@@ -39,11 +39,13 @@ GEM
39
39
  faraday-excon (1.1.0)
40
40
  faraday-httpclient (1.0.1)
41
41
  faraday-net_http (1.0.1)
42
- faraday-net_http_persistent (1.1.0)
42
+ faraday-net_http_persistent (1.2.0)
43
43
  faraday-patron (1.0.0)
44
- faraday_middleware (1.0.0)
44
+ faraday-rack (1.0.0)
45
+ faraday_middleware (1.1.0)
45
46
  faraday (~> 1.0)
46
47
  hashdiff (1.0.1)
48
+ json_schema (0.21.0)
47
49
  multipart-post (2.1.1)
48
50
  parallel (1.20.1)
49
51
  parser (3.0.1.1)
@@ -83,7 +85,7 @@ GEM
83
85
  rubocop (~> 1.0)
84
86
  rubocop-ast (>= 1.1.0)
85
87
  ruby-progressbar (1.11.0)
86
- ruby2_keywords (0.0.4)
88
+ ruby2_keywords (0.0.5)
87
89
  unicode-display_width (2.0.0)
88
90
  webmock (3.13.0)
89
91
  addressable (>= 2.3.6)
data/README.md CHANGED
@@ -22,15 +22,65 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
+ ### Initialize the client
25
26
  ```ruby
26
- client = Datacite::Client.new(username: "foo", password: "bar")
27
- result = client.autogenerate_doi
27
+ client = Datacite::Client.new(username: "foo",
28
+ password: "bar",
29
+ host: "api.test.datacite.org")
30
+ ```
31
+
32
+ ### Create a Draft DOI
33
+
34
+ ```ruby
35
+ result = client.register_doi(prefix: '10.0001', suffix: 'bc123df4567')
36
+
28
37
  result.either(
29
38
  -> response { response.doi },
30
39
  -> response { raise("Something went wrong", response.status) }
31
40
  )
32
41
  ```
33
42
 
43
+ #### Auto-generated DOI's
44
+
45
+ ```ruby
46
+ result = client.autogenerate_doi(prefix: '10.0001')
47
+
48
+ result.either(
49
+ -> response { response.doi },
50
+ -> response { raise("Something went wrong", response.status) }
51
+ )
52
+ ```
53
+
54
+ ### Update DOI's
55
+
56
+ ```ruby
57
+ # See https://support.datacite.org/reference/dois-2#put_dois-id for the attributes
58
+ attributes = {
59
+ relatedIdentifiers: [
60
+ {
61
+ relatedIdentifier: "https://doi.org/10.xxxx/xxxxx",
62
+ relatedIdentifierType: "DOI",
63
+ relationType: "References",
64
+ resourceTypeGeneral: "Dataset"
65
+ }
66
+ ]
67
+ }
68
+ result = client.update(id: '10.0001/bc123df4567', attributes: attributes)
69
+
70
+ result.either(
71
+ -> response { response.doi },
72
+ -> response { raise("Something went wrong", response.status) }
73
+ )
74
+ ```
75
+
76
+ ### Validation
77
+ This gem validates using a json schema from https://github.com/datacite/schema/blob/master/source/json/kernel-4.3/datacite_4.3_schema.json
78
+
79
+ We've made the following changes:
80
+ * relax the required fields (https://github.com/datacite/schema/issues/97)
81
+ * add event property (https://github.com/datacite/schema/issues/100)
82
+ * add url property (https://github.com/datacite/schema/issues/101)
83
+
34
84
  ## Development
35
85
 
36
86
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/datacite.gemspec CHANGED
@@ -31,5 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "dry-monads", "~> 1.3"
32
32
  spec.add_dependency "faraday", "~> 1.4"
33
33
  spec.add_dependency "faraday_middleware", "~> 1.0"
34
+ spec.add_dependency "json_schema", "~> 0.21.0"
34
35
  spec.add_dependency "zeitwerk", "~> 2.4"
35
36
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Datacite
4
- # The JSON request to create a DOI
5
- class AutogenerateDoi
6
- # @param [Prefix] prefix
4
+ # The JSON request to create a random DOI
5
+ class AutogenerateDoiRequestBody
6
+ # @param [String] prefix
7
7
  def initialize(prefix:)
8
8
  @prefix = prefix
9
9
  end
@@ -3,6 +3,7 @@
3
3
  require "faraday"
4
4
  require "faraday_middleware"
5
5
  require "dry/monads"
6
+ require "json_schema"
6
7
 
7
8
  module Datacite
8
9
  # The connection to DataCite API
@@ -18,20 +19,52 @@ module Datacite
18
19
  headers: headers
19
20
  ) do |conn|
20
21
  conn.request :json
21
- conn.basic_auth(username, password)
22
+ conn.request(:basic_auth, username, password)
22
23
  conn.response :json
23
24
  end
24
25
  end
25
26
 
27
+ # Creates a random DOI
28
+ # @param [String] prefix
26
29
  # @returns [Dry::Monads::Result]
27
30
  def autogenerate_doi(prefix:)
28
- request_body = AutogenerateDoi.new(prefix: prefix).to_json
29
- response = conn.post("/dois", request_body)
31
+ request_body = AutogenerateDoiRequestBody.new(prefix: prefix).to_json
32
+ register(request_body)
33
+ end
34
+
35
+ # Creates a specific DOI
36
+ # @param [String] prefix
37
+ # @param [String] suffix
38
+ # @returns [Dry::Monads::Result]
39
+ def register_doi(prefix:, suffix:)
40
+ request_body = RegisterDoiRequestBody.new(prefix: prefix, suffix: suffix).to_json
41
+ register(request_body)
42
+ end
43
+
44
+ # Update a DOI
45
+ # @param [String] id
46
+ # @param [String] value
47
+ # @returns [Dry::Monads::Result]
48
+ def update(id:, attributes:)
49
+ Validator.validate!(attributes)
50
+ request_body = {
51
+ data: {
52
+ attributes: attributes
53
+ }
54
+ }
55
+
56
+ response = conn.put("/dois/#{id}", request_body.to_json)
30
57
  response.success? ? Success(Response.new(response)) : Failure(response)
31
58
  end
32
59
 
33
60
  private
34
61
 
62
+ # @returns [Dry::Monads::Result]
63
+ def register(request_body)
64
+ response = conn.post("/dois", request_body)
65
+ response.success? ? Success(Response.new(response)) : Failure(response)
66
+ end
67
+
35
68
  def headers
36
69
  {
37
70
  "Content-Type" => "application/vnd.api+json",
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datacite
4
+ # The JSON request to create a specific DOI
5
+ class RegisterDoiRequestBody
6
+ # @param [String] prefix
7
+ # @param [String] suffix
8
+ def initialize(prefix:, suffix:)
9
+ @prefix = prefix
10
+ @suffix = suffix
11
+ end
12
+
13
+ # @returns [Hash]
14
+ def to_json(*_args)
15
+ {
16
+ data: {
17
+ type: "dois",
18
+ attributes: {
19
+ doi: "#{prefix}/#{suffix}"
20
+ }
21
+ }
22
+ }
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :prefix, :suffix
28
+ end
29
+ end
@@ -0,0 +1,481 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+
4
+ "definitions": {
5
+ "nameType": {
6
+ "type": "string",
7
+ "enum": [
8
+ "Organizational",
9
+ "Personal"
10
+ ]
11
+ },
12
+ "nameIdentifiers": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object",
16
+ "properties": {
17
+ "nameIdentifier": {"type": "string"},
18
+ "nameIdentifierScheme": {"type": "string"},
19
+ "schemeURI": {"type": "string", "format": "uri"}
20
+ },
21
+ "required": ["nameIdentifier", "nameIdentifierScheme"]
22
+ },
23
+ "uniqueItems": true
24
+ },
25
+ "affiliations": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "object",
29
+ "properties": {
30
+ "affiliation": {"type": "string"}
31
+ },
32
+ "required": ["affiliation"]
33
+ },
34
+ "uniqueItems": true
35
+ },
36
+ "titleType": {
37
+ "type": "string",
38
+ "enum": [
39
+ "AlternativeTitle",
40
+ "Subtitle",
41
+ "TranslatedTitle",
42
+ "Other"
43
+ ]
44
+ },
45
+ "contributorType": {
46
+ "type": "string",
47
+ "enum": [
48
+ "ContactPerson",
49
+ "DataCollector",
50
+ "DataCurator",
51
+ "DataManager",
52
+ "Distributor",
53
+ "Editor",
54
+ "HostingInstitution",
55
+ "Producer",
56
+ "ProjectLeader",
57
+ "ProjectManager",
58
+ "ProjectMember",
59
+ "RegistrationAgency",
60
+ "RegistrationAuthority",
61
+ "RelatedPerson",
62
+ "Researcher",
63
+ "ResearchGroup",
64
+ "RightsHolder",
65
+ "Sponsor",
66
+ "Supervisor",
67
+ "WorkPackageLeader",
68
+ "Other"
69
+ ]
70
+ },
71
+ "date": {
72
+ "type": "string",
73
+ "anyOf": [
74
+ {"format": "date"},
75
+ {"format": "date-time"}
76
+ ]
77
+ },
78
+ "dateType": {
79
+ "type": "string",
80
+ "enum": [
81
+ "Accepted",
82
+ "Available",
83
+ "Copyrighted",
84
+ "Collected",
85
+ "Created",
86
+ "Issued",
87
+ "Submitted",
88
+ "Updated",
89
+ "Valid",
90
+ "Withdrawn",
91
+ "Other"
92
+ ]
93
+ },
94
+ "resourceTypeGeneral": {
95
+ "type": "string",
96
+ "enum": [
97
+ "Audiovisual",
98
+ "Collection",
99
+ "DataPaper",
100
+ "Dataset",
101
+ "Event",
102
+ "Image",
103
+ "InteractiveResource",
104
+ "Model",
105
+ "PhysicalObject",
106
+ "Service",
107
+ "Software",
108
+ "Sound",
109
+ "Text",
110
+ "Workflow",
111
+ "Other"
112
+ ]
113
+ },
114
+ "relatedIdentifierType": {
115
+ "type": "string",
116
+ "enum": [
117
+ "ARK",
118
+ "arXiv",
119
+ "bibcode",
120
+ "DOI",
121
+ "EAN13",
122
+ "EISSN",
123
+ "Handle",
124
+ "IGSN",
125
+ "ISBN",
126
+ "ISSN",
127
+ "ISTC",
128
+ "LISSN",
129
+ "LSID",
130
+ "PMID",
131
+ "PURL",
132
+ "UPC",
133
+ "URL",
134
+ "URN",
135
+ "w3id"
136
+ ]
137
+ },
138
+ "relationType": {
139
+ "type": "string",
140
+ "enum": [
141
+ "IsCitedBy",
142
+ "Cites",
143
+ "IsSupplementTo",
144
+ "IsSupplementedBy",
145
+ "IsContinuedBy",
146
+ "Continues",
147
+ "IsDescribedBy",
148
+ "Describes",
149
+ "HasMetadata",
150
+ "IsMetadataFor",
151
+ "HasVersion",
152
+ "IsVersionOf",
153
+ "IsNewVersionOf",
154
+ "IsPreviousVersionOf",
155
+ "IsPartOf",
156
+ "HasPart",
157
+ "IsReferencedBy",
158
+ "References",
159
+ "IsDocumentedBy",
160
+ "Documents",
161
+ "IsCompiledBy",
162
+ "Compiles",
163
+ "IsVariantFormOf",
164
+ "IsOriginalFormOf",
165
+ "IsIdenticalTo",
166
+ "IsReviewedBy",
167
+ "Reviews",
168
+ "IsDerivedFrom",
169
+ "IsSourceOf",
170
+ "IsRequiredBy",
171
+ "Requires",
172
+ "IsObsoletedBy",
173
+ "Obsoletes"
174
+ ]
175
+ },
176
+ "descriptionType": {
177
+ "type": "string",
178
+ "enum": [
179
+ "Abstract",
180
+ "Methods",
181
+ "SeriesInformation",
182
+ "TableOfContents",
183
+ "TechnicalInfo",
184
+ "Other"
185
+ ]
186
+ },
187
+ "geoLocationPoint": {
188
+ "type": "object",
189
+ "properties": {
190
+ "pointLongitude": {"$ref": "#/definitions/longitude"},
191
+ "pointLatitude": {"$ref": "#/definitions/latitude"}
192
+ },
193
+ "required": ["pointLongitude", "pointLatitude"]
194
+ },
195
+ "longitude": {
196
+ "type": "number",
197
+ "minimum": -180,
198
+ "maximum": 180
199
+ },
200
+ "latitude": {
201
+ "type": "number",
202
+ "minimum": -90,
203
+ "maximum": 90
204
+ },
205
+ "funderIdentifierType": {
206
+ "type": "string",
207
+ "enum": [
208
+ "ISNI",
209
+ "GRID",
210
+ "Crossref Funder ID",
211
+ "Other"
212
+ ]
213
+ }
214
+ },
215
+
216
+ "type": "object",
217
+
218
+ "properties": {
219
+ "event": {
220
+ "type": "string",
221
+ "enum": ["publish", "register", "hide"]
222
+ },
223
+ "url": {
224
+ "type": "string"
225
+ },
226
+ "types": {
227
+ "type": "object",
228
+ "properties": {
229
+ "resourceType": {"type": "string"},
230
+ "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"}
231
+ },
232
+ "required": ["resourceType", "resourceTypeGeneral"]
233
+ },
234
+ "identifiers": {
235
+ "type": "array",
236
+ "items":{
237
+ "type": "object",
238
+ "properties": {
239
+ "identifier": {"type": "string"},
240
+ "identifierType": {"type": "string"}
241
+ },
242
+ "required": ["identifier", "identifierType"]
243
+ },
244
+ "minItems": 1,
245
+ "uniqueItems": true
246
+ },
247
+ "creators": {
248
+ "type": "array",
249
+ "items": {
250
+ "type": "object",
251
+ "properties": {
252
+ "name": {"type": "string"},
253
+ "nameType": {"$ref": "#/definitions/nameType"},
254
+ "givenName": {"type": "string"},
255
+ "familyName": {"type": "string"},
256
+ "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"},
257
+ "affiliations": {"$ref": "#/definitions/affiliations"},
258
+ "lang": {"type": "string"}
259
+ },
260
+ "required": ["name"]
261
+ },
262
+ "minItems": 1,
263
+ "uniqueItems": true
264
+ },
265
+ "titles": {
266
+ "type": "array",
267
+ "items": {
268
+ "type": "object",
269
+ "properties": {
270
+ "title": {"type": "string"},
271
+ "titleType": {"$ref": "#/definitions/titleType"},
272
+ "lang": {"type": "string"}
273
+ },
274
+ "required": ["title"]
275
+ },
276
+ "minItems": 1,
277
+ "uniqueItems": true
278
+ },
279
+ "publisher": {
280
+ "type": "string"
281
+ },
282
+ "publicationYear": {
283
+ "type": "string"
284
+ },
285
+ "subjects": {
286
+ "type": "array",
287
+ "items": {
288
+ "type": "object",
289
+ "properties": {
290
+ "subject": {"type": "string"},
291
+ "subjectScheme": {"type": "string"},
292
+ "schemeURI": {"type": "string", "format": "uri"},
293
+ "valueURI": {"type": "string", "format": "uri"},
294
+ "lang": {"type": "string"}
295
+ },
296
+ "required": ["subject"]
297
+ },
298
+ "uniqueItems": true
299
+ },
300
+ "contributors": {
301
+ "type": "array",
302
+ "items": {
303
+ "type": "object",
304
+ "properties": {
305
+ "contributorType": {"$ref": "#/definitions/contributorType"},
306
+ "name": {"type": "string"},
307
+ "nameType": {"$ref": "#/definitions/nameType"},
308
+ "givenName": {"type": "string"},
309
+ "familyName": {"type": "string"},
310
+ "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"},
311
+ "affiliations": {"$ref": "#/definitions/affiliations"},
312
+ "lang": {"type": "string"}
313
+ },
314
+ "required": ["contributorType", "name"]
315
+ },
316
+ "uniqueItems": true
317
+ },
318
+ "dates": {
319
+ "type": "array",
320
+ "items": {
321
+ "type": "object",
322
+ "properties": {
323
+ "date": {"$ref": "#/definitions/date"},
324
+ "dateType": {"$ref": "#/definitions/dateType"},
325
+ "dateInformation": {"type": "string"}
326
+ },
327
+ "required": ["date", "dateType"]
328
+ },
329
+ "uniqueItems": true
330
+ },
331
+ "language": {
332
+ "type": "string",
333
+ "$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes."
334
+ },
335
+ "alternateIdentifiers": {
336
+ "type": "array",
337
+ "items": {
338
+ "type": "object",
339
+ "properties": {
340
+ "alternateIdentifier": {"type": "string"},
341
+ "alternateIdentifierType": {"type": "string"}
342
+ },
343
+ "required": ["alternateIdentifier", "alternateIdentifierType"]
344
+ },
345
+ "uniqueItems": true
346
+ },
347
+ "relatedIdentifiers": {
348
+ "type": "array",
349
+ "items": {
350
+ "type": "object",
351
+ "properties": {
352
+ "relatedIdentifier": {"type": "string"},
353
+ "relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"},
354
+ "relationType": {"$ref": "#/definitions/relationType"},
355
+ "relatedMetadataScheme": {"type": "string"},
356
+ "schemeURI": {"type": "string", "format": "uri"},
357
+ "schemeType": {"type": "string"},
358
+ "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"}
359
+ },
360
+ "required": ["relatedIdentifier", "relatedIdentifierType", "relationType"],
361
+ "if": {
362
+ "properties": {
363
+ "relationType": {"enum": ["HasMetadata", "IsMetadataFor"]}
364
+ }
365
+ },
366
+ "else": {
367
+ "$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor",
368
+ "properties": {
369
+ "relatedMetadataScheme": false,
370
+ "schemeURI": false,
371
+ "schemeType": false
372
+ }
373
+ }
374
+ },
375
+ "uniqueItems": true
376
+ },
377
+ "sizes": {
378
+ "type": "array",
379
+ "items": {
380
+ "type": "string"
381
+ },
382
+ "uniqueItems": true
383
+ },
384
+ "formats": {
385
+ "type": "array",
386
+ "items": {
387
+ "type": "string"
388
+ },
389
+ "uniqueItems": true
390
+ },
391
+ "version": {
392
+ "type": "string"
393
+ },
394
+ "rightsList": {
395
+ "type": "array",
396
+ "items": {
397
+ "type": "object",
398
+ "properties": {
399
+ "rights": {"type": "string"},
400
+ "rightsURI": {"type": "string", "format": "uri"},
401
+ "rightsIdentifier": {"type": "string"},
402
+ "rightsIdentifierScheme": {"type": "string"},
403
+ "schemeURI": {"type": "string", "format": "uri"},
404
+ "lang": {"type": "string"}
405
+ }
406
+ },
407
+ "uniqueItems": true
408
+ },
409
+ "descriptions": {
410
+ "type": "array",
411
+ "items": {
412
+ "type": "object",
413
+ "properties": {
414
+ "description": {"type": "string"},
415
+ "descriptionType": {"$ref": "#/definitions/descriptionType"},
416
+ "lang": {"type": "string"}
417
+ },
418
+ "required": ["description", "descriptionType"]
419
+ },
420
+ "uniqueItems": true
421
+ },
422
+ "geoLocations": {
423
+ "type": "array",
424
+ "items": {
425
+ "type": "object",
426
+ "properties": {
427
+ "geoLocationPlace": {"type": "string"},
428
+ "geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"},
429
+ "geoLocationBox": {
430
+ "type": "object",
431
+ "properties": {
432
+ "westBoundLongitude": {"$ref": "#/definitions/longitude"},
433
+ "eastBoundLongitude": {"$ref": "#/definitions/longitude"},
434
+ "southBoundLatitude": {"$ref": "#/definitions/latitude"},
435
+ "northBoundLatitude": {"$ref": "#/definitions/latitude"}
436
+ },
437
+ "required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"]
438
+ },
439
+ "geoLocationPolygons": {
440
+ "type": "array",
441
+ "items": {
442
+ "type": "object",
443
+ "properties": {
444
+ "polygonPoints": {
445
+ "type": "array",
446
+ "items": {"$ref": "#/definitions/geoLocationPoint"},
447
+ "minItems": 4
448
+ },
449
+ "inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"}
450
+ },
451
+ "required": ["polygonPoints"]
452
+ },
453
+ "uniqueItems": true
454
+ }
455
+ }
456
+ },
457
+ "uniqueItems": true
458
+ },
459
+ "fundingReferences": {
460
+ "type": "array",
461
+ "items": {
462
+ "type": "object",
463
+ "properties": {
464
+ "funderName": {"type": "string"},
465
+ "funderIdentifier": {"type": "string"},
466
+ "funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"},
467
+ "awardNumber": {"type": "string"},
468
+ "awardURI": {"type": "string", "format": "uri"},
469
+ "awardTitle": {"type": "string"}
470
+ },
471
+ "required": ["funderName"]
472
+ },
473
+ "uniqueItems": true
474
+ },
475
+ "schemaVersion": {
476
+ "type": "string",
477
+ "const": "http://datacite.org/schema/kernel-4"
478
+ }
479
+ },
480
+ "additionalProperties": false
481
+ }
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json_schema"
4
+
5
+ module Datacite
6
+ # Validates the request data is valid
7
+ class Validator
8
+ def self.validate!(data)
9
+ # Schema from https://github.com/datacite/schema/blob/master/source/json/kernel-4.3/datacite_4.3_schema.json
10
+ # with changes:
11
+ # 1. Remove invalid formats https://github.com/datacite/schema/issues/96
12
+ # 2. Remove required fields https://github.com/datacite/schema/issues/97
13
+ # 3. Added "additionalProperties": false
14
+
15
+ schema_data = JSON.parse(File.read("#{__dir__}/schema.json"))
16
+ schema = JsonSchema.parse!(schema_data)
17
+ schema.validate!(data)
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Datacite
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datacite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json_schema
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.21.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.21.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: zeitwerk
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +87,7 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".github/pull_request_template.md"
76
91
  - ".github/workflows/main.yml"
77
92
  - ".gitignore"
78
93
  - ".rspec"
@@ -85,9 +100,12 @@ files:
85
100
  - bin/setup
86
101
  - datacite.gemspec
87
102
  - lib/datacite.rb
88
- - lib/datacite/autogenerate_doi.rb
103
+ - lib/datacite/autogenerate_doi_request_body.rb
89
104
  - lib/datacite/client.rb
105
+ - lib/datacite/register_doi_request_body.rb
90
106
  - lib/datacite/response.rb
107
+ - lib/datacite/schema.json
108
+ - lib/datacite/validator.rb
91
109
  - lib/datacite/version.rb
92
110
  homepage: https://github.com/sul-dlss/datacite-ruby
93
111
  licenses: []