Class: TerraspaceBundler::Extract

Inherits:
Object
  • Object
show all
Defined in:
lib/terraspace_bundler/extract/tar.rb,
lib/terraspace_bundler/extract.rb,
lib/terraspace_bundler/extract/zip.rb

Overview

Defined Under Namespace

Classes: Tar, Zip

Class Method Summary collapse

Class Method Details

.extract(archive, dest) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/terraspace_bundler/extract.rb', line 3

def self.extract(archive, dest)
  FileUtils.rm_rf(dest)
  FileUtils.mkdir_p(File.dirname(dest))

  if archive.ends_with?('.tgz') || archive.ends_with?('.tar.gz')
    Tar.extract(archive, dest)
  elsif archive.ends_with?('.zip')
    Zip.extract(archive, dest)
  else
    puts <<~EOL.color(:red)
      ERROR: Unable to extract. Unsupported archive extension for:

          #{archive}
    EOL
    exit 1
  end
end