Module: RelatonIetf::Scrapper
Overview
Scrapper module
Constant Summary collapse
- GH_URL =
"https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
Instance Method Summary collapse
Instance Method Details
#scrape_page(text, is_relation: false) ⇒ RelatonIetf::IetfBibliographicItem
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/relaton_ietf/scrapper.rb', line 13 def scrape_page(text, is_relation: false) # Remove initial "IETF " string if specified ref = text.gsub(/^IETF /, "") /^(?:RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref ref.sub!(/(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0")) if num rfc_item ref, is_relation rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, SocketError raise RelatonBib::RequestError, "No document found for #{ref} reference" end |