Module: Relaton::Oasis::Bibliography

Defined in:
lib/relaton/oasis/bibliography.rb

Constant Summary collapse

ENDPOINT =
"https://raw.githubusercontent.com/relaton/relaton-data-oasis/refs/heads/data-v2/"

Class Method Summary collapse

Class Method Details

.get(ref, year = nil, opts = {}) ⇒ Object



30
31
32
# File 'lib/relaton/oasis/bibliography.rb', line 30

def get(ref, year = nil, opts = {})
  search(ref, year, opts)
end

.search(text, _year = nil, _opts = {}) ⇒ Object

rubocop:disable Metrics/MethodLength



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/relaton/oasis/bibliography.rb', line 11

def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength
  Util.info "Fetching from Relaton repository ...", key: text
  /^(?:OASIS\s)?(?<code>.+)/ =~ text
  row = find_index_entry(code)
  unless row
    Util.info "Not found.", key: text
    return
  end

  uri = URI("#{ENDPOINT}#{row[:file]}")
  parse_item(fetch_yaml(uri), text)
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
       Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
       Net::ProtocolError, Net::ReadTimeout,
       OpenSSL::SSL::SSLError, Errno::ETIMEDOUT => e
  raise Relaton::RequestError,
        "Could not access #{uri}: #{e.message}"
end