Class BoxGrinder::PackageHelper
In: lib/boxgrinder-build/helpers/package-helper.rb
lib/boxgrinder-build/helpers/package-helper.rb
Parent: Object

Methods

new   new   package   package  

Public Class methods

[Source]

    # File lib/boxgrinder-build/helpers/package-helper.rb, line 23
23:     def initialize(config, appliance_config, options = {})
24:       @config = config
25:       @appliance_config = appliance_config
26: 
27:       @log = options[:log] || LogHelper.new
28:       @exec_helper = options[:exec_helper] || ExecHelper.new(:log => @log)
29:     end

[Source]

    # File lib/boxgrinder-build/helpers/package-helper.rb, line 23
23:     def initialize(config, appliance_config, options = {})
24:       @config = config
25:       @appliance_config = appliance_config
26: 
27:       @log = options[:log] || LogHelper.new
28:       @exec_helper = options[:exec_helper] || ExecHelper.new(:log => @log)
29:     end

Public Instance methods

[Source]

    # File lib/boxgrinder-build/helpers/package-helper.rb, line 31
31:     def package(dir, package, type = :tar)
32:       if File.exists?(package)
33:         @log.info "Package of #{type} type for #{@appliance_config.name} appliance already exists, skipping."
34:         return package
35:       end
36: 
37:       @log.info "Packaging #{@appliance_config.name} appliance to #{type}..."
38: 
39:       case type
40:         when :tar
41:           package_name = File.basename(package, '.tgz')
42:           symlink = "#{File.dirname(package)}/#{package_name}"
43: 
44:           FileUtils.ln_s(File.expand_path(dir), symlink)
45:           @exec_helper.execute "tar -C '#{File.dirname(package)}' -hcvzf '#{package}' '#{package_name}'"
46:           FileUtils.rm(symlink)
47:         else
48:           raise "Specified format: '#{type}' is currently unsupported."
49:       end
50: 
51:       @log.info "Appliance #{@appliance_config.name} packaged."
52: 
53:       package
54:     end

[Source]

    # File lib/boxgrinder-build/helpers/package-helper.rb, line 31
31:     def package(dir, package, type = :tar)
32:       if File.exists?(package)
33:         @log.info "Package of #{type} type for #{@appliance_config.name} appliance already exists, skipping."
34:         return package
35:       end
36: 
37:       @log.info "Packaging #{@appliance_config.name} appliance to #{type}..."
38: 
39:       case type
40:         when :tar
41:           package_name = File.basename(package, '.tgz')
42:           symlink = "#{File.dirname(package)}/#{package_name}"
43: 
44:           FileUtils.ln_s(File.expand_path(dir), symlink)
45:           @exec_helper.execute "tar -C '#{File.dirname(package)}' -hcvzf '#{package}' '#{package_name}'"
46:           FileUtils.rm(symlink)
47:         else
48:           raise "Specified format: '#{type}' is currently unsupported."
49:       end
50: 
51:       @log.info "Appliance #{@appliance_config.name} packaged."
52: 
53:       package
54:     end

[Validate]