Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move a bunch of internal methods to _underscore method names

  • Loading branch information...
commit e26f5fe5ef71a8505bc9691bd7e244ad2c523ab9 1 parent 60f1b23
@tilsammans authored
View
1  README.rdoc
@@ -43,6 +43,7 @@ A couple variables can be overridden by setting them in config/deploy.rb:
user # SSH user, defaults to nil, which falls back to your unix user
deploy_host # the host on which to run the db dump, falls back to your first db
+ dumpfile # remote pathname to dump the database in, defaults to tmp/${production}.sql.gz
Copyright (c) 2010-2011 Joost Baaij, released under the MIT license.
View
2  capistrano_transmit.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{capistrano_transmit}
- s.version = "0.2.7"
+ s.version = "0.2.8"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Joost Baaij"]
View
45 lib/capistrano/transmit.rb
@@ -4,29 +4,20 @@
Capistrano::Configuration.instance.load do
- _cset :user, nil
_cset(:deploy_host) { find_servers(:roles => :db).first.host }
- _cset(:db_config) { capture("cat #{current_path}/config/database.yml") }
- _cset(:db_remote) { YAML::load(db_config)['production'] }
- _cset(:db_local) { YAML::load_file("config/database.yml")['development'] }
- _cset(:dumpfile) { "#{current_path}/tmp/#{db_remote['database']}.sql.gz" }
+ _cset(:dumpfile) { "#{current_path}/tmp/#{_db_remote['database']}.sql.gz" }
after "transmit:get:mysql", "transmit:cleanup"
after "transmit:put:mysql", "transmit:cleanup"
- # Return just the deploy host when user not set.
- def _user_with_host
- user.nil? ? deploy_host : "#{user}@#{deploy_host}"
- end
-
namespace :transmit do
namespace :get do
desc 'Fetch the remote production database and overwrite your local development database with it'
task :mysql, :roles => :db do
- run "mysqldump --opt --quick --extended-insert --skip-lock-tables -u #{db_remote['username']} --password='#{db_remote['password']}' --host='#{db_remote['host']}' #{db_remote['database']} | gzip > #{dumpfile}"
+ run "mysqldump --opt --quick --extended-insert --skip-lock-tables -u #{_db_remote['username']} --password='#{_db_remote['password']}' --host='#{_db_remote['host']}' #{_db_remote['database']} | gzip > #{dumpfile}"
- system "rsync -vP #{_user_with_host}:#{dumpfile} tmp/#{db_local["database"]}.sql.gz"
- system "gunzip < tmp/#{db_local["database"]}.sql.gz | mysql -u #{db_local['username']} --password='#{db_local['password']}' --host='#{db_local['host']}' #{db_local['database']}"
+ system "rsync -vP #{_user_with_host}:#{dumpfile} tmp/#{_db_local["database"]}.sql.gz"
+ system "gunzip < tmp/#{_db_local["database"]}.sql.gz | mysql -u #{_db_local['username']} --password='#{_db_local['password']}' --host='#{_db_local['host']}' #{_db_local['database']}"
end
desc 'Fetch the assets from the production server to the development environment'
@@ -38,17 +29,37 @@ def _user_with_host
namespace :put do
desc 'Upload the local development database to the remote production database and overwrite it'
task :mysql, :roles => :db do
- system "mysqldump --opt -u #{db_local['username']} --password='#{db_local['password']}' --host='#{db_local['host']}' #{db_local['database']} > tmp/#{db_local['database']}.sql"
+ system "mysqldump --opt -u #{_db_local['username']} --password='#{_db_local['password']}' --host='#{_db_local['host']}' #{_db_local['database']} > tmp/#{_db_local['database']}.sql"
- system "rsync -vP tmp/#{db_local['database']}.sql #{_user_with_host}:#{dumpfile}"
- run "mysql -u #{db_remote['username']} --password='#{db_remote['password']}' --host='#{db_remote['host']}' #{db_remote['database']} < #{dumpfile}"
+ system "rsync -vP tmp/#{_db_local['database']}.sql #{_user_with_host}:#{dumpfile}"
+ run "mysql -u #{_db_remote['username']} --password='#{_db_remote['password']}' --host='#{_db_remote['host']}' #{_db_remote['database']} < #{dumpfile}"
end
end
task :cleanup do
run "rm #{dumpfile}"
- system "rm tmp/#{db_local['database']}.sql.gz"
+ system "rm tmp/#{_db_local['database']}.sql.gz"
end
end
+ # Return just the deploy host when user not set.
+ def _user_with_host
+ user.nil? ? deploy_host : "#{user}@#{deploy_host}"
+ end
+
+ # Output of the entire database.yml on the remote server.
+ def _db_config
+ capture("cat #{current_path}/config/database.yml")
+ end
+
+ # Production database configuration hash.
+ def _db_remote
+ YAML::load(_db_config)['production']
+ end
+
+ # Development database configuration hash.
+ def _db_local
+ YAML::load_file("config/database.yml")['development']
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.