lib/relaton_cie/scrapper.rb in relaton-cie-1.13.0 vs lib/relaton_cie/scrapper.rb in relaton-cie-1.14.0
- old
+ new
@@ -2,11 +2,11 @@
module Scrapper
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-cie/master/data/".freeze
class << self
# @param code [String]
- # @return [RelatonBib::BibliographicItem]
+ # @return [RelatonCie::BibliographicItem]
def scrape_page(code)
url = "#{ENDPOINT}#{code.gsub(/[\/\s\-:.]/, '_').upcase}.yaml"
parse_page url
rescue OpenURI::HTTPError => e
return if e.io.status.first == "404"
@@ -15,14 +15,15 @@
end
private
# @param url [String]
- # @retrurn [RelatonBib::BibliographicItem]
+ # @retrurn [RelatoCie::BibliographicItem]
def parse_page(url)
doc = OpenURI.open_uri url
bib_hash = RelatonBib::HashConverter.hash_to_bib YAML.safe_load(doc)
- RelatonBib::BibliographicItem.new(**bib_hash)
+ bib_hash[:fetched] = Date.today.to_s
+ RelatonCie::BibliographicItem.new(**bib_hash)
end
end
end
end