Sha256: b15c2e9b362369790f2fb385c1c853e45f0a4283876a8bccd074853202bc0c8e

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

Capistrano::Configuration.instance(:must_exist).load do
    namespace :local do
      desc <<-DESC
        Rsyncs the your production content (identified by the :shared_content and
        :content_directories properties) from a deployable environment (RAILS_ENV) to the local filesystem.
      DESC
      task :rsync_content do
        from = ENV['FROM'] || 'production'
        if exists?(:domain)
          remote_domain = fetch(:domain)
        end
        if exists?(:rsync_domain)
          remote_domain =  fetch(:rsync_domain)
        end
        if exists?(:user)
          remote_user =  fetch(:user)
        end
        if exists?(:port)
          remote_port =  "-p #{fetch(:user)}"
        end
        system("rsync -avz -e 'ssh #{remote_port}' '#{[remote_user, remote_domain].join("@")}:#{content_path}' '#{rails_root}/tmp/'")
      end

      desc <<-DESC
        Creates a symlink to public/system from tmp/system
      DESC
      task :rsync_restore_content do
        # from = ENV['FROM'] || 'production'
        print "\033[1;45m Linking Assets to public directory \033[0m\n"
        system "ln -nfs #{rails_root}/tmp/system #{rails_root}/public/system"
      end


      desc <<-DESC
        Wrapper for local:rsync_content and local:rsync_restore_content
        $> cap local:rsync RAILS_ENV=production
      DESC
      task :rsync do
        transaction do
          rsync_content
          rsync_restore_content
        end
      end
    end  
end    

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blavosync-0.5.1 lib/blavosync/recipes/content_rsync.rb