Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
namespace :elvino do namespace :db do desc "Clone the production database to the local database." task :download, :roles => :db do require 'yaml' dbcfg = YAML::load_file('config/database.yml') pipe = IO.popen("gzcat | mysql5 -uroot #{dbcfg['development']['database']}", 'w') run "mysqldump -u#{dbcfg['production']['username']} -p --skip-lock-tables #{dbcfg['production']['database']} | gzip" do |channel, stream, data| if data =~ /^Enter password:/ channel.send_data "#{dbcfg['production']['password']}\n" next end pipe.write data break if stream == :err end pipe.close end end end
This paste will be private.
From the Design Piracy series on my blog: