Sha256: a4ebbbac870b02af8d44abbcc7ad347093256d41fe4b8bf008ad6afc14e34c33

Contents?: true

Size: 1.61 KB

Versions: 8

Compression:

Stored size: 1.61 KB

Contents

require 'boxgrinder-build/plugins/delivery/base/base-delivery-plugin'

module BoxGrinder
  class LocalPlugin < BaseDeliveryPlugin
    def info
      {
              :name       => :local,
              :type       => [:local],
              :full_name  => "Local file system"
      }
    end

    def after_init
      set_default_config_value('overwrite', true)
      set_default_config_value('package', true)
    end

    def execute(deliverables, type = :local)      
      validate_plugin_config( [ 'path' ], 'http://community.jboss.org/docs/DOC-15216' )

      files = []

      if @plugin_config['package']
        files <<  PackageHelper.new(@config, @appliance_config, {:log => @log, :exec_helper => @exec_helper}).package(deliverables)
      else
        files << deliverables[:disk]

        [:metadata, :other].each do |deliverable_type|
          deliverables[deliverable_type].each_value do |file|
            files << file
          end
        end
      end

      if @plugin_config['overwrite'] or !already_delivered?(files)
        FileUtils.mkdir_p @plugin_config['path']

        @log.debug "Copying files to destination..."

        files.each do |file|
          @log.debug "Copying #{file}..."
          FileUtils.cp(file, @plugin_config['path'])
        end
        @log.info "Appliance delivered to #{@plugin_config['path']}."
      else
        @log.info "Appliance already delivered to #{@plugin_config['path']}."
      end
    end

    def already_delivered?(files)
      files.each do |file|
        return false unless File.exists?("#{@plugin_config['path']}/#{File.basename(file)}")
      end
      true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
boxgrinder-build-0.4.1 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.4.0 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.8 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.7 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.6 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.5 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.3 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
boxgrinder-build-0.3.2 lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb