lib/relaton_nist/data_fetcher.rb in relaton-nist-1.14.6 vs lib/relaton_nist/data_fetcher.rb in relaton-nist-1.14.7
- old
+ new
@@ -34,13 +34,20 @@
{ type: "DOI", id: fetch_doi(doc) },
# { type: "NIST", id: anchor(doc), scope: "anchor" },
]
end
+ #
+ # Parse document's ID from XML
+ #
+ # @param [Nokogiri::XML::Element] doc XML element
+ #
+ # @return [String] document's ID
+ #
def pub_id(doc)
# anchor(doc).gsub(".", " ")
- fetch_doi(doc).split("/")[1..].join("/").gsub(".", " ")
+ fetch_doi(doc).split("/")[1..].join("/").gsub(".", " ").sub(/^nist\sir/, "NIST IR")
end
def fetch_doi(doc) # rubocop:disable Metrics/CyclomaticComplexity
id = doc.at("doi_data/doi").text
case id
@@ -267,16 +274,18 @@
# @param [Nokogiri::XML::Element] doc document element
#
# @return [Array<RelatonBib::Series>] series
#
def fetch_series(doc)
- series_path = File.expand_path("series.yaml", __dir__)
- series = YAML.load_file series_path
prf, srs, num = pub_id(doc).split
sname = series[srs] || srs
title = RelatonBib::TypedTitleString.new(content: "#{prf} #{sname}")
abbr = RelatonBib::LocalizedString.new srs
[RelatonBib::Series.new(title: title, abbreviation: abbr, number: num)]
+ end
+
+ def series
+ @series ||= YAML.load_file File.expand_path("series.yaml", __dir__)
end
#
# Save document
#