Sha256: 705d80b000ea99c2b107ae538dbf959668272b4e52c5674c0975d00278760a22

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 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
        execute_command :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

7 entries across 7 versions & 1 rubygems

Version Path
bankai-0.13.1 lib/bankai/generators/deploy_generator.rb
bankai-0.13.0 lib/bankai/generators/deploy_generator.rb
bankai-0.12.1 lib/bankai/generators/deploy_generator.rb
bankai-0.12.0 lib/bankai/generators/deploy_generator.rb
bankai-0.11.0 lib/bankai/generators/deploy_generator.rb
bankai-0.10.0 lib/bankai/generators/deploy_generator.rb
bankai-0.9.1 lib/bankai/generators/deploy_generator.rb