Sha256: b7ae15a94009c4ea07b07b7c9c6a748c8aed4092ae1eb71509a5c1e7fe2cb30e

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require_relative 'base'

module Bankai
  module Generators
    # :nodoc:
    class DeployGenerator < Base
      DEFAULT_REPO = 'git@example.com:me/my_repo.git'

      def install_capistrano
        Bundler.with_clean_env { run 'bundle exec cap install' }
      end

      def configure_capfile
        inject_into_file(
          'Capfile',
          capistrano_plugins,
          after: "# require \"capistrano/passenger\"\n"
        )
      end

      def replace_deploy_config
        template 'deploy.rb.erb', 'config/deploy.rb', force: true
      end

      protected

      def repo_url
        return DEFAULT_REPO unless Dir.exist?('.git')

        res = `git remote get-url origin`
        return DEFAULT_REPO if res.blank?

        res
      end

      private

      def capistrano_plugins
        plugins = []
        plugins << 'require "capistrano/bundler"'
        plugins << 'require "capistrano/rails/assets"' unless options[:api]
        plugins << 'require "capistrano/rails/migrations"'
        plugins.join("\n")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bankai-0.8.1 lib/bankai/generators/deploy_generator.rb
bankai-0.8.0 lib/bankai/generators/deploy_generator.rb
bankai-0.7.0 lib/bankai/generators/deploy_generator.rb
bankai-0.6.0 lib/bankai/generators/deploy_generator.rb
bankai-0.5.1 lib/bankai/generators/deploy_generator.rb
bankai-0.5.0 lib/bankai/generators/deploy_generator.rb
bankai-0.4.1 lib/bankai/generators/deploy_generator.rb
bankai-0.4.0 lib/bankai/generators/deploy_generator.rb