diff --git a/Gemfile.lock b/Gemfile.lock index 6314db99..872096bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.8.8) + bolognese (1.8.9) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) diff --git a/lib/bolognese/readers/crossref_reader.rb b/lib/bolognese/readers/crossref_reader.rb index b2fcfed2..ec474ef4 100644 --- a/lib/bolognese/readers/crossref_reader.rb +++ b/lib/bolognese/readers/crossref_reader.rb @@ -86,7 +86,9 @@ def read_crossref(string: nil, **options) bibliographic_metadata = meta.dig("crossref", "report_paper", "report_paper_metadata").to_h resource_type = "report" when "peer_review" - bibliographic_metadata = meta.dig("crossref", "peer_review").to_h + bibliographic_metadata = meta.dig("crossref", "peer_review") + when "dissertation" + bibliographic_metadata = meta.dig("crossref", "dissertation") end resource_type = (resource_type || model).to_s.underscore.camelcase.presence @@ -236,7 +238,7 @@ def crossref_license(program_metadata) end def crossref_people(bibliographic_metadata, contributor_role) - person = bibliographic_metadata.dig("contributors", "person_name") + person = bibliographic_metadata.dig("contributors", "person_name") || bibliographic_metadata.dig("person_name") organization = Array.wrap(bibliographic_metadata.dig("contributors", "organization")) person = [{ "name" => ":(unav)", "contributor_role"=>"author" }] if contributor_role == "author" && Array.wrap(person).select { |a| a["contributor_role"] == "author" }.blank? && Array.wrap(organization).select { |a| a["contributor_role"] == "author" }.blank? diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index fd20d36e..50d4d3d2 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.8.8" + VERSION = "1.8.9" end diff --git a/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/dissertation.yml b/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/dissertation.yml new file mode 100644 index 00000000..bb444078 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/dissertation.yml @@ -0,0 +1,122 @@ +--- +http_interactions: +- request: + method: get + uri: https://doi.org/ra/10.14264 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.1; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + response: + status: + code: 200 + message: '' + headers: + Date: + - Sat, 22 Aug 2020 09:37:48 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Set-Cookie: + - __cfduid=dd2a5efda710f4da2c27722ecdb7d162d1598089068; expires=Mon, 21-Sep-20 + 09:37:48 GMT; path=/; domain=.doi.org; HttpOnly; SameSite=Lax; Secure + Cf-Cache-Status: + - DYNAMIC + Cf-Request-Id: + - 04b72118d7000064a35e821200000001 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 5c6b9e07ba4164a3-FRA + body: + encoding: ASCII-8BIT + string: |- + [ + { + "DOI": "10.14264", + "RA": "Crossref" + } + ] + http_version: + recorded_at: Sat, 22 Aug 2020 09:37:48 GMT +- request: + method: get + uri: https://api.crossref.org/works/10.14264/uql.2020.791/transform/application/vnd.crossref.unixsd+xml + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.1; mailto:info@datacite.org) + Accept: + - text/xml + response: + status: + code: 200 + message: OK + headers: + Link: + - ; rel="canonical", ; + title="Patricia Maree Collingwood"; rel="author" + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Headers: + - X-Requested-With + Content-Length: + - '2769' + Server: + - http-kit + Date: + - Sat, 22 Aug 2020 09:37:49 GMT + X-Rate-Limit-Limit: + - '50' + X-Rate-Limit-Interval: + - 1s + Connection: + - close + body: + encoding: ASCII-8BIT + string: "\n\r\n \r\n + \ \r\n none\r\n \r\n \r\n + \ \r\n 10.14264/uql.2020.791\r\n + \ University of Queensland + Library\r\n University + of Queensland Library\r\n 5387\r\n + \ 116937436\r\n + \ 1346666\r\n + \ 1591592933\r\n + \ 10.14264\r\n + \ 2020-06-08T05:08:59Z\r\n + \ 2020-06-08T05:08:58Z\r\n + \ 0\r\n + \ \r\n \r\n + \ \r\n \r\n Patricia Maree\r\n + \ Collingwood\r\n https://orcid.org/0000-0003-3086-4443\r\n + \ \r\n \r\n School + truancy and financial independence during emerging adulthood: a longitudinal + analysis of receipt of and reliance on cash transfers\r\n \r\n + \ \r\n 05\r\n 25\r\n + \ 2020\r\n \r\n \r\n + \ The University of Queensland\r\n + \ School of Social Science\r\n + \ \r\n PhD Thesis\r\n + \ \r\n 10.14264/uql.2020.791\r\n + \ http://espace.library.uq.edu.au/view/UQ:23a1e74\r\n + \ \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n" + http_version: + recorded_at: Sat, 22 Aug 2020 09:37:49 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/readers/crossref_reader_spec.rb b/spec/readers/crossref_reader_spec.rb index 9cc6b799..4887198c 100644 --- a/spec/readers/crossref_reader_spec.rb +++ b/spec/readers/crossref_reader_spec.rb @@ -201,6 +201,30 @@ expect(subject.agency).to eq("crossref") end + it "dissertation" do + input = "https://doi.org/10.14264/uql.2020.791" + subject = Bolognese::Metadata.new(input: input) + expect(subject.valid?).to be true + expect(subject.url).to eq("http://espace.library.uq.edu.au/view/UQ:23a1e74") + expect(subject.types).to eq("bibtex"=>"phdthesis", "citeproc"=>"thesis", "resourceType"=>"Dissertation", "resourceTypeGeneral"=>"Text", "ris"=>"THES", "schemaOrg"=>"Thesis") + expect(subject.creators).to eq([{"familyName"=>"Collingwood", + "givenName"=>"Patricia Maree", + "name"=>"Collingwood, Patricia Maree", + "nameIdentifiers"=> + [{"nameIdentifier"=>"https://orcid.org/0000-0003-3086-4443", + "nameIdentifierScheme"=>"ORCID", + "schemeUri"=>"https://orcid.org"}], + "nameType"=>"Personal"}]) + expect(subject.titles).to eq([{"title"=>"School truancy and financial independence during emerging adulthood: a longitudinal analysis of receipt of and reliance on cash transfers"}]) + expect(subject.id).to eq("https://doi.org/10.14264/uql.2020.791") + expect(subject.identifiers).to be_empty + expect(subject.descriptions).to be_empty + expect(subject.dates).to include({"date"=>"2020-06-08", "dateType"=>"Issued"}) + expect(subject.publication_year).to eq("2020") + expect(subject.publisher).to eq("University of Queensland Library") + expect(subject.agency).to eq("crossref") + end + it "DOI with SICI DOI" do input = "https://doi.org/10.1890/0012-9658(2006)87[2832:tiopma]2.0.co;2" subject = Bolognese::Metadata.new(input: input)