class Database::Remote

Public Class Methods

new(cap_instance) click to toggle source
Calls superclass method Database::Base::new
# File lib/mysql.rb, line 35
def initialize(cap_instance)
  super(cap_instance)
  @cap.run("cat #{@cap.current_path}/config/database.yml") { |c, s, d| @config = YAML.load(d)[(@cap.rails_env || 'production').to_s] }
end

Public Instance Methods

download(local_file = " click to toggle source
# File lib/mysql.rb, line 45
def download(local_file = "#{output_file}")
  remote_file = "#{@cap.current_path}/#{output_file}"
  @cap.get remote_file, local_file
end
dump() click to toggle source
# File lib/mysql.rb, line 40
def dump
  @cap.run "cd #{@cap.current_path}; #{dump_cmd} | bzip2 - - > #{output_file}"
  self
end
load(file, cleanup) click to toggle source

cleanup = true removes the mysqldump file after loading, false leaves it in db/

# File lib/mysql.rb, line 51
def load(file, cleanup)
  unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2'))
  @cap.run "cd #{@cap.current_path}; bunzip2 -f #{file} && RAILS_ENV=#{@cap.rails_env} #{rake} db:drop db:create && #{import_cmd(unzip_file)}"
  File.unlink(unzip_file) if cleanup
end