module Blockbuster::Extractor

extracts files from gzipped tarballs

Public Instance Methods

extract_cassettes() click to toggle source
# File lib/blockbuster/concerns/extractor.rb, line 4
def extract_cassettes
  return unless File.exist?(file_path)

  File.open(file_path, 'rb') do |file|
    Zlib::GzipReader.wrap(file) do |gz|
      Gem::Package::TarReader.new(gz) do |tar|
        tar.each do |entry|
          untar_file(entry) if entry.file?
        end
      end
    end
  end
end
save_to_disk(entry, contents) click to toggle source
# File lib/blockbuster/concerns/extractor.rb, line 25
def save_to_disk(entry, contents)
  destination = File.join configuration.test_directory, entry.full_name

  FileUtils.mkdir_p(File.dirname(destination))
  File.open(destination, 'wb') do |cass|
    cass.write(contents)
  end
  File.chmod(entry.header.mode, destination)
end
untar_file(entry) click to toggle source
# File lib/blockbuster/concerns/extractor.rb, line 18
def untar_file(entry)
  contents = entry.read
  @comparator.add(entry.full_name, Digest::MD5.hexdigest(contents), file_name)

  save_to_disk(entry, contents) unless configuration.local_mode
end