Sha256: 0da2d81e1df16882d3a9cb197fb4f662b37271d7d624057cfcec111695ff637e

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

class BootupGenerator < Rails::Generators::Base
  source_root File.expand_path('../templates', __FILE__)
  argument :app_name, type: :string, default: Rails.application.class.parent

  def generate_bootup
    log :generate, "Booting #{app_name}"

    @db = ask("Would you like to use Postgres?")
    log :generate, "Copying Gemfile"
    template "Gemfile.erb", "Gemfile"

    log :generate, "Running Bundler"
    inside Rails.root do
      run "bundle install"
    end

    log :generate, "Removing public/index.."
      inside Rails.root do
        run "rm public/index.html"
      end

    if @db == 'y' or @db == 'yes'
      log :generate, "Initializing database.yml"
      template 'database.yml.erb', 'config/database.yml'

      log :generate, "Creating database"
      rake("db:create")
    end


    log :generate, "Installing Twitter Bootstrap"
    generate "bootstrap:install"

    log :generate, "Copy application.js & initialize datatables to #datatables - Remember to change sorting"
    copy_file "application.js", "app/assets/javascripts/application.js"

    log :generate, "Copying stylesheets"
    copy_file "application.css", "app/assets/stylesheets/application.css"

    log :generate, "Installing Simple Form"
    generate "simple_form:install --bootstrap"

    tests = ask("Would you like to get rid of the default testing framework & install Rspec with Guard?")
    if tests == 'y' or tests == 'yes'
      log :generate, "Removing Tests.."
      inside Rails.root do
        run "rm -rf test/"
      end

      log :generate, "Setting up Rspec.."
      generate "rspec:install"

      log :generate, "Setting up Guard with a custom guardfile.."
      copy_file "Guardfile", "Guardfile"

      log :generate, "Setting up spork"
      copy_file "spec_helper.rb", "spec/spec_helper.rb"
    else
      log :generate, "Skipping removal of tests"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootup-0.0.1 lib/generators/bootup/bootup_generator.rb