Sha256: 99f4e23bed136dd46173945a8698f2354ada41282d55ca1f4c4bbf7bdb986f27

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

module Bretelline
  class AppGenerator < Rails::Generators::AppGenerator
    class_option :database, type: :string, aliases: "-d", default: "postgresql",
                            desc: "Configure for selected database (options: #{DATABASES.join('/')})"

    class_option :skip_spring, type: :boolean, default: true,
                               desc: "Don't install Spring application preloader"

    class_option :skip_test, type: :boolean, default: true,
                             desc: "Skip Test Unit"

    class_option :skip_system_test, type: :boolean, default: true,
                                    desc: "Skip system test files"

    class_option :skip_turbolinks, type: :boolean, default: true,
                                   desc: "Skip turbolinks gem"

    class_option :skip_action_cable, type: :boolean, aliases: "-C", default: true,
                                     desc: "Skip Action Cable files"

    def source_paths
      [
        Rails::Generators::AppGenerator.source_root,
        File.expand_path("templates", File.dirname(__FILE__))
      ]
    end

    def finish_template
      invoke :bretelline
      super
    end

    def run_bundle
      # Do nothing, it will be run by the bretelline command
    end

    def bretelline
      bundle_command 'install'
      invoke :create_database
      build :setup
      invoke :migrate_database
    end

    def create_database
      bundle_command "exec rails db:create"
    end

    def migrate_database
      bundle_command "exec rails db:migrate"
    end

    protected

    def get_builder_class
      Bretelline::Builders::Solidus
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bretelline-0.2.0 lib/bretelline/app_generator.rb