Sha256: 883b7b02fc10571b2d90abddb624bdf3df007898459cecf9212c1bd65c2801d2
Contents?: true
Size: 751 Bytes
Versions: 5
Compression:
Stored size: 751 Bytes
Contents
require "fileutils" module Mandy class Packer TMP_DIR = '/tmp/mandy' def self.pack(dir, gemfile) tmp_path = "#{TMP_DIR}/packed-job-#{Time.now.to_i}" FileUtils.mkdir_p(tmp_path) to_be_copied = File.file?(dir) ? dir : File.join(dir, '*') FileUtils.cp_r(Dir.glob(to_be_copied), tmp_path) FileUtils.cp_r(gemfile, tmp_path) Dir.chdir(tmp_path) { `gem bundle` } Dir.chdir(tmp_path) { `tar -cf bundle.tar *` } File.join(tmp_path, 'bundle.tar') end def self.unpack(file) return false unless File.extname(file) == '.tar' `tar -xf #{file}` end def self.cleanup!(file) return false unless File.extname(file) == '.tar' `rm #{file}` end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
mandy-0.3.5 | lib/packer.rb |
mandy-0.3.4 | lib/packer.rb |
mandy-0.3.3 | lib/packer.rb |
mandy-0.3.2 | lib/packer.rb |
mandy-0.3.1 | lib/packer.rb |