Sha256: afffb44a16e10b1d054e73af5fa9e425024dea99b96f8f0681da52d7c544dbf0

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require 'stringio'

namespace :figaro do
  desc <<-DESC
    Upload application config to the server

    You can override any of these defaults by setting the variables shown below.

    set :figaro_target, -> { shared_path.join('application.yml') }
    set :figaro_config, -> { release_path.join('config', 'application.yml') }
    set :figaro_to_env, false
  DESC
  task :upload do
    figaro_data = nil

    run_locally do
      figaro_stage = fetch(:stage)
      figaro_tmp   = "figaro-#{figaro_stage}"

      if fetch(:figaro_to_env)
        figaro_cmd = %Q(Figaro.vars("#{figaro_stage}").split)
      else
        figaro_cmd = %Q(Figaro.env("#{figaro_stage}").to_yaml)
      end

      figaro_data = capture(:rails, "runner 'puts #{figaro_cmd}'")
    end

    if figaro_data
      on roles(fetch(:figaro_roles)) do
        upload! StringIO.new(figaro_data), fetch(:figaro_target)
      end
    end
  end

  desc <<-DESC
    Symlink the application config to the release_path
  DESC
  task :symlink do
    on roles(fetch(:figaro_roles)) do
      execute :ln, '-sf', fetch(:figaro_target), fetch(:figaro_config)
    end
  end
end

namespace :load do
  task :defaults do
    set :figaro_target, -> { shared_path.join('application.yml') }
    set :figaro_config, -> { release_path.join('config', 'application.yml') }
    set :figaro_to_env, false
    set :figaro_roles, :app
  end
end

namespace :deploy do
  after :updating, 'figaro:symlink'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mascherano-1.1.0 lib/mascherano/tasks/figaro.cap
mascherano-1.0.4 lib/mascherano/tasks/figaro.cap