bolognese 2.1.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/.github/workflows/release.yml +2 -2
  4. data/Gemfile.lock +9 -9
  5. data/bolognese.gemspec +3 -3
  6. data/lib/bolognese/metadata_utils.rb +1 -0
  7. data/lib/bolognese/readers/citeproc_reader.rb +6 -0
  8. data/lib/bolognese/readers/crossref_reader.rb +37 -3
  9. data/lib/bolognese/readers/schema_org_reader.rb +21 -2
  10. data/lib/bolognese/utils.rb +12 -7
  11. data/lib/bolognese/version.rb +1 -1
  12. data/lib/bolognese/writers/schema_org_writer.rb +4 -0
  13. data/resources/kernel-4/include/datacite-contributorType-v4.xsd +3 -1
  14. data/resources/kernel-4/include/datacite-dateType-v4.xsd +3 -1
  15. data/resources/kernel-4/include/datacite-relatedIdentifierType-v4.xsd +5 -2
  16. data/resources/kernel-4/include/datacite-relationType-v4.xsd +7 -3
  17. data/resources/kernel-4/include/datacite-resourceType-v4.xsd +5 -1
  18. data/resources/kernel-4/include/datacite-titleType-v4.xsd +1 -1
  19. data/resources/kernel-4/metadata.xsd +2 -1
  20. data/resources/kernel-4.6/include/datacite-contributorType-v4.xsd +37 -0
  21. data/resources/kernel-4.6/include/datacite-dateType-v4.xsd +27 -0
  22. data/resources/kernel-4.6/include/datacite-descriptionType-v4.xsd +19 -0
  23. data/resources/kernel-4.6/include/datacite-funderIdentifierType-v4.xsd +16 -0
  24. data/resources/kernel-4.6/include/datacite-nameType-v4.xsd +10 -0
  25. data/resources/kernel-4.6/include/datacite-numberType-v4.xsd +12 -0
  26. data/resources/kernel-4.6/include/datacite-relatedIdentifierType-v4.xsd +37 -0
  27. data/resources/kernel-4.6/include/datacite-relationType-v4.xsd +57 -0
  28. data/resources/kernel-4.6/include/datacite-resourceType-v4.xsd +49 -0
  29. data/resources/kernel-4.6/include/datacite-titleType-v4.xsd +14 -0
  30. data/resources/kernel-4.6/include/xml.xsd +286 -0
  31. data/resources/kernel-4.6/metadata.xsd +712 -0
  32. data/spec/datacite_utils_spec.rb +109 -1
  33. data/spec/fixtures/citeproc.json +6 -2
  34. data/spec/fixtures/crossref.xml +18 -0
  35. data/spec/fixtures/crossref_schema_4.6_values.xml +174 -0
  36. data/spec/fixtures/datacite-example-full-v4.6.xml +114 -0
  37. data/spec/fixtures/schema_org_4.6_attributes.json +108 -0
  38. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors_Translator/supports_Translator_contributorType.yml +71 -0
  39. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates_with_Coverage/inserts_date_with_dateType_Coverage.yml +71 -0
  40. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_CSTR/supports_CSTR_relatedIdentifierType.yml +71 -0
  41. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_HasTranslation/supports_HasTranslation_relationType.yml +71 -0
  42. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_RRID/supports_RRID_relatedIdentifierType.yml +71 -0
  43. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type_with_Award/supports_Award_as_resourceTypeGeneral.yml +71 -0
  44. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type_with_Project/supports_Project_as_resourceTypeGeneral.yml +71 -0
  45. data/spec/readers/citeproc_reader_spec.rb +1 -0
  46. data/spec/readers/crossref_reader_spec.rb +31 -0
  47. data/spec/readers/datacite_reader_spec.rb +41 -0
  48. data/spec/readers/schema_org_reader_spec.rb +27 -0
  49. data/spec/writers/citeproc_writer_spec.rb +9 -0
  50. data/spec/writers/datacite_writer_spec.rb +71 -0
  51. data/spec/writers/jats_writer_spec.rb +1 -1
  52. data/spec/writers/schema_org_writer_spec.rb +36 -0
  53. metadata +38 -22
@@ -340,5 +340,32 @@ describe Bolognese::Metadata, vcr: true do
340
340
  "funderIdentifierType"=>"Crossref Funder ID",
341
341
  "funderName"=>"European Commission"}])
342
342
  end
343
+
344
+ it "Schema 4.6 attributes" do
345
+ input = fixture_path + 'schema_org_4.6_attributes.json'
346
+ subject = Bolognese::Metadata.new(input: input)
347
+
348
+ expect(subject.related_identifiers).to eq(
349
+ [
350
+ {"relatedIdentifier"=>"10.1234/translated-version", "relatedIdentifierType"=>"DOI", "relationType"=>"HasTranslation"},
351
+ {"relatedIdentifier"=>"10.1234/other-version", "relatedIdentifierType"=>"DOI", "relationType"=>"IsTranslationOf"},
352
+ ]
353
+ )
354
+ expect(subject.dates).to eq(
355
+ [
356
+ {"date"=>"2023-01-01", "dateType"=>"Issued"},
357
+ {"date"=>"2023-01-01", "dateType"=>"Created"},
358
+ {"date"=>"2023-01-01", "dateType"=>"Updated"},
359
+ {"date"=>"2020-01-01", "dateType"=>"Coverage"}
360
+ ]
361
+ )
362
+ expect(subject.contributors).to eq(
363
+ [
364
+ {"name"=>"Doe, Jane", "givenName"=>"Jane", "familyName"=>"Doe", "nameType"=>"Personal", "affiliation"=>[{"name"=>"ExampleAffiliation", "affiliationIdentifier"=>"https://ror.org/04wxnsj81", "affiliationIdentifierScheme"=>"ROR"}], "nameIdentifiers"=>[{"nameIdentifier"=>"https://orcid.org/0000-0003-1419-2405", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}]},
365
+ {"name"=>"Smith, John", "givenName"=>"John", "familyName"=>"Smith", "nameType"=>"Personal", "affiliation"=>[{"name"=>"ExampleAffiliation", "affiliationIdentifier"=>"https://ror.org/04wxnsj81", "affiliationIdentifierScheme"=>"ROR"}]},
366
+ {"name"=>"Ross, Cody", "givenName"=>"Cody", "familyName"=>"Ross", "nameType"=>"Personal", "affiliation"=>[{"name"=>"ExampleAffiliation", "affiliationIdentifier"=>"https://ror.org/04wxnsj81", "affiliationIdentifierScheme"=>"ROR"}], "nameIdentifiers"=>[{"nameIdentifier"=>"https://orcid.org/0000-0003-1419-2405", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}], "contributorType"=>"Translator"},
367
+ ]
368
+ )
369
+ end
343
370
  end
344
371
  end
@@ -286,5 +286,14 @@ describe Bolognese::Metadata, vcr: true do
286
286
  expect(json["DOI"]).to eq("10.34747/g6yb-3412")
287
287
  expect(json["issued"]).to eq("date-parts"=>[[2019]])
288
288
  end
289
+
290
+ it "from Schema 4.6 with Translator contributor" do
291
+ input = fixture_path + 'datacite-example-full-v4.6.xml'
292
+ subject = Bolognese::Metadata.new(input: input)
293
+ json = JSON.parse(subject.citeproc)
294
+ expect(json["translator"]).to eq([
295
+ {"family"=>"Doe", "given"=>"Jane"},
296
+ ])
297
+ end
289
298
  end
290
299
  end
@@ -286,6 +286,77 @@ describe Bolognese::Metadata, vcr: true do
286
286
  )
287
287
  end
288
288
 
289
+ it "Schema 4.6" do
290
+ input = fixture_path + 'datacite-example-full-v4.6.xml'
291
+ doi = "10.82433/B09Z-4K37"
292
+ subject = Bolognese::Metadata.new(input: input, from: "datacite", regenerate: true)
293
+ expect(subject.valid?).to be true
294
+
295
+ datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
296
+ expect(datacite.fetch("xsi:schemaLocation", "").split(" ").first).to eq("http://datacite.org/schema/kernel-4")
297
+ expect(datacite.dig("contributors", "contributor").count).to eq(2)
298
+ expect(datacite.dig("contributors", "contributor")).to include(
299
+ {
300
+ "contributorType"=>"Translator",
301
+ "contributorName"=>{
302
+ "nameType"=>"Personal",
303
+ "__content__"=>"Doe, Jane"
304
+ },
305
+ "givenName"=>"Jane",
306
+ "familyName"=>"Doe",
307
+ "nameIdentifier"=>{
308
+ "nameIdentifierScheme"=>"ORCID",
309
+ "schemeURI"=>"https://orcid.org",
310
+ "__content__"=>"https://orcid.org/0000-0003-1419-2405"
311
+ },
312
+ "affiliation"=>{
313
+ "affiliationIdentifier"=>"https://ror.org/04wxnsj81",
314
+ "affiliationIdentifierScheme"=>"ROR",
315
+ "schemeURI"=>"https://ror.org",
316
+ "__content__"=>"ExampleAffiliation"
317
+ }
318
+ }
319
+ )
320
+ expect(datacite.dig("dates", "date").count).to eq(5)
321
+ expect(datacite.dig("dates", "date")).to include(
322
+ {
323
+ "dateType"=>"Coverage",
324
+ "__content__"=>"2020-01-01"
325
+ }
326
+ )
327
+ expect(datacite.dig("resourceType")).to eq(
328
+ {
329
+ "__content__"=>"Research Project",
330
+ "resourceTypeGeneral"=>"Project"
331
+ }
332
+ )
333
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(4)
334
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")).to eq(
335
+ [
336
+ {
337
+ "relatedIdentifierType"=>"RRID",
338
+ "relationType"=>"References",
339
+ "__content__"=>"RRID:AB_90755"
340
+ },
341
+ {
342
+ "relatedIdentifierType"=>"CSTR",
343
+ "relationType"=>"References",
344
+ "__content__"=>"CSTR:AB_12345"
345
+ },
346
+ {
347
+ "relatedIdentifierType"=>"DOI",
348
+ "relationType"=>"HasTranslation",
349
+ "__content__"=>"10.1234/translated-version"
350
+ },
351
+ {
352
+ "relatedIdentifierType"=>"DOI",
353
+ "relationType"=>"IsTranslationOf",
354
+ "__content__"=>"10.1234/other-version"
355
+ }
356
+ ]
357
+ )
358
+ end
359
+
289
360
  it "Geolocations" do
