Sha256: beda1b17473275cc646a03b9c3e167bc8cdaecbeb72a08b9c0bf97b4204e404f

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'rails/generators'
require 'pathname'

module Shoestrap
  class DeploymentGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates/deployment', __FILE__)

    def add_unicorn_config
      copy_file 'unicorn.rb', 'config/unicorn.rb'
    end

    def add_database_config
      template 'database.yml.erb', 'config/database.yml', :force => true
    end

    def add_deployment_task
      template 'deployment.rake.erb', 'lib/tasks/deployment.rake'
    end

    protected

    def app_name
      Pathname.new(Rails.root).basename.to_s
    end

    def db_credentials_production
      '<%= begin IO.read("#{ENV[\'HOME\']}/.config/' + app_name + '_production/db") rescue "" end %>'
    end

    def db_credentials_staging
      '<%= begin IO.read("#{ENV[\'HOME\']}/.config/' + app_name + '_staging/db") rescue "" end %>'
    end

    def restart_unicorn_command
      '#{ENV[\'HOME\']}/unicorn.sh upgrade ' + app_name + '_#{ENV[\'RAILS_ENV\']}'
    end

    def restart_monit_command
      'monit -g ' + app_name + '_#{ENV[\'RAILS_ENV\']} monitor'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoestrap-0.2.0 lib/generators/shoestrap/deployment_generator.rb