From 0152810697ea1535194b1c02324c748d00e5b697 Mon Sep 17 00:00:00 2001
From: codycooperross <50597551+codycooperross@users.noreply.github.com>
Date: Mon, 26 Feb 2024 10:49:46 -0500
Subject: [PATCH] nameIdentifier ORCID identifiers ending with a `/` are not
rendered in JSON when converting from XML Fixes #188
---
lib/bolognese/utils.rb | 4 ++--
spec/author_utils_spec.rb | 10 ++++++++--
spec/fixtures/datacite-example-ROR-nameIdentifiers.xml | 8 ++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/bolognese/utils.rb b/lib/bolognese/utils.rb
index 4f5231de..45c45c09 100644
--- a/lib/bolognese/utils.rb
+++ b/lib/bolognese/utils.rb
@@ -600,12 +600,12 @@ def orcid_as_url(orcid)
end
def validate_orcid(orcid)
- orcid = Array(/\A(?:(?:http|https):\/\/(?:(?:www|sandbox)?\.)?orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z/.match(orcid)).last
+ orcid = Array(/\A(?:(?:http|https):\/\/(?:(?:www|sandbox)?\.)?orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\/{0,1}\z/.match(orcid)).last
orcid.gsub(/[[:space:]]/, "-") if orcid.present?
end
def validate_ror(ror)
- Array(/^(?:(?:(?:http|https):\/\/)?ror\.org\/)?(0\w{6}\d{2})$/.match(ror)).last
+ Array(/^(?:(?:(?:http|https):\/\/)?ror\.org\/)?(0\w{6}\d{2})\/{0,1}$/.match(ror)).last
end
def validate_orcid_scheme(orcid_scheme)
diff --git a/spec/author_utils_spec.rb b/spec/author_utils_spec.rb
index e95acc35..60acc276 100644
--- a/spec/author_utils_spec.rb
+++ b/spec/author_utils_spec.rb
@@ -168,11 +168,12 @@
expect(subject.creators[4]).to eq("nameType"=>"Organizational", "name"=>"University Of Kivu", "nameIdentifiers"=> [{"nameIdentifier"=>"https://ror.org/01qfhxr31", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"ROR"}], "affiliation"=>[])
expect(subject.creators[5]).to eq("nameType"=>"Organizational", "name"=>"សាកលវិទ្យាល័យកម្ពុជា", "nameIdentifiers"=> [{"nameIdentifier"=>"http://ror.org/025e3rc84", "nameIdentifierScheme"=>"RORS"}], "affiliation"=>[])
expect(subject.creators[6]).to eq("nameType"=>"Organizational", "name"=>"جامعة زاخۆ", "nameIdentifiers"=> [{"nameIdentifier"=>"05sd1pz50", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"RORS"}], "affiliation"=>[])
+ expect(subject.creators[9]).to eq("nameType"=>"Organizational", "name"=>"Gump South Pacific Research Station", "nameIdentifiers"=> [{"nameIdentifier"=>"https://ror.org/04sk0et52", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"ROR"}], "affiliation"=>[])
expect(subject.contributors.first).to eq("nameType"=>"Organizational", "name"=>" Nawroz University ", "nameIdentifiers"=> [{"nameIdentifier"=>"https://ror.org/04gp75d48", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"ROR"}], "affiliation"=>[], "contributorType"=>"Producer")
expect(subject.contributors.last).to eq("nameType"=>"Organizational", "name"=>"University Of Greenland (Https://Www.Uni.Gl/)", "nameIdentifiers"=> [{"nameIdentifier"=>"https://ror.org/00t5j6b61", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"ROR"}],"affiliation"=>[], "contributorType"=>"Sponsor")
end
- context "affiliationIdentifier" do
+ context "affiliationIdentifier/nameIdentifier" do
let(:input) { fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' }
subject { Bolognese::Metadata.new(input: input, from: "datacite") }
@@ -207,6 +208,11 @@
expect(subject.creators[8]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0118", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}])
end
+ it "should normalize valid ORCID nameIdentifier with trailing slash" do
+ #" 0000-0001-9998-0118 ", # Valid ORCID with leading/trailing spaces
+ expect(subject.creators[10]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0117", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}])
+ end
+
it "should parse non ROR schema's without normalizing them" do
input = fixture_path + 'datacite-example-ROR-nameIdentifiers.xml'
subject = Bolognese::Metadata.new(input: input, from: "datacite")
@@ -250,4 +256,4 @@
expect(response).to eq("Matt Jones and Peter Slaughter and {University of California, Santa Barbara}")
end
end
-end
+end
\ No newline at end of file
diff --git a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml
index 8a1f68b7..5f765b30 100644
--- a/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml
+++ b/spec/fixtures/datacite-example-ROR-nameIdentifiers.xml
@@ -43,6 +43,14 @@
Mike B
0000-0001-9998-0118
+
+ Gump South Pacific Research Station
+ https://ror.org/04sk0et52/
+
+
+ Ashwini Sukale
+ https://orcid.org/0000-0001-9998-0117/
+
Genomic Standards Consortium (GSC) Island Sampling Day: Moorea Reef to Ridges Genomic Transect