lib/relaton_nist/data_fetcher.rb in relaton-nist-1.10.1 vs lib/relaton_nist/data_fetcher.rb in relaton-nist-1.10.2
- old
+ new
@@ -32,20 +32,20 @@
# when "10.6028/NIST.HB.150-10-1995" then doi.sub!(/150-10$/, "150-10-1995")
# end
# anchor = doi.split("/")[1..-1].join "/"
[
{ type: "NIST", id: pub_id(doc), primary: true },
- { type: "DOI", id: doi(doc) },
+ { type: "DOI", id: fetch_doi(doc) },
{ type: "NIST", id: anchor(doc), scope: "anchor" },
]
end
def pub_id(doc)
anchor(doc).gsub(".", " ")
end
- def doi(doc) # rubocop:disable Metrics/CyclomaticComplexity
+ def fetch_doi(doc) # rubocop:disable Metrics/CyclomaticComplexity
id = doc.at("doi_data/doi").text
case id
when "10.6028/NBS.CIRC.e2e" then "10.6028/NBS.CIRC.2e2"
when "10.6028/NBS.CIRC.sup" then "10.6028/NBS.CIRC.24e7sup"
when "10.6028/NBS.CIRC.supJun1925-Jun1926" then "10.6028/NBS.CIRC.24e7sup2"
@@ -55,11 +55,11 @@
else id
end
end
def anchor(doc)
- doi(doc).split("/")[1..-1].join "/"
+ fetch_doi(doc).split("/")[1..-1].join "/"
end
# @param doc [Nokogiri::XML::Element]
# @return [Array<RelatonBib::DocumentIdentifier>]
def fetch_docid(doc)
@@ -113,11 +113,14 @@
end
# @param doc [Nokogiri::XML::Element]
# @return [Array<RelatonBib::TypedUri>]
def fetch_link(doc)
- url = doc.at("doi_data/resource").text
- [RelatonBib::TypedUri.new(type: "doi", content: url)]
+ pdf = doc.at("doi_data/resource").text
+ doi = "https://doi.org/#{fetch_doi(doc)}"
+ [{ type: "doi", content: doi }, { type: "pdf", content: pdf }].map do |l|
+ RelatonBib::TypedUri.new(**l)
+ end
end
# @param doc [Nokogiri::XML::Element]
# @return [Array<RelatonBib::FormattedString>]
def fetch_abstract(doc)