Skip to content

Instantly share code, notes, and snippets.

@wafiq
Created March 5, 2017 13:46
Show Gist options
  • Select an option

  • Save wafiq/3d2261c36a54bf88612a2901761d59bb to your computer and use it in GitHub Desktop.

Select an option

Save wafiq/3d2261c36a54bf88612a2901761d59bb to your computer and use it in GitHub Desktop.

Revisions

  1. wafiq created this gist Mar 5, 2017.
    75 changes: 75 additions & 0 deletions rails_template.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    gemfile = <<-FILE
    source 'https://rubygems.org'
    ruby '#{RUBY_VERSION}'
    gem 'rails'
    gem 'pg'
    gem 'unicorn'
    gem 'jquery-rails'
    gem 'sass-rails'
    gem 'slim-rails'
    gem 'autoprefixer-rails'
    gem 'uglifier'
    gem 'bootstrap-sass'
    gem 'font-awesome-sass'
    group :development do
    gem 'annotate'
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'pry-rails'
    gem 'listen'
    end
    FILE

    create_file 'Gemfile', gemfile

    run "bundle install"

    scss = <<-SCSS
    @import "bootstrap-sprockets";
    @import "bootstrap";
    @import "font-awesome-sprockets";
    @import "font-awesome";
    SCSS

    remove_file "app/assets/stylesheets/application.css"
    create_file "app/assets/stylesheets/application.scss", scss

    remove_file "README.md"
    create_file "README.md"

    run "echo '# #{@app_name.titleize}' >> README.md"

    layout_file = <<-FILE
    doctype html
    html
    head
    title #{@app_name.titleize}
    meta name="viewport" content="width=device-width, initial-scale=1.0"
    = stylesheet_link_tag 'application', media: 'all'
    = csrf_meta_tags
    body
    = yield
    = javascript_include_tag 'application'
    FILE

    remove_file 'app/views/layouts/application.html.erb'
    create_file 'app/views/layouts/application.html.slim', ERB.new(layout_file).result(binding)

    generate :controller, :pages, :index, "--skip-routes"
    route "root to: 'pages#index'"

    rails_command "db:create"
    rails_command "db:migrate"

    git :init
    git :add => "."
    git :commit => "-a -m 'Initial commit'"

    # optional
    run "powder link #{@app_name}"
    run "atom ./"