Class: Mandy::Packer
- Inherits:
-
Object
- Object
- Mandy::Packer
- Defined in:
- lib/packer.rb
Constant Summary collapse
- TMP_DIR =
'/tmp/mandy'
Class Method Summary collapse
Class Method Details
.cleanup!(file) ⇒ Object
20 21 22 23 |
# File 'lib/packer.rb', line 20 def self.cleanup!(file) return false unless File.extname(file) == '.tar' `rm #{file}` end |
.pack(dir) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/packer.rb', line 7 def self.pack(dir) return dir if File.file?(dir) FileUtils.mkdir_p(TMP_DIR) tmp_path = "#{TMP_DIR}/packed-job-#{Time.now.to_i}.tar" Dir.chdir(dir) { `tar -cf #{tmp_path} *` } tmp_path end |
.unpack(file) ⇒ Object
15 16 17 18 |
# File 'lib/packer.rb', line 15 def self.unpack(file) return false unless File.extname(file) == '.tar' `tar -xf #{file}` end |