Class: Arxiv::Downloader::SourceArchive

Inherits:
Object
  • Object
show all
Defined in:
lib/arxiv/downloader/source_archive.rb

Instance Method Summary collapse

Constructor Details

#initialize(identifier, client:) ⇒ SourceArchive

Returns a new instance of SourceArchive.



9
10
11
12
# File 'lib/arxiv/downloader/source_archive.rb', line 9

def initialize identifier, client:
  @identifier = identifier
  @client     = client
end

Instance Method Details

#download(to:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/arxiv/downloader/source_archive.rb', line 14

def download to:
  FileUtils.mkdir_p to

  body = @client.get(url).to_s
  Zlib::GzipReader.wrap StringIO.new(body) do |gz|
    Gem::Package::TarReader.new(gz) do |tar|
      tar.each { |entry| extract entry, to }
    end
  end
end