Module: LocalUtils

Defined in:
lib/capistrano-extensions/deploy.rb

Instance Method Summary collapse

Instance Method Details

#current_timestampObject



211
212
213
# File 'lib/capistrano-extensions/deploy.rb', line 211

def current_timestamp
  @current_timestamp ||= Time.now.to_i
end

#local_content_backup_dir(args = {}) ⇒ Object



221
222
223
224
225
# File 'lib/capistrano-extensions/deploy.rb', line 221

def local_content_backup_dir(args={})
  env = args[:env] || rails_env
  timestamp = args[:timestamp] || current_timestamp
  "#{tmp_dir}/#{application}-#{env}-content-#{timestamp}"
end

#local_db_backup_file(args = {}) ⇒ Object



215
216
217
218
219
# File 'lib/capistrano-extensions/deploy.rb', line 215

def local_db_backup_file(args = {})
  env = args[:env] || rails_env
  timestamp = args[:timestamp] || current_timestamp
  "#{tmp_dir}/#{application}-#{env}-db-#{timestamp}.sql"
end

#most_recent_local_backup(env, type) ⇒ Object



231
232
233
# File 'lib/capistrano-extensions/deploy.rb', line 231

def most_recent_local_backup(env, type)
  retrieve_local_files(env, type).first.to_i
end

#retrieve_local_files(env, type) ⇒ Object



227
228
229
# File 'lib/capistrano-extensions/deploy.rb', line 227

def retrieve_local_files(env, type)
  `ls -r #{tmp_dir} | awk -F"-" '{ if ($2 ~ /#{env}/ && $3 ~ /#{type}/) { print $4; } }'`.split(' ')
end