module HighLevelBrowse

Namespaced to avoid conflicts with other range_tree gems

Constants

SOURCE_URL
VERSION

Public Class Methods

fetch() click to toggle source

Fetch a new version of the raw file and turn it into a db @return [DB] The loaded database

# File lib/high_level_browse.rb, line 12
def self.fetch
  uri = URI.parse(SOURCE_URL)
  # Why on earth OpenURI::OpenRead is mixed into http but not https, I don't know
  uri.extend OpenURI::OpenRead

  xml = uri.read
  return DB.new_from_xml(xml)
rescue => e
  raise "Could not fetch xml from '#{SOURCE_URL}': #{e}"
end
fetch_and_save(dir:) click to toggle source

Fetch and save to the specified directory @param [String] dir The directory where the hlb.json.gz file will end up @return [DB] The fetched and saved database

# File lib/high_level_browse.rb, line 27
def self.fetch_and_save(dir:)
  db = self.fetch
  db.save(dir: dir)
  db
end
load(dir:) click to toggle source

Load from disk @param [String] dir The directory where the hlb.json.gz file is located @return [DB] The loaded database

# File lib/high_level_browse.rb, line 37
def self.load(dir:)
  DB.load(dir: dir)
end