Sha256: 53bf12e6748ab67ee69ec94e284b09815bafb08b8cea5a7197f600e6c3d20242

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

module RelatonCcsds
  class HitCollection < RelatonBib::HitCollection
    GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-ccsds/main/".freeze
    INDEX_FILE = "index-v2.yaml".freeze

    #
    # Search his in index.
    #
    # @return [<Type>] <description>
    #
    def fetch
      pubid = Pubid::Ccsds::Identifier.parse(text)
      rows = if pubid.edition
               index.search(pubid)
               # index.search { |r| Pubid::Ccsds::Identifier.create(**r[:id]) == pubid }
             else
               index.search { |r| r[:id].exclude(:edition) == pubid }
             end
      @array = rows.map { |row| Hit.new code: row[:id], url: "#{GHURL}#{row[:file]}" }
      self
    rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError, Errno::ECONNRESET => e
      raise RelatonBib::RequestError, e.message
    end

    def index
      @index ||= Relaton::Index.find_or_create :ccsds, url: "#{GHURL}index-v2.zip", file: INDEX_FILE
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-ccsds-1.20.0 lib/relaton_ccsds/hit_collection.rb