bolognese 1.5.17 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +17 -14
  4. data/lib/bolognese/datacite_utils.rb +20 -2
  5. data/lib/bolognese/metadata.rb +2 -2
  6. data/lib/bolognese/readers/citeproc_reader.rb +4 -2
  7. data/lib/bolognese/readers/codemeta_reader.rb +4 -2
  8. data/lib/bolognese/readers/datacite_reader.rb +18 -13
  9. data/lib/bolognese/readers/ris_reader.rb +4 -2
  10. data/lib/bolognese/readers/schema_org_reader.rb +7 -2
  11. data/lib/bolognese/utils.rb +95 -0
  12. data/lib/bolognese/version.rb +1 -1
  13. data/resources/oecd/for-mappings.json +1101 -0
  14. data/resources/oecd/fos-mappings.json +198 -0
  15. data/spec/datacite_utils_spec.rb +27 -7
  16. data/spec/fixtures/datacite-funderIdentifier.xml +4 -0
  17. data/spec/fixtures/datacite_software_version.json +74 -0
  18. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_for_match.yml +44 -0
  19. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_match.yml +44 -0
  20. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_no_match.yml +44 -0
  21. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_for_match.yml +44 -0
  22. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_match.yml +44 -0
  23. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_no_match.yml +44 -0
  24. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/even_more_subject_scheme_FOR.yml +97 -0
  25. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/more_subject_scheme_FOR.yml +107 -0
  26. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/subject_scheme_FOR.yml +110 -0
  27. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml +49 -0
  28. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_formats/insert.yml +49 -0
  29. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_given_and_family_name.yml +49 -0
  30. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_sizes/insert.yml +49 -0
  31. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/software.yml +9 -9
  32. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/software_w/version.yml +52 -0
  33. data/spec/readers/datacite_reader_spec.rb +101 -1
  34. data/spec/readers/schema_org_reader_spec.rb +15 -1
  35. data/spec/utils_spec.rb +50 -0
  36. data/spec/writers/citeproc_writer_spec.rb +18 -0
  37. data/spec/writers/datacite_writer_spec.rb +8 -0
  38. data/spec/writers/schema_org_writer_spec.rb +2 -0
  39. metadata +19 -2
@@ -78,6 +78,18 @@ describe Bolognese::Metadata, vcr: true do
78
78
  "nameType" => "Personal", "givenName"=>"Matthias", "familyName"=>"Staib", "affiliation" => [{"name"=>"University of Zurich, Zurich, Switzerland"}])
79
79
  expect(subject.publisher).to be_nil
80
80
  expect(subject.publication_year).to eq("2018")
81
+ expect(subject.subjects).to eq([{"subject"=>"Pupil Size Response"},
82
+ {"subject"=>"Skin Conductance Response"},
83
+ {"subject"=>"Electrocardiogram"},
84
+ {"subject"=>"Electromyogram"},
85
+ {"subject"=>"Electrodermal Activity"},
86
+ {"subject"=>"Galvanic Skin Response"},
87
+ {"subject"=>"PSR"},
88
+ {"subject"=>"SCR"},
89
+ {"subject"=>"ECG"},
90
+ {"subject"=>"EMG"},
91
+ {"subject"=>"EDA"},
92
+ {"subject"=>"GSR"}])
81
93
  end
82
94
 
83
95
  it "pangaea" do
@@ -119,6 +131,9 @@ describe Bolognese::Metadata, vcr: true do
119
131
  expect(subject.titles).to eq([{"title"=>"Summary data ankylosing spondylitis GWAS"}])
120
132
  expect(subject.container).to eq("identifier"=>"https://dataverse.harvard.edu", "identifierType"=>"URL", "title"=>"Harvard Dataverse", "type"=>"DataRepository")
121
133
  expect(subject.creators).to eq([{"name" => "International Genetics Of Ankylosing Spondylitis Consortium (IGAS)", "nameIdentifiers"=>[], "affiliation" => []}])
134
+ expect(subject.subjects).to eq([{"subject"=>"Medicine, Health and Life Sciences"},
135
+ {"subject"=>"Genome-Wide Association Studies"},
136
+ {"subject"=>"Ankylosing spondylitis"}])
122
137
  end
123
138
 
124
139
  it "harvard dataverse via identifiers.org" do
@@ -285,7 +300,6 @@ describe Bolognese::Metadata, vcr: true do
285
300
  expect(subject.id).to eq("https://doi.org/10.23698/aida/drov")
286
301
  end
287
302
 
288
-
289
303
  it "from attributes" do
