lib/ms_deploy/recipes/assets.rb in ms_deploy-0.2.3 vs lib/ms_deploy/recipes/assets.rb in ms_deploy-0.2.4

- old
+ new

@@ -1,18 +1,26 @@ Capistrano::Configuration.instance.load do - load 'deploy/assets' # http://guides.rubyonrails.org/asset_pipeline.html#in-production + load 'deploy/assets' unless ENV['NOASSETS'] # http://guides.rubyonrails.org/asset_pipeline.html#in-production - # http://www.bencurtis.com/2011/12/skipping-asset-compilation-with-capistrano/ - namespace :deploy do - namespace :assets do - #task :precompile, :roles => :web, :except => { :no_release => true } do - # from = source.next_revision(current_revision) - # if capture("cd #{latest_release} && #{source.local.log(from)} lib/assets/ vendor/assets/ app/assets/ | wc -l").to_i > 0 - # run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} - # else - # logger.info "Skipping asset pre-compilation because there were no asset changes" - # end - #end + set :assets_dir, 'system' unless exists?(:assets_dir) + set :local_assets_dir, 'public' unless exists?(:local_assets_dir) + + namespace :assets do + namespace :local do + desc 'Synchronize your local assets using remote assets' + task :sync do + if Util.prompt "Are you sure you want to erase your local assets with server assets" + servers = find_servers :roles => :app + [assets_dir].flatten.each do |dir| + system("rsync -a --del --progress --rsh='ssh -p #{fetch(:ssh_port, 22)}' #{user}@#{servers.first}:#{shared_path}/#{dir}/ #{local_assets_dir}") + end + end + end + end + + desc 'Synchronize your local assets using remote assets' + task :pull do + assets.local.sync end end end