Sha256: 8a12bb5df3f04ef4a7648e0d805416e7f5205da5df3ce40b2525e6521014e673

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

require 'ftools'

class FeatureConsumer
  attr_accessor :package_dir, :consumer_dir, :application_name

  def execute()
    raise "The directory containing the packages has not been specified" if @package_dir.nil?
    raise "The directory packages should be copied to has not been specified" if @consumer_dir.nil?
    raise "The name of the application has not been specified" if @application_name.nil?

    Dir[@package_dir + "/#{@application_name}/**/**"].each do |resource|
      raise "Could not find the app name in the resource type" if resource.match(/.*\/#{@application_name}\/(.*)/).nil?
      
      destination = File.expand_path(File.join(@consumer_dir, $1))
      next if File.directory?(resource)

      dir = File.expand_path(File.dirname(destination))
      FileUtils.mkdir_p(dir) if false == File.exists?(dir)

      puts "Copying #{resource} to #{destination}"
      File.copy(resource, destination)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
seabass-0.2.1 lib/seabass/feature_consumer.rb
seabass-0.2.0 lib/seabass/feature_consumer.rb