Sha256: b5cfe006689a18af1f76941ce09c8ba51fe4d227c352abded35409361b942d72

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

require 'rake'
require 'rake/tasklib'
require 'fileutils'

module Uploader
  class Tasks < ::Rake::TaskLib
    def initialize
      define
    end
  
    private
    def define
      namespace :uploader do
        
        task :app_env do
          Rake::Task[:environment].invoke if defined?(RAILS_ROOT)
        end
        
        desc 'Send all uploads to S3.  (Will only send uploads from a model named Upload)'
        task :upload_to_s3 do
          uploads = Upload.pending_s3_migrations
          uploads.each do |upload|
            upload.remote = upload.local
            upload.save!
          end
        end

        desc "Sync required files from uploader."
        task :sync do
          path = File.join(File.dirname(__FILE__), *%w[.. ..])
          daemons_path = "#{RAILS_ROOT}/lib/daemons"
          system "rsync -ruv #{path}/public ."
          system "rsync -ruv #{path}/db ."
          FileUtils.mkdir_p(daemons_path) unless File.directory?(daemons_path)          
          FileUtils.cp_r("#{path}/lib/daemons/amazonaws.rb", "#{RAILS_ROOT}/lib/daemons/amazonaws.rb")
        end
        
      end
    end
  end
end
Uploader::Tasks.new

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uploader-2.0.2 lib/uploader/tasks.rb
uploader-2.0.0 lib/uploader/tasks.rb
uploader-1.0.3 lib/uploader/tasks.rb
uploader-1.0.2 lib/uploader/tasks.rb
uploader-1.0.1 lib/uploader/tasks.rb
uploader-1.0.0 lib/uploader/tasks.rb