config/deploy.rb
def upload_config_file( filename )

    # work out some filenames
    local  = 'config/' + filename.gsub(/^(\w+)\.(\w+)$/, '\1.deploy.\2')
    remote = "#{shared_path}/config/#{filename}"

    # check
    return if test '[ -f #{remote} ]'

    # munge + get a key
    config = YAML::load_file( local )
    candidates = config.keys.reject{ |k| k == 'default' }
    victim = candidates.first

    # write
    config[fetch( :stage.to_s )] = config[victim].dup
    config.delete( victim)
    config.delete( 'default' ) if config.key?( 'default' )

    # upload
    io = StringIO.new( YAML.dump( config ))
    upload! io, remote

  end
# Uploads a deployable file, switching out the environment name as necessary
Uploads a deployable file, switching out the environment name as necessary
Uploads a deployable file switching out the environment name as necessary
def upload_config_file( filename )
    local  = 'config/' + filename.gsub(/^(\w+)\.(\w+)$/, '\1.deploy.\2')
    remote = "#{shared_path}/config/#{filename}"
    return if test '[ -f #{remote} ]'
    config = YAML::load_file( local )
    candidates = config.keys.reject{ |k| k == 'default' }
    victim = candidates.first
    config[fetch( :stage.to_s )] = config[victim].dup
    config.delete( victim)
    config.delete( 'default' ) if config.key?( 'default' )
    io = StringIO.new( YAML.dump( config ))
    upload! io, remote
  end
def upload_config_file ( filename ) local = 'config/' + filename . gsub ( / ^( \w +) \. ( \w +)$ / , '\1.deploy.\2' ) remote = "#{shared_path}/config/#{filename}" return if test '[ -f #{remote} ]' config = YAML :: load_file ( local ) candidates = config . keys . reject { | k | k == 'default' } victim = candidates . first config [ fetch ( :stage . to_s ) ] = config [ victim ] . dup config . delete ( victim ) config . delete ( 'default' ) if config . key? ( 'default' ) io = StringIO . new ( YAML . dump ( config ) ) upload! io , remote end
Uploads a deployable file, switching out the environment name as necessary
Uploads a deployable file switching out the environment name as necessary
# work out some filenames # check # munge + get a key # write # upload
filename