290
361
  input = fixture_path + 'datacite-example-full-v4.5.xml'
291
362
  doi = "10.82433/B09Z-4K37"
@@ -87,7 +87,7 @@ describe Bolognese::Metadata, vcr: true do
87
87
  expect(jats.dig("publication_type")).to be_nil
88
88
  expect(jats.dig("source")).to eq("Eating your own Dog Food")
89
89
  expect(jats.dig("publisher_name")).to eq("DataCite")
90
- expect(jats.dig("person_group", "name")).to eq("surname"=>"Fenner", "given_names"=>"Martin")
90
+ expect(jats.dig("person_group", 0, "name")).to eq("surname"=>"Fenner", "given_names"=>"Martin")
91
91
  expect(jats.dig("year")).to eq("iso_8601_date"=>"2016-12-20", "__content__"=>"2016")
92
92
  expect(jats.dig("month")).to eq("12")
93
93
  expect(jats.dig("day")).to eq("20")
@@ -378,5 +378,41 @@ describe Bolognese::Metadata, vcr: true do
378
378
  }
379
379
  )
380
380
  end
381
+
382
+ it "from Schema 4.6 with Translator contributor, workTranslation, translationOfWork, and temporalCoverage" do
383
+ input = fixture_path + 'datacite-example-full-v4.6.xml'
384
+ subject = Bolognese::Metadata.new(input: input)
385
+ json = JSON.parse(subject.schema_org)
386
+
387
+ expect(json["@type"]).to eq(
388
+ "Project"
389
+ )
390
+ expect(json["translator"]).to eq(
391
+ {
392
+ "name" => "Jane Doe",
393
+ "givenName" => "Jane",
394
+ "familyName" => "Doe",
395
+ "affiliation" => {
396
+ "@type" => "Organization",
397
+ "@id" => "https://ror.org/04wxnsj81",
398
+ "name" => "ExampleAffiliation"
399
+ },
400
+ "contributorType" => "Translator",
401
+ "@type" => "Person",
402
+ "@id" => "https://orcid.org/0000-0003-1419-2405"
403
+ }
404
+ )
405
+ expect(json["workTranslation"]).to eq(
406
+ "@id" => "https://doi.org/10.1234/translated-version",
407
+ "@type" => "CreativeWork"
408
+ )
409
+ expect(json["translationOfWork"]).to eq(
410
+ "@id" => "https://doi.org/10.1234/other-version",
411
+ "@type" => "CreativeWork"
412
+ )
413
+ expect(json["temporalCoverage"]).to eq(
414
+ "2020-01-01"
415
+ )
416
+ end
381
417
  end
382
418
  end
metadata CHANGED
@@ -1,55 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-26 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.9.4
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '5'
19
+ version: '5.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 4.9.4
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '5'
26
+ version: '5.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: nokogiri
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
31
+ - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 1.13.2
40
- - - "<"
33
+ version: '1.16'
34
+ - - ">="
41
35
  - !ruby/object:Gem::Version
42
- version: '1.14'
36
+ version: 1.16.2
43
37
  type: :runtime
44
38
  prerelease: false
45
39
  version_requirements: !ruby/object:Gem::Requirement
46
40
  requirements:
47
- - - ">="
41
+ - - "~>"
48
42
  - !ruby/object:Gem::Version
49
- version: 1.13.2
50
- - - "<"
43
+ version: '1.16'
44
+ - - ">="
51
45
  - !ruby/object:Gem::Version
52
- version: '1.14'
46
+ version: 1.16.2
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: loofah
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -760,6 +754,18 @@ files:
760
754
  - resources/kernel-4.5/include/datacite-titleType-v4.xsd
761
755
  - resources/kernel-4.5/include/xml.xsd
762
756
  - resources/kernel-4.5/metadata.xsd
757
+ - resources/kernel-4.6/include/datacite-contributorType-v4.xsd
758
+ - resources/kernel-4.6/include/datacite-dateType-v4.xsd
759
+ - resources/kernel-4.6/include/datacite-descriptionType-v4.xsd
760
+ - resources/kernel-4.6/include/datacite-funderIdentifierType-v4.xsd
761
+ - resources/kernel-4.6/include/datacite-nameType-v4.xsd
762
+ - resources/kernel-4.6/include/datacite-numberType-v4.xsd
763
+ - resources/kernel-4.6/include/datacite-relatedIdentifierType-v4.xsd
764
+ - resources/kernel-4.6/include/datacite-relationType-v4.xsd
765
+ - resources/kernel-4.6/include/datacite-resourceType-v4.xsd
766
+ - resources/kernel-4.6/include/datacite-titleType-v4.xsd
767
+ - resources/kernel-4.6/include/xml.xsd
768
+ - resources/kernel-4.6/metadata.xsd
763
769
  - resources/kernel-4/include/datacite-contributorType-v4.xsd
764
770
  - resources/kernel-4/include/datacite-dateType-v4.xsd
765
771
  - resources/kernel-4/include/datacite-descriptionType-v4.xsd
@@ -796,6 +802,7 @@ files:
796
802
  - spec/fixtures/crossref.bib
797
803
  - spec/fixtures/crossref.ris
798
804
  - spec/fixtures/crossref.xml
805
+ - spec/fixtures/crossref_schema_4.6_values.xml
799
806
  - spec/fixtures/datacite-empty-sizes.xml
800
807
  - spec/fixtures/datacite-example-ROR-nameIdentifiers.xml
801
808
  - spec/fixtures/datacite-example-affiliation.xml
@@ -808,6 +815,7 @@ files:
808
815
  - spec/fixtures/datacite-example-escaped-text.xml
809
816
  - spec/fixtures/datacite-example-full-v4.4.xml
810
817
  - spec/fixtures/datacite-example-full-v4.5.xml
818
+ - spec/fixtures/datacite-example-full-v4.6.xml
811
819
  - spec/fixtures/datacite-example-geolocation-2.xml
812
820
  - spec/fixtures/datacite-example-geolocation.xml
813
821
  - spec/fixtures/datacite-example-nameIdentifier-with-schemeURI.xml
@@ -851,6 +859,7 @@ files:
851
859
  - spec/fixtures/ris_bug.ris
852
860
  - spec/fixtures/schema_4.0.xml
853
861
  - spec/fixtures/schema_org.json
862
+ - spec/fixtures/schema_org_4.6_attributes.json
854
863
  - spec/fixtures/schema_org_geolocation.json
855
864
  - spec/fixtures/schema_org_geoshape.json
856
865
  - spec/fixtures/schema_org_gtex.json
@@ -1070,8 +1079,10 @@ files:
1070
1079
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml
1071
1080
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/handle_input/unknown_DOI_prefix.yml
1072
1081
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml
1082
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors_Translator/supports_Translator_contributorType.yml
1073
1083
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml
1074
1084
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml
1085
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates_with_Coverage/inserts_date_with_dateType_Coverage.yml
1075
1086
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_descriptions/insert.yml
1076
1087
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_identifier/doi.yml
1077
1088
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_language/insert.yml
@@ -1080,8 +1091,13 @@ files:
1080
1091
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publisher/insert.yml
1081
1092
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/insert.yml
1082
1093
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/related_identifier.yml
1094
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_CSTR/supports_CSTR_relatedIdentifierType.yml
1095
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_HasTranslation/supports_HasTranslation_relationType.yml
1096
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers_RRID/supports_RRID_relatedIdentifierType.yml
1083
1097
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_items/insert.yml
1084
1098
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type/insert.yml
1099
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type_with_Award/supports_Award_as_resourceTypeGeneral.yml
1100
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type_with_Project/supports_Project_as_resourceTypeGeneral.yml
1085
1101
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_rights_list/insert.yml
1086
1102
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_sizes/insert.yml
1087
1103
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_subjects/insert.yml
@@ -1322,14 +1338,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
1322
1338
  requirements:
1323
1339
  - - ">="
1324
1340
  - !ruby/object:Gem::Version
1325
- version: '2.3'
1341
+ version: '3.0'
1326
1342
  required_rubygems_version: !ruby/object:Gem::Requirement
1327
1343
  requirements:
1328
1344
  - - ">="
1329
1345
  - !ruby/object:Gem::Version
1330
1346
  version: '0'
1331
1347
  requirements: []
1332
- rubygems_version: 3.0.3.1
1348
+ rubygems_version: 3.3.26
1333
1349
  signing_key:
1334
1350
  specification_version: 4
1335
1351
  summary: Ruby client library for conversion of DOI Metadata