Class: Packmule::Archiver::Tar

Inherits:
Object
  • Object
show all
Defined in:
lib/packmule/archiver.rb

Overview

Tar

Class Method Summary collapse

Class Method Details

.create(options) ⇒ Object

Creates the tar file, like a BOSS!



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/packmule/archiver.rb', line 71

def self.create(options)
  options = {:gzip => false, :bzip => false}.merge(options)
  filename = "#{options[:filename]}.tar" + (options[:gzip] ? '.gz' : (options[:bzip] ? '.bz2' : ''))
  
  # Make sure it doesn't exist..
  if ::FileTest.exists? "./#{filename}"
    puts "#{filename} already exists, skipping"
    return false
  end
  
  if options[:gzip] == true
    # Tar and gzip like a boss
    `tar czf #{filename} -C #{options[:dir]} ./`
  elsif options[:bzip] == true
    # Bzippit
    `tar cfj #{filename} -C #{options[:dir]} ./`
  else
    # Totally boss taring code, yo
    `tar cf #{filename} -C #{options[:dir]} ./`
  end
  
  if ::FileTest.exists? "./#{filename}"
    puts " - #{filename} created"
  end
  
  return true
end