Sha256: edd0f7e3ccb5c27c2b39496282b74a0f59c8405ae7d98d885bd6f17c104f6a8e

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

require 'rails/generators/rails/app/app_generator'

module MakeItSo
  class RailsAppGenerator < ::Rails::Generators::AppGenerator
    source_root(MakeItSo.source_root(:rails))

    class_option :rspec,
      type: :boolean,
      default: true,
      desc: 'install rspec'

    class_option :devise,
      type: :boolean,
      default: true,
      desc: 'install devise: complete with acceptance tests'

    #override database to default to postgres
    class_option :database,
      type: :string,
      aliases: '-d',
      default: 'postgresql',
      desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"

    class_option :foundation,
      type: :boolean,
      default: true,
      desc: 'generate foundation support'

    # turbolinks is the devil
    class_option :skip_turbolinks,
      type: :boolean,
      default: true,
      desc: 'Skip turbolinks gem'

    def initialize(*args)
      super
      if @options[:rspec]
        # don't generate Test::Unit - we have to dup to unfreeze
        @options = @options.dup
        @options[:skip_test] = true
      end
    end

    def finish_template
      super

      build 'pry_rails_dependency'
      build 'base_stylesheets'
      build 'eliminate_byebug'
      unless options[:skip_javascript]
        build 'base_javascripts'
      end

      build 'application_controller'
      if options[:rspec]
        build 'rspec_dependency'
        #build 'fix_generators'
        build 'factory_bot_rspec'
        build 'valid_attribute_rspec'
        build 'shoulda_rspec'
        build 'teaspoon_jasmine'
      end

      if options[:devise]
        build 'devise_dependency'
      end

      if options[:foundation]
        build 'foundation_dependency'
      end
    end

    protected

    def get_builder_class
      MakeItSo::Rails::AppBuilder
    end

  end
end

[
  MakeItSo.source_root(:rails),
  Rails::Generators::AppGenerator.source_root
].each do |path|
  MakeItSo::RailsAppGenerator.source_paths << path
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
make_it_so-0.0.9 lib/generators/rails_app_generator.rb