Sha256: 00d78c61d99e792ea952f99d0b0c139bbf2be83d7f563ed21ccae94243a2b474
Contents?: true
Size: 838 Bytes
Versions: 1
Compression:
Stored size: 838 Bytes
Contents
module RelatonEcma module Scrapper ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-ecma/master/data/".freeze class << self # @param code [String] # @return [RelatonBib::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" raise RelatonBib::RequestError, "No document found for #{code} reference. #{e.message}" end private # @param url [String] # @retrurn [RelatonEcma::BibliographicItem] def parse_page(url) doc = OpenURI.open_uri url hash = YAML.safe_load(doc) hash["fetched"] = Date.today.to_s BibliographicItem.from_hash hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
relaton-ecma-1.14.0 | lib/relaton_ecma/scrapper.rb |