Sha256: 94fd2070f354f294f328c4530acc4b504fa402cb79d57509274ea05c2a30f4f6

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

Capistrano::Configuration.instance(:must_exist).load do
  namespace :tire do
    namespace :setup do
      desc "Upload configs"
      task :default, :roles => :app do
        if exists?(:tire_setup_settings)
          set(:recipe_settings) { tire_template_settings }
          put template.render(_tire_template), _tire_remote_file
        else
          puts "[FATAL] - Tire template settings were not found"
          abort
        end
      end

      desc "Download configs"
      task :get, :roles => :db do
        download _tire_remote_file, _tire_local_file
      end
    end
  end

  def tire_setup_defaults
    HashWithIndifferentAccess.new({
      'common'=>{
        'url' => 'http://localhost:9200'
      }
    }.reverse_merge(default_rails_environments_hash))
  end

  def tire_template_settings
    DeepToHash.to_hash tire_setup_defaults.deep_merge(fetch(:tire_setup_settings, {}))
  end

  def _tire_remote_file
    File.join(shared_path, fetch(:tire_remote_file, 'config/tire.yml'))
  end

  def _tire_local_file
    File.join(local_rails_root, fetch(:tire_local_file, 'config/tire.yml'))
  end

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