Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Forked from DamirSvrtan/app_template.rb
Last active August 29, 2015 14:11
Show Gist options
  • Save jschoolcraft/e7683c60a2d64b0ebe8c to your computer and use it in GitHub Desktop.
Save jschoolcraft/e7683c60a2d64b0ebe8c to your computer and use it in GitHub Desktop.

Revisions

  1. @DamirSvrtan DamirSvrtan revised this gist Nov 28, 2014. 1 changed file with 5 additions and 9 deletions.
    14 changes: 5 additions & 9 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    bundle exec rake db:setup
    FILE

    File.open('bin/setup', 'w'){|file| file.write(bin_setup_file)}
    create_file 'bin/setup', bin_setup_file

    remove_file "README.rdoc"
    create_file "README.md", "Development: run ./bin/setup"
    @@ -45,9 +45,7 @@
    database: <%= @app_name %>_production
    FILE

    File.open('config/database.yml', 'w') do |file|
    file.write(ERB.new(database_file).result(binding))
    end
    create_file 'config/database.yml', ERB.new(database_file).result(binding), force: true

    # Remove unwanted gems. spring will be added later in the development group of gems
    %w(spring coffee-rails sqlite3).each do |unwanted_gem|
    @@ -69,10 +67,8 @@
    = yield
    FILE

    File.delete('app/views/layouts/application.html.erb')
    File.open('app/views/layouts/application.html.slim', 'w') do |file|
    file.write(ERB.new(layout_file).result(binding))
    end
    remove_file 'app/views/layouts/application.html.erb'
    create_file 'app/views/layouts/application.html.slim', ERB.new(layout_file).result(binding)

    # remove commented lines
    gsub_file("Gemfile", /#.*\n/, '')
    @@ -109,4 +105,4 @@
    %w(.sass-cache powder public/system dump.rdb logfile .DS_Store).each do |gitignored|
    append_file ".gitignore", gitignored
    end
    git add: ".", commit: "-m 'Initial commit'"
    git add: ".", commit: "-m 'Initial commit'"
  2. @DamirSvrtan DamirSvrtan revised this gist Sep 30, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -59,7 +59,7 @@
    doctype html
    html
    head
    title Site title
    title <%= @app_name.titleize %>
    = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
    = javascript_include_tag 'application', 'data-turbolinks-track' => true
    @@ -72,7 +72,7 @@
    File.delete('app/views/layouts/application.html.erb')
    File.open('app/views/layouts/application.html.slim', 'w') do |file|
    file.write(ERB.new(layout_file).result(binding))
    end
    end

    # remove commented lines
    gsub_file("Gemfile", /#.*\n/, '')
  3. @SomeKay SomeKay revised this gist Sep 29, 2014. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -54,6 +54,26 @@
    gsub_file("Gemfile", /gem '#{unwanted_gem}'.*\n/, '')
    end

    # Replace erb layout file with slim layout file
    layout_file = <<-FILE
    doctype html
    html
    head
    title Site title
    = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
    = javascript_include_tag 'application', 'data-turbolinks-track' => true
    = csrf_meta_tags
    body
    = yield
    FILE

    File.delete('app/views/layouts/application.html.erb')
    File.open('app/views/layouts/application.html.slim', 'w') do |file|
    file.write(ERB.new(layout_file).result(binding))
    end

    # remove commented lines
    gsub_file("Gemfile", /#.*\n/, '')
    # remove double newlines
  4. @DamirSvrtan DamirSvrtan revised this gist Aug 20, 2014. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,6 @@
    #!/bin/sh
    bundle install
    bundle exec rake db:setup
    if [ -d ~/.pow ]
    then
    echo 7000 > ~/.pow/`basename $PWD`
    else
    echo "Pow not set up but the team uses it for this project."
    fi
    FILE

    File.open('bin/setup', 'w'){|file| file.write(bin_setup_file)}
  5. @DamirSvrtan DamirSvrtan revised this gist Aug 20, 2014. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion app_template.rb
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,22 @@
    ### Rails app generator template. Run it:
    ### rails new _app_name_ -m https://gist.github.com/DamirSvrtan/28a28e50d639b9445bbc/raw/app_template.rb

    bin_setup_file = <<-FILE
    #!/bin/sh
    bundle install
    bundle exec rake db:setup
    if [ -d ~/.pow ]
    then
    echo 7000 > ~/.pow/`basename $PWD`
    else
    echo "Pow not set up but the team uses it for this project."
    fi
    FILE

    File.open('bin/setup', 'w'){|file| file.write(bin_setup_file)}

    remove_file "README.rdoc"
    create_file "README.md", "TODO"
    create_file "README.md", "Development: run ./bin/setup"
    run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss'

    database_type = ask("Do you want to use postgres or mysql?", limited_to: ["pg", "mysql"])
  6. @DamirSvrtan DamirSvrtan revised this gist Aug 20, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion app_template.rb
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,13 @@
    # remove double newlines
    gsub_file("Gemfile", /^\n\n/, '')

    simple_form_installation = "simple_form:install"

    if yes?('Use bootstrap?')
    gem 'bootstrap-sass'
    simple_form_installation << " --bootstrap"
    end

    gem 'simple_form'
    gem 'slim-rails'
    gem 'draper'
    @@ -68,7 +75,7 @@

    run "bundle install"

    generate "simple_form:install"
    generate simple_form_installation

    git :init
    %w(.sass-cache powder public/system dump.rdb logfile .DS_Store).each do |gitignored|
  7. @DamirSvrtan DamirSvrtan revised this gist Aug 18, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion app_template.rb
    Original file line number Diff line number Diff line change
    @@ -71,5 +71,7 @@
    generate "simple_form:install"

    git :init
    append_file ".gitignore", "dump.rdb"
    %w(.sass-cache powder public/system dump.rdb logfile .DS_Store).each do |gitignored|
    append_file ".gitignore", gitignored
    end
    git add: ".", commit: "-m 'Initial commit'"
  8. @DamirSvrtan DamirSvrtan revised this gist Aug 18, 2014. 1 changed file with 44 additions and 4 deletions.
    48 changes: 44 additions & 4 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,59 @@
    ### Rails app generator template
    ### run with rails new __app_name__ -m https://gist.github.com/DamirSvrtan/28a28e50d639b9445bbc/raw/app_template.rb
    ### Rails app generator template. Run it:
    ### rails new _app_name_ -m https://gist.github.com/DamirSvrtan/28a28e50d639b9445bbc/raw/app_template.rb

    remove_file "README.rdoc"
    create_file "README.md", "TODO"
    run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss'

    gsub_file("Gemfile", /#.*\n/, '')
    database_type = ask("Do you want to use postgres or mysql?", limited_to: ["pg", "mysql"])

    adapter = if database_type == 'pg'
    gem 'pg'
    'postgresql'
    else
    gem 'mysql2'
    'mysql2'
    end

    database_file = <<-FILE
    default: &default
    adapter: <%= adapter %>
    pool: 5
    timeout: 5000
    host: localhost
    username: root
    development:
    <<: *default
    database: <%= @app_name %>_development
    password:
    test:
    <<: *default
    database: <%= @app_name %>_test
    # spring will be added later in the development group of gems
    production:
    <<: *default
    database: <%= @app_name %>_production
    FILE

    File.open('config/database.yml', 'w') do |file|
    file.write(ERB.new(database_file).result(binding))
    end

    # Remove unwanted gems. spring will be added later in the development group of gems
    %w(spring coffee-rails sqlite3).each do |unwanted_gem|
    gsub_file("Gemfile", /gem '#{unwanted_gem}'.*\n/, '')
    end

    # remove commented lines
    gsub_file("Gemfile", /#.*\n/, '')
    # remove double newlines
    gsub_file("Gemfile", /^\n\n/, '')

    gem 'simple_form'
    gem 'slim-rails'
    gem 'draper'

    gem_group :development do
    gem 'spring'
  9. @DamirSvrtan DamirSvrtan revised this gist Aug 15, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion app_template.rb
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,11 @@
    run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss'

    gsub_file("Gemfile", /#.*\n/, '')
    gsub_file("Gemfile", /gem 'spring'.*\n/, '')

    # spring will be added later in the development group of gems
    %w(spring coffee-rails sqlite3).each do |unwanted_gem|
    gsub_file("Gemfile", /gem '#{unwanted_gem}'.*\n/, '')
    end

    gem 'simple_form'
    gem 'slim-rails'
  10. @DamirSvrtan DamirSvrtan revised this gist Aug 12, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    ### Rails app generator template
    ### run with rails new __app_name__ -m https://gist.github.com/DamirSvrtan/28a28e50d639b9445bbc/raw/app_template.rb

    remove_file "README.rdoc"
    create_file "README.md", "TODO"
    run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss'
  11. @DamirSvrtan DamirSvrtan created this gist Aug 12, 2014.
    28 changes: 28 additions & 0 deletions app_template.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    remove_file "README.rdoc"
    create_file "README.md", "TODO"
    run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss'

    gsub_file("Gemfile", /#.*\n/, '')
    gsub_file("Gemfile", /gem 'spring'.*\n/, '')

    gem 'simple_form'
    gem 'slim-rails'

    gem_group :development do
    gem 'spring'
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'quiet_assets'
    gem 'pry-rails'
    gem 'bullet'
    gem 'traceroute'
    gem 'letter_opener'
    end

    run "bundle install"

    generate "simple_form:install"

    git :init
    append_file ".gitignore", "dump.rdb"
    git add: ".", commit: "-m 'Initial commit'"