Class: BoxGrinder::PackageHelper
- Inherits:
-
Object
- Object
- BoxGrinder::PackageHelper
- Defined in:
- lib/boxgrinder-build/helpers/package-helper.rb
Instance Method Summary collapse
-
#initialize(config, appliance_config, options = {}) ⇒ PackageHelper
constructor
A new instance of PackageHelper.
- #package(dir, package, type = :tar) ⇒ Object
Constructor Details
#initialize(config, appliance_config, options = {}) ⇒ PackageHelper
23 24 25 26 27 28 29 |
# File 'lib/boxgrinder-build/helpers/package-helper.rb', line 23 def initialize(config, appliance_config, = {}) @config = config @appliance_config = appliance_config @log = [:log] || LogHelper.new @exec_helper = [:exec_helper] || ExecHelper.new(:log => @log) end |
Instance Method Details
#package(dir, package, type = :tar) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/boxgrinder-build/helpers/package-helper.rb', line 31 def package(dir, package, type = :tar) if File.exists?(package) @log.info "Package of #{type} type for #{@appliance_config.name} appliance already exists, skipping." return package end @log.info "Packaging #{@appliance_config.name} appliance to #{type}..." case type when :tar package_name = File.basename(package, '.tgz') symlink = "#{File.dirname(package)}/#{package_name}" FileUtils.ln_s(File.(dir), symlink) @exec_helper.execute "tar -C '#{File.dirname(package)}' -hcvzf '#{package}' '#{package_name}'" FileUtils.rm(symlink) else raise "Specified format: '#{type}' is currently unsupported." end @log.info "Appliance #{@appliance_config.name} packaged." package end |