Sha256: 9b605909e5b68a388c11620d8e401781f5ad12a85119c0e472f62dd748dd8787

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 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

    def add_airbrake_config
      copy_file 'airbrake.rb', 'config/initializers/airbrake.rb'
    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

2 entries across 2 versions & 1 rubygems

Version Path
shoestrap-0.2.2 lib/generators/shoestrap/deployment_generator.rb
shoestrap-0.2.1 lib/generators/shoestrap/deployment_generator.rb