Skip to content

Commit 02e1860

Browse files
authored
Merge pull request #189 from datacite/codycooperross/issue188
Fix for ORCID and ROR identifiers ending with a `/` not being rendered in JSON when converting from XML
2 parents 7a1ea4a + 0152810 commit 02e1860

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/bolognese/utils.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,12 @@ def orcid_as_url(orcid)
600600
end
601601

602602
def validate_orcid(orcid)
603-
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
603+
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
604604
orcid.gsub(/[[:space:]]/, "-") if orcid.present?
605605
end
606606

607607
def validate_ror(ror)
608-
Array(/^(?:(?:(?:http|https):\/\/)?ror\.org\/)?(0\w{6}\d{2})$/.match(ror)).last
608+
Array(/^(?:(?:(?:http|https):\/\/)?ror\.org\/)?(0\w{6}\d{2})\/{0,1}$/.match(ror)).last
609609
end
610610

611611
def validate_orcid_scheme(orcid_scheme)

spec/author_utils_spec.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@
168168
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"=>[])
169169
expect(subject.creators[5]).to eq("nameType"=>"Organizational", "name"=>"សាកលវិទ្យាល័យកម្ពុជា", "nameIdentifiers"=> [{"nameIdentifier"=>"http://ror.org/025e3rc84", "nameIdentifierScheme"=>"RORS"}], "affiliation"=>[])
170170
expect(subject.creators[6]).to eq("nameType"=>"Organizational", "name"=>"جامعة زاخۆ", "nameIdentifiers"=> [{"nameIdentifier"=>"05sd1pz50", "schemeUri"=>"https://ror.org", "nameIdentifierScheme"=>"RORS"}], "affiliation"=>[])
171+
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"=>[])
171172
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")
172173
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")
173174
end
174175

175-
context "affiliationIdentifier" do
176+
context "affiliationIdentifier/nameIdentifier" do
176177
let(:input) { fixture_path + 'datacite-example-ROR-nameIdentifiers.xml' }
177178
subject { Bolognese::Metadata.new(input: input, from: "datacite") }
178179

@@ -207,6 +208,11 @@
207208
expect(subject.creators[8]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0118", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}])
208209
end
209210

211+
it "should normalize valid ORCID nameIdentifier with trailing slash" do
212+
#" 0000-0001-9998-0118 ", # Valid ORCID with leading/trailing spaces
213+
expect(subject.creators[10]["nameIdentifiers"]).to eq([{"nameIdentifier"=>"https://orcid.org/0000-0001-9998-0117", "schemeUri"=>"https://orcid.org", "nameIdentifierScheme"=>"ORCID"}])
214+
end
215+
210216
it "should parse non ROR schema's without normalizing them" do
211217
input = fixture_path + 'datacite-example-ROR-nameIdentifiers.xml'
212218
subject = Bolognese::Metadata.new(input: input, from: "datacite")
@@ -250,4 +256,4 @@
250256
expect(response).to eq("Matt Jones and Peter Slaughter and {University of California, Santa Barbara}")
251257
end
252258
end
253-
end
259+
end

spec/fixtures/datacite-example-ROR-nameIdentifiers.xml

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
<creatorName nameType="Personal">Mike B</creatorName>
4444
<nameIdentifier nameIdentifierScheme="ORCID"> 0000-0001-9998-0118 </nameIdentifier>
4545
</creator>
46+
<creator>
47+
<creatorName nameType="Organizational">Gump South Pacific Research Station</creatorName>
48+
<nameIdentifier nameIdentifierScheme="ROR" schemeURI="https://ror.org/">https://ror.org/04sk0et52/</nameIdentifier>
49+
</creator>
50+
<creator>
51+
<creatorName nameType="Personal">Ashwini Sukale</creatorName>
52+
<nameIdentifier schemeURI="https://orcid.org/" nameIdentifierScheme="ORCID">https://orcid.org/0000-0001-9998-0117/</nameIdentifier>
53+
</creator>
4654
</creators>
4755
<titles>
4856
<title xml:lang="en-US">Genomic Standards Consortium (GSC) Island Sampling Day: Moorea Reef to Ridges Genomic Transect</title>

0 commit comments

Comments
 (0)