Created
November 15, 2012 13:19
-
-
Save mirakui/4078624 to your computer and use it in GitHub Desktop.
Fast deploy using capistrano_rsync_with_remote_cache and turbo-sprockets-rails3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements: | |
# https://github.com/vigetlabs/capistrano_rsync_with_remote_cache | |
# https://github.com/ndbroadbent/turbo-sprockets-rails3 | |
require 'capistrano/recipes/deploy/strategy/rsync_with_remote_cache' | |
Capistrano::Deploy::Strategy::RsyncWithRemoteCache.class_eval do | |
def deploy! | |
update_local_cache | |
prepare_assets | |
update_remote_cache | |
finalize_assets | |
copy_remote_cache | |
end | |
def prepare_assets | |
system([ | |
"test ! -d #{assets_cache} && mkdir -p #{assets_cache}", | |
"mv #{assets_cache} #{assets_path}", | |
"cd #{local_cache_path}", | |
"RAILS_ENV=#{configuration[:rails_env]} bundle exec rake assets:precompile" | |
].join(';')) | |
end | |
def finalize_assets | |
system("mv #{assets_path} #{assets_cache}") | |
end | |
def assets_cache | |
File.expand_path(configuration[:assets_cache] || '.assets_cache') | |
end | |
def assets_path | |
File.expand_path(File.join(local_cache_path, configuration[:assets_path] || 'public/assets')) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment