Sha256: 0ee3cee72fe619fd5588481f7f3aeea165096ab3183c841af7cea56f79e9aee1

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

Capistrano::Configuration.instance(:must_exist).load do
  namespace :mailer do
    namespace :setup do
      desc "Upload configs"
      task :default, :roles => :app do
        if exists?(:mailer_setup_settings)
          set(:recipe_settings) { mailer_template_settings }
          put template.render(_mailer_template), _mailer_remote_file
        else
          puts "[FATAL] - Mailers template settings were not found"
          abort
        end
      end

      desc "Download configs"
      task :get, :roles => :db do
        download _mailer_remote_file, _mailer_local_file
      end
    end
  end

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

  def mailer_template_settings
    DeepToHash.to_hash mailer_setup_defaults.deep_merge(fetch(:mailer_setup_settings, {}))
  end

  def _mailer_remote_file
    File.join(shared_path, fetch(:mailer_remote_file, 'config/mailers.yml'))
  end

  def _mailer_local_file
    File.join(local_rails_root, fetch(:mailer_local_file, 'config/mailers.yml'))
  end

  def _mailer_template
    fetch(:mailer_template, 'mailers.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/mailer.rb
marcosgz-cap-recipe-0.0.13 lib/capistrano/recipes/mailer.rb
marcosgz-cap-recipe-0.0.12 lib/capistrano/recipes/mailer.rb
marcosgz-cap-recipe-0.0.11 lib/capistrano/recipes/mailer.rb
marcosgz-cap-recipe-0.0.10 lib/capistrano/recipes/mailer.rb
marcosgz-cap-recipe-0.0.9 lib/capistrano/recipes/mailer.rb