Module: RelatonCalconnect::Scrapper

Defined in:
lib/relaton_calconnect/scrapper.rb

Constant Summary collapse

DOMAIN =
"https://standards.calconnect.org/".freeze

Class Method Summary collapse

Class Method Details

.parse_page(hit) ⇒ RelatonCalconnect::CcBibliographicItem

Parse document page

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/relaton_calconnect/scrapper.rb', line 15

def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  links = array(hit["link"])
  link = links.detect { |l| l["type"] == "rxl" }
  if link
    bib = fetch_bib_xml link["content"]
    update_links bib, links
    # XMLParser.from_xml bib_xml
  else
    hit.delete "fetched"
    bib = RelatonCalconnect::CcBibliographicItem.from_hash doc_to_hash hit
  end
  bib.link.each do |l|
    l.content.merge!(scheme: SCHEME, host: HOST) unless l.content.host
  end
  bib
end