Sha256: c7b7daaf66dc3088c15e88991c8ff76601355e70871c12f579f45982b882d6af

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

require 'find'
 
module ImagePicker
  class Assets
    @source = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files'))
    @destination = RAILS_ROOT
    class << self 
      attr_accessor :source, :destination
    end
    
    def self.install
      paths = []
      Find.find(source) do |path|
        Find.prune if path =~ /\/\..+/
        Find.prune if path =~ /CVS/
        paths << path
      end
      paths.each do |path| 
        dest_path = path.gsub(source, destination)
        if File.directory?(path)
          FileUtils.mkdir_p(dest_path) unless File.exists?(dest_path)
        else
          FileUtils.cp(path, dest_path)
        end
      end
    rescue Exception => e
      puts "Error trying to copy files: #{e.inspect}"
      raise e
    end
    
  end  
end
 
namespace :image_picker do
  desc "Install files required by image_picker"
  task :install_files do  
    ImagePicker::Assets.install
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelargir-image_picker-0.5 tasks/image_picker.rake