class Object

Constants

CENSORED_KEYS

configure log censoring, so that password and AWS secret keys don't end up in the logs

Public Instance Methods

cmd(cmd) click to toggle source
# File lib/desmond/capistrano.rb, line 6
def cmd(cmd)
  "cd #{current_path};#{env} #{workers} #{que_command} #{cmd} #{pid_dir}"
end
copy_migration(source_file, dest_folder) click to toggle source

copy migration source_file to migrations folder dest_folder if it doesn't exist ther yet

# File lib/desmond/rake.rb, line 36
def copy_migration(source_file, dest_folder)
  # check if migration already exists
  migration_exists = migrations(dest_folder).map do |file|
    File.basename(file).split('_')[1..-1].join('_').eql?(File.basename(source_file))
  end.any?
  return if migration_exists

  # copy migration file
  migration_number = next_migration_number(dest_folder)
  base_migration_name = File.basename source_file
  migration_name = "#{migration_number}_#{base_migration_name}"
  dest_file = File.join dest_folder, migration_name
  FileUtils.cp(source_file, dest_file)
end
migrations(dirname) click to toggle source

returns migration files in the given directory dirname

# File lib/desmond/rake.rb, line 7
def migrations(dirname)
  Dir.foreach(dirname).select do |entry|
    !entry.start_with?('.')
  end
end
next_migration_number(dirname) click to toggle source

returns the next migration number to use from the given directory dirname

# File lib/desmond/rake.rb, line 16
def next_migration_number(dirname)
  current_migration_number_str = migrations(dirname).map do |file|
    File.basename(file).split('_').first
  end.max || '0000'
  current_migration_number = current_migration_number_str.to_i

  num_digits = current_migration_number_str.size
  if num_digits > 5
    # timestamp format
    [Time.now.utc.strftime('%Y%m%d%H%M%S'), format('%.14d', current_migration_number + 1)].max
  else
    # counter format
    format("%.#{num_digits}d", current_migration_number + 1)
  end
end
pid_dir() click to toggle source
# File lib/desmond/capistrano.rb, line 2
def pid_dir
  fetch(:pid_dir, "#{fetch(:release_path)}/tmp/pids")
end