module RidgepoleRake::Brancher::Command

Private Instance Methods

add_config() click to toggle source

@note override

# File lib/ridgepole_rake/ext/brancher.rb, line 25
def add_config
  stash.push('--config', database_configuration)
end
add_diff_action() click to toggle source

@note override

# File lib/ridgepole_rake/ext/brancher.rb, line 57
def add_diff_action
  stash.push('--diff', database_configuration, config.ridgepole.fetch(:file))
end
database_configuration() click to toggle source
# File lib/ridgepole_rake/ext/brancher.rb, line 29
def database_configuration
  if config.brancher[:use] && (yaml = database_configuration_with_brancher)
    action.eql?(:diff) ? remove_first_line_in_yaml(yaml) : yaml
  else
    config.ridgepole.fetch(:config)
  end
end
database_configuration_with_brancher() click to toggle source
# File lib/ridgepole_rake/ext/brancher.rb, line 37
def database_configuration_with_brancher
  configurations = load_configurations
  env = config.ridgepole.fetch(:env)

  ::Brancher::DatabaseRenameService.rename!(configurations, env)

  configurations[env].to_yaml
rescue
  nil
end
load_configurations() click to toggle source
# File lib/ridgepole_rake/ext/brancher.rb, line 48
def load_configurations
  YAML.load(ERB.new(File.read(config.ridgepole.fetch(:config))).result)
end
remove_first_line_in_yaml(yaml) click to toggle source
# File lib/ridgepole_rake/ext/brancher.rb, line 52
def remove_first_line_in_yaml(yaml)
  yaml.sub(/\A---\n/, '')
end