Class: Edploy::Archive

Inherits:
Object
  • Object
show all
Defined in:
lib/edployscripts/archive.rb

Class Method Summary collapse

Class Method Details

.extract(archive, target_dir, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/edployscripts/archive.rb', line 6

def extract(archive, target_dir, options = {})
  cmds = []
  case archive_type(archive)
  when :tgz then cmds << "tar -C #{target_dir} -z -x -f #{archive}"
  when :tbz2 then cmds << "tar -C #{target_dir} -j -x -f #{archive}"
  when :tar then cmds << "tar -C #{target_dir} -x -f #{archive}"
  when :zip then cmds << "cd #{target_dir} ; unzip #{archive}"
  end
  cmds << "rm -f #{archive}" if options[:remove]
  system cmds.join(' ; ')
end