Sha256: 5e51b851e3b06456dc811515480d763864ef58d6c5f5c707a1526ee6d72b3e88

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

Capistrano::Configuration.instance(:must_exist).load do
  namespace :uploader do
    namespace :setup do
      desc "Upload configs"
      task :default, :roles => :app do
        if exists?(:uploader_setup_settings)
          set(:recipe_settings) { uploader_template_settings }
          put template.render(_uploader_template), _uploader_remote_file
        else
          puts "[FATAL] - Uploader template settings were not found"
          abort
        end
      end

      desc "Download configs"
      task :get, :roles => :db do
        download _uploader_remote_file, _uploader_local_file
      end
    end

  end

  def uploader_setup_defaults
    HashWithIndifferentAccess.new({'common'=>{}}.reverse_merge(default_rails_environments_hash))
  end

  def uploader_template_settings
    DeepToHash.to_hash uploader_setup_defaults.deep_merge(fetch(:uploader_setup_settings, {}))
  end

  def _uploader_remote_file
    File.join(shared_path, fetch(:uploader_remote_file, 'config/uploader.yml'))
  end

  def _uploader_local_file
    File.join(local_rails_root, fetch(:uploader_local_file, 'config/uploader.yml'))
  end

  def _uploader_template
    fetch(:uploader_template, 'uploader.yml.erb')
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
marcosgz-cap-recipe-0.0.14 lib/capistrano/recipes/uploader.rb
marcosgz-cap-recipe-0.0.13 lib/capistrano/recipes/uploader.rb
marcosgz-cap-recipe-0.0.12 lib/capistrano/recipes/uploader.rb
marcosgz-cap-recipe-0.0.11 lib/capistrano/recipes/uploader.rb
marcosgz-cap-recipe-0.0.10 lib/capistrano/recipes/uploader.rb
marcosgz-cap-recipe-0.0.9 lib/capistrano/recipes/uploader.rb