Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capistrano 3 support PR #23 from @sauliusgrigaitis
- Loading branch information
Sébastien Gruhier
committed
Feb 9, 2014
1 parent
e7775db
commit fe8749e
Showing
7 changed files
with
108 additions
and
123 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,102 @@ | ||
if Capistrano::Configuration.instance(false) | ||
|
||
Capistrano::Configuration.instance(true).load do |instance| | ||
|
||
require File.expand_path("#{File.dirname(__FILE__)}/util") | ||
require File.expand_path("#{File.dirname(__FILE__)}/database") | ||
require File.expand_path("#{File.dirname(__FILE__)}/asset") | ||
|
||
instance.set :local_rails_env, ENV['RAILS_ENV'] || 'development' unless exists?(:local_rails_env) | ||
instance.set :rails_env, 'production' unless exists?(:rails_env) | ||
instance.set :db_local_clean, false unless exists?(:db_local_clean) | ||
instance.set :assets_dir, 'system' unless exists?(:assets_dir) | ||
instance.set :local_assets_dir, 'public' unless exists?(:local_assets_dir) | ||
|
||
namespace :db do | ||
namespace :remote do | ||
desc 'Synchronize your remote database using local database data' | ||
task :sync, :roles => :db do | ||
if Util.prompt 'Are you sure you want to REPLACE THE REMOTE DATABASE with local database' | ||
Database.local_to_remote(instance) | ||
end | ||
require File.expand_path("#{File.dirname(__FILE__)}/util") | ||
require File.expand_path("#{File.dirname(__FILE__)}/database") | ||
require File.expand_path("#{File.dirname(__FILE__)}/asset") | ||
|
||
set :local_rails_env, ENV['RAILS_ENV'] || 'development' unless fetch(:local_rails_env) | ||
set :rails_env, 'production' unless fetch(:rails_env) | ||
set :db_local_clean, false unless fetch(:db_local_clean) | ||
set :assets_dir, 'system' unless fetch(:assets_dir) | ||
set :local_assets_dir, 'public' unless fetch(:local_assets_dir) | ||
|
||
namespace :db do | ||
namespace :remote do | ||
desc 'Synchronize your remote database using local database data' | ||
task :sync do | ||
on roles(:db) do | ||
if Util.prompt 'Are you sure you want to REPLACE THE REMOTE DATABASE with local database' | ||
Database.local_to_remote(self) | ||
end | ||
end | ||
end | ||
end | ||
|
||
namespace :local do | ||
desc 'Synchronize your local database using remote database data' | ||
task :sync, :roles => :db do | ||
puts "Local database: #{Database::Local.new(instance).database}" | ||
if Util.prompt 'Are you sure you want to erase your local database with server database' | ||
Database.remote_to_local(instance) | ||
end | ||
namespace :local do | ||
desc 'Synchronize your local database using remote database data' | ||
task :sync do | ||
on roles(:db) do | ||
puts "Local database: #{Database::Local.new(self).database}" | ||
if Util.prompt 'Are you sure you want to erase your local database with server database' | ||
Database.remote_to_local(self) | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc 'Synchronize your local database using remote database data' | ||
task :pull do | ||
db.local.sync | ||
end | ||
desc 'Synchronize your local database using remote database data' | ||
task :pull => "db:local:sync" | ||
|
||
desc 'Synchronize your remote database using local database data' | ||
task :push do | ||
db.remote.sync | ||
end | ||
end | ||
desc 'Synchronize your remote database using local database data' | ||
task :push => "db:remote:sync" | ||
end | ||
|
||
namespace :assets do | ||
namespace :remote do | ||
desc 'Synchronize your remote assets using local assets' | ||
task :sync, :roles => :app do | ||
puts "Assets directories: #{assets_dir}" | ||
if Util.prompt "Are you sure you want to erase your server assets with local assets" | ||
Asset.local_to_remote(instance) | ||
end | ||
namespace :assets do | ||
namespace :remote do | ||
desc 'Synchronize your remote assets using local assets' | ||
task :sync do | ||
on roles(:app) do | ||
puts "Assets directories: #{fetch(:assets_dir)}" | ||
if Util.prompt "Are you sure you want to erase your server assets with local assets" | ||
Asset.local_to_remote(self) | ||
end | ||
end | ||
end | ||
end | ||
|
||
namespace :local do | ||
desc 'Synchronize your local assets using remote assets' | ||
task :sync, :roles => :app do | ||
puts "Assets directories: #{local_assets_dir}" | ||
if Util.prompt "Are you sure you want to erase your local assets with server assets" | ||
Asset.remote_to_local(instance) | ||
end | ||
namespace :local do | ||
desc 'Synchronize your local assets using remote assets' | ||
task :sync do | ||
on roles(:app) do | ||
puts "Assets directories: #{fetch(:local_assets_dir)}" | ||
if Util.prompt "Are you sure you want to erase your local assets with server assets" | ||
Asset.remote_to_local(self) | ||
end | ||
end | ||
|
||
desc 'Synchronize your local assets using remote assets' | ||
task :pull do | ||
assets.local.sync | ||
end | ||
|
||
desc 'Synchronize your remote assets using local assets' | ||
task :push do | ||
assets.remote.sync | ||
end | ||
end | ||
end | ||
|
||
namespace :app do | ||
namespace :remote do | ||
desc 'Synchronize your remote assets AND database using local assets and database' | ||
task :sync do | ||
if Util.prompt "Are you sure you want to REPLACE THE REMOTE DATABASE AND your remote assets with local database and assets(#{assets_dir})" | ||
Database.local_to_remote(instance) | ||
Asset.local_to_remote(instance) | ||
end | ||
end | ||
end | ||
desc 'Synchronize your local assets using remote assets' | ||
task :pull => "assets:local:sync" | ||
|
||
namespace :local do | ||
desc 'Synchronize your local assets AND database using remote assets and database' | ||
task :sync do | ||
puts "Local database : #{Database::Local.new(instance).database}" | ||
puts "Assets directories : #{local_assets_dir}" | ||
if Util.prompt "Are you sure you want to erase your local database AND your local assets with server database and assets(#{assets_dir})" | ||
Database.remote_to_local(instance) | ||
Asset.remote_to_local(instance) | ||
end | ||
end | ||
end | ||
desc 'Synchronize your remote assets using local assets' | ||
task :push => "assets:remote:sync" | ||
end | ||
|
||
desc 'Synchronize your local assets AND database using remote assets and database' | ||
task :pull do | ||
app.local.sync | ||
namespace :app do | ||
namespace :remote do | ||
desc 'Synchronize your remote assets AND database using local assets and database' | ||
task :sync do | ||
if Util.prompt "Are you sure you want to REPLACE THE REMOTE DATABASE AND your remote assets with local database and assets(#{assets_dir})" | ||
Database.local_to_remote(self) | ||
Asset.local_to_remote(self) | ||
end | ||
end | ||
end | ||
|
||
desc 'Synchronize your remote assets AND database using local assets and database' | ||
task :push do | ||
app.remote.sync | ||
namespace :local do | ||
desc 'Synchronize your local assets AND database using remote assets and database' | ||
task :sync do | ||
puts "Local database : #{Database::Local.new(self).database}" | ||
puts "Assets directories : #{fetch(:local_assets_dir)}" | ||
if Util.prompt "Are you sure you want to erase your local database AND your local assets with server database and assets(#{assets_dir})" | ||
Database.remote_to_local(self) | ||
Asset.remote_to_local(self) | ||
end | ||
|
||
end | ||
end | ||
|
||
desc 'Synchronize your local assets AND database using remote assets and database' | ||
task :pull => "app:local:sync" | ||
|
||
desc 'Synchronize your remote assets AND database using local assets and database' | ||
task :push => "app:remote:sync" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
module Util | ||
def self.prompt(msg, prompt = "(y)es, (n)o ") | ||
answer = Capistrano::CLI.ui.ask("#{msg} #{prompt} ? ") do |q| | ||
q.overwrite = false | ||
q.validate = /^y$|^yes$|^n$|^no$/i | ||
q.responses[:not_valid] = prompt | ||
end | ||
(answer =~ /^y$|^yes$/i) == 0 | ||
ask(:answer, "#{msg} #{prompt} ? ") | ||
(fetch(:answer) =~ /^y$|^yes$/i) == 0 | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module CapistranoDbTasks | ||
VERSION = "0.2.1" | ||
VERSION = "0.3" | ||
end |