Sha256: 76776a62cbb46eaba75f798939233b8847d7cda609707928a35b4303a877bca7
Contents?: true
Size: 680 Bytes
Versions: 22
Compression:
Stored size: 680 Bytes
Contents
require "fileutils" module Mandy class Packer TMP_DIR = '/tmp/mandy' def self.pack(script, 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(script, tmp_path) 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.cleanup!(file) return false unless File.extname(file) == '.tar' `rm #{file}` end end end
Version data entries
22 entries across 22 versions & 1 rubygems