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 NoMethodError when reading blank publisher properties from DataCite XML #181

Merged
merged 1 commit into from
Dec 7, 2023
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
2 changes: 1 addition & 1 deletion lib/bolognese/readers/datacite_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def read_datacite(string: nil, **options)
{ "name" => r.strip }
elsif r.is_a?(Hash)
{
"name" => r["__content__"].strip,
"name" => r["__content__"].present? ? r["__content__"].strip : nil,
"publisherIdentifier" => r["publisherIdentifierScheme"] == "ROR" ? normalize_ror(r["publisherIdentifier"]) : r["publisherIdentifier"],
"publisherIdentifierScheme" => r["publisherIdentifierScheme"],
"schemeUri" => r["schemeURI"],
Expand Down
18 changes: 18 additions & 0 deletions spec/fixtures/datacite_blank_publisher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd">
<identifier identifierType="DOI">10.81360/4DVP-KR57</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Møller, Jørgen</creatorName>
<givenName>Jørgen</givenName>
<familyName>Møller</familyName>
</creator>
</creators>
<titles>
<title xml:lang="en">Economic Crisis and Democratic Breakdown in the Interwar Years: A Reassessment</title>
<title xml:lang="de">Wirtschaftskrise und demokratischer Zusammenbruch in der Zwischenkriegszeit: Eine Neubewertung</title>
</titles>
<publisher publisherIdentifier="https://ror.org/04wxnsj81"></publisher>
<publicationYear>2015</publicationYear>
<resourceType resourceTypeGeneral="JournalArticle"/>
</resource>
8 changes: 8 additions & 0 deletions spec/readers/datacite_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1801,4 +1801,12 @@
]
)
end

it "blank publisher" do
input = fixture_path + "datacite_blank_publisher.xml"
subject = Bolognese::Metadata.new(input: input)
expect(subject.publisher).to eq(
{ "publisherIdentifier" => "https://ror.org/04wxnsj81" }
)
end
end