290
304
  subject = Bolognese::Metadata.new(input: nil,
291
305
  from: "schema_org",
@@ -481,4 +481,54 @@ describe Bolognese::Metadata, vcr: true do
481
481
  expect(response).to eq("https://raw.githubusercontent.com/datacite/metadata-reports/master/software/codemeta.json")
482
482
  end
483
483
  end
484
+
485
+ context "fos" do
486
+ it "name_to_fos match" do
487
+ name = "Biological sciences"
488
+ response = subject.name_to_fos(name)
489
+ expect(response).to eq([{"subject"=>"Biological sciences"},
490
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
491
+ "subject"=>"FOS: Biological sciences",
492
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
493
+ end
494
+
495
+ it "name_to_fos for match" do
496
+ name = "Statistics"
497
+ response = subject.name_to_fos(name)
498
+ expect(response).to eq([{"subject"=>"Statistics"},
499
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
500
+ "subject"=>"FOS: Mathematics",
501
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
502
+ end
503
+
504
+ it "name_to_fos no match" do
505
+ name = "Random tag"
506
+ response = subject.name_to_fos(name)
507
+ expect(response).to eq([{"subject"=>"Random tag"}])
508
+ end
509
+
510
+ it "hsh_to_fos match" do
511
+ hsh = { "__content__" => "Biological sciences" }
512
+ response = subject.hsh_to_fos(hsh)
513
+ expect(response).to eq([{"subject"=>"Biological sciences"},
514
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
515
+ "subject"=>"FOS: Biological sciences",
516
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
517
+ end
518
+
519
+ it "hsh_to_fos for match" do
520
+ hsh = { "__content__" => "Statistics" }
521
+ response = subject.hsh_to_fos(hsh)
522
+ expect(response).to eq([{"subject"=>"Statistics"},
523
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
524
+ "subject"=>"FOS: Mathematics",
525
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
526
+ end
527
+
528
+ it "hsh_to_fos no match" do
529
+ hsh = { "__content__"=>"Random tag" }
530
+ response = subject.hsh_to_fos(hsh)
531
+ expect(response).to eq([{"subject"=>"Random tag"}])
532
+ end
533
+ end
484
534
  end
@@ -94,6 +94,24 @@ describe Bolognese::Metadata, vcr: true do
94
94
  expect(json["title"]).to eq("Scimag catalogue of LibGen as of January 1st, 2014")
95
95
  end
96
96
 
97
+ it "software w/version" do
98
+ input = "https://doi.org/10.5281/zenodo.2598836"
99
+ subject = Bolognese::Metadata.new(input: input, from: "datacite")
100
+ json = JSON.parse(subject.citeproc)
101
+ expect(json["type"]).to eq("article")
102
+ expect(json["DOI"]).to eq("10.5281/zenodo.2598836")
103
+ expect(json["version"]).to eq("1.0.0")
104
+ end
105
+
106
+ it "software w/version from datacite_json" do
107
+ input = fixture_path + "datacite_software_version.json"
108
+ subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
109
+ json = JSON.parse(subject.citeproc)
110
+ expect(json["type"]).to eq("article")
111
+ expect(json["DOI"]).to eq("10.5281/ZENODO.2598836")
112
+ expect(json["version"]).to eq("1.0.0")
113
+ end
114
+
97
115
  it "multiple abstracts" do
98
116
  input = "https://doi.org/10.12763/ona1045"
99
117
  subject = Bolognese::Metadata.new(input: input, from: "datacite")
@@ -164,6 +164,10 @@ describe Bolognese::Metadata, vcr: true do
164
164
  expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}])
165
165
  expect(subject.publication_year).to eq("2017")
166
166
  expect(subject.publisher).to eq("Figshare")
167
+ expect(subject.subjects).to eq([{"subject"=>"Information Systems"},
168
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
169
+ "subject"=>"FOS: Computer and information sciences",
170
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
167
171
  expect(subject.agency).to eq("DataCite")
168
172
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
169
173
  expect(subject.datacite).to end_with("</resource>")
@@ -182,6 +186,10 @@ describe Bolognese::Metadata, vcr: true do
182
186
  expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}])
183
187
  expect(subject.publication_year).to eq("2017")
184
188
  expect(subject.publisher).to eq("Figshare")
189
+ expect(subject.subjects).to eq([{"subject"=>"Information Systems"},
190
+ {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
191
+ "subject"=>"FOS: Computer and information sciences",
192
+ "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
185
193
  expect(subject.agency).to eq("DataCite")
186
194
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
187
195
  expect(subject.datacite).to end_with("</resource>")
@@ -50,6 +50,7 @@ describe Bolognese::Metadata, vcr: true do
50
50
  expect(json["@id"]).to eq("https://doi.org/10.5061/dryad.8515")
51
51
  expect(json["@reverse"]).to eq("citation" => [{"@id"=>"https://doi.org/10.1371/journal.ppat.1000446", "@type"=>"ScholarlyArticle"}, {"@type"=>"ScholarlyArticle", "identifier"=>{"@type"=>"PropertyValue", "propertyID"=>"PMID", "value"=>"19478877"}}],
52
52
  "isBasedOn" => [{"@id"=>"https://doi.org/10.1371/journal.ppat.1000446", "@type"=>"ScholarlyArticle"}, {"@type"=>"ScholarlyArticle", "identifier"=>{"@type"=>"PropertyValue", "propertyID"=>"PMID", "value"=>"19478877"}}])
53
+ expect(json["keywords"]).to eq("Phylogeny, Malaria, Parasites, Taxonomy, Mitochondrial genome, Africa, Plasmodium")
53
54
  end
54
55
 
55
56
  it "Schema.org JSON IsSupplementTo" do
@@ -81,6 +82,7 @@ describe Bolognese::Metadata, vcr: true do
81
82
  "affiliation"=>{"@type"=>"Organization", "name"=>"NCEAS"}},
82
83
  {"name"=>"University Of California, Santa Barbara", "@type"=>"Organization"}])
83
84
  expect(json["version"]).to eq("2.0.0")
85
+ expect(json["keywords"]).to eq("data sharing, data repository, DataONE")
84
86
  end
85
87
 
86
88
  it "Funding" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.17
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-18 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -722,6 +722,8 @@ files:
722
722
  - resources/kernel-4/include/datacite-titleType-v4.xsd
723
723
  - resources/kernel-4/include/xml.xsd
724
724
  - resources/kernel-4/metadata.xsd
725
+ - resources/oecd/for-mappings.json
726
+ - resources/oecd/fos-mappings.json
725
727
  - resources/schema_org/jsonldcontext.json
726
728
  - resources/xml.xsd
727
729
  - spec/array_spec.rb
@@ -772,6 +774,7 @@ files:
772
774
  - spec/fixtures/datacite_software.json
773
775
  - spec/fixtures/datacite_software_missing_comma.json
774
776
  - spec/fixtures/datacite_software_overlapping_keys.json
777
+ - spec/fixtures/datacite_software_version.json
775
778
  - spec/fixtures/edam_package.json
776
779
  - spec/fixtures/funding_reference.xml
777
780
  - spec/fixtures/gtex.xml
@@ -873,6 +876,12 @@ files:
873
876
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml
874
877
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml
875
878
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_string/crosscite.yml
879
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_for_match.yml
880
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_match.yml
881
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/hsh_to_fos_no_match.yml
882
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_for_match.yml
883
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_match.yml
884
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/fos/name_to_fos_no_match.yml
876
885
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/from_schema_org/with_id.yml
877
886
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/from_schema_org_creators/with_affiliation.yml
878
887
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/from_schema_org_creators/without_affiliation.yml
@@ -934,15 +943,18 @@ files:
934
943
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/dissertation.yml
935
944
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/doi_with_sign.yml
936
945
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/empty_subject.yml
946
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/even_more_subject_scheme_FOR.yml
937
947
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_references.yml
938
948
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml
939
949
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml
940
950
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/keywords_with_attributes.yml
941
951
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/leading_and_trailing_whitespace.yml
952
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/more_subject_scheme_FOR.yml
942
953
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_author_names_in_one_creatorsName.yml
943
954
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/multiple_licenses.yml
944
955
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/series-information.yml
945
956
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/subject_scheme.yml
957
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/subject_scheme_FOR.yml
946
958
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/xs_string_attributes.yml
947
959
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date/publication_date.yml
948
960
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/date.yml
@@ -993,9 +1005,12 @@ files:
993
1005
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml
994
1006
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml
995
1007
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml
1008
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml
996
1009
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_descriptions/insert.yml
1010
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_formats/insert.yml
997
1011
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_identifier/doi.yml
998
1012
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_language/insert.yml
1013
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_given_and_family_name.yml
999
1014
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_only_name.yml
1000
1015
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publication_year/insert.yml
1001
1016
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publisher/insert.yml
@@ -1003,6 +1018,7 @@ files:
1003
1018
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/related_identifier.yml
1004
1019
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type/insert.yml
1005
1020
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_rights_list/insert.yml
1021
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_sizes/insert.yml
1006
1022
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_subjects/insert.yml
1007
1023
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_titles/insert.yml
1008
1024
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_version/insert.yml
@@ -1103,6 +1119,7 @@ files:
1103
1119
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/multiple_abstracts.yml
1104
1120
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/organization_author.yml
1105
1121
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/software.yml
1122
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/software_w/version.yml
1106
1123
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/with_first_page.yml
1107
1124
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/with_only_first_page.yml
1108
1125
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/with_pages.yml