Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ORCID and ROR identifiers ending with a / not being rendered in JSON when converting from XML #189

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions spec/author_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -250,4 +256,4 @@
expect(response).to eq("Matt Jones and Peter Slaughter and {University of California, Santa Barbara}")
end
end
end
end
8 changes: 8 additions & 0 deletions spec/fixtures/datacite-example-ROR-nameIdentifiers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<creatorName nameType="Personal">Mike B</creatorName>
<nameIdentifier nameIdentifierScheme="ORCID"> 0000-0001-9998-0118 </nameIdentifier>
</creator>
<creator>
<creatorName nameType="Organizational">Gump South Pacific Research Station</creatorName>
<nameIdentifier nameIdentifierScheme="ROR" schemeURI="https://ror.org/">https://ror.org/04sk0et52/</nameIdentifier>
</creator>
<creator>
<creatorName nameType="Personal">Ashwini Sukale</creatorName>
<nameIdentifier schemeURI="https://orcid.org/" nameIdentifierScheme="ORCID">https://orcid.org/0000-0001-9998-0117/</nameIdentifier>
</creator>
</creators>
<titles>
<title xml:lang="en-US">Genomic Standards Consortium (GSC) Island Sampling Day: Moorea Reef to Ridges Genomic Transect</title>
Expand Down
Loading