Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

  • Loading branch information...
commit 4aef59271638ba03f0a5e10d384fa5cdaf09fba3 0 parents
Josep Jaume Rey authored April 27, 2012

Showing 1 changed file with 123 additions and 0 deletions. Show diff stats Hide diff stats

  1. 123  template.rb
123  template.rb
... ...
@@ -0,0 +1,123 @@
  1
+require 'ostruct'
  2
+
  3
+application_name = `pwd`.split('/').last
  4
+run "echo > Gemfile"
  5
+
  6
+choices = OpenStruct.new
  7
+
  8
+choices.i18n = yes?("Will this application use I18n?")
  9
+choices.json = yes?("Will you output json?")
  10
+choices.heroku = yes?("Will you use heroku?")
  11
+
  12
+if choices.devise = yes?("Will you use devise?")
  13
+  choices.devise_user_model = ask("What would you like the user model to be called? [User]")
  14
+  choices.devise_user_model = 'User' if choices.devise_user_model.blank?
  15
+end
  16
+
  17
+if choices.active_admin = yes?("Will you use active_admin?")
  18
+  choices.active_admin_user_model = ask("What would you like the Admin user model to be called? [AdminUser]")
  19
+  choices.active_admin_user_model = 'AdminUser' if choices.active_admin_user_model.blank?
  20
+end
  21
+
  22
+if choices.uploads = yes?("Will this app have file uploads?")
  23
+  choices.s3 = yes?("Will they be over S3?")
  24
+end
  25
+choices.assets = yes?("Do you want to optimize this app's assets for performance?")
  26
+
  27
+add_source :rubygems
  28
+gem 'rails'
  29
+gem "slim-rails"
  30
+gem "simple_form"
  31
+gem 'draper'
  32
+gem 'button_form'
  33
+gem 'flash_messages_helper'
  34
+gem 'rails-i18n' if choices.i18n
  35
+gem 'jbuilder' if choices.json
  36
+gem 'carrierwave' if choices.uploads
  37
+gem 'devise' if choices.devise
  38
+if choices.active_admin
  39
+  gem 'meta_search', version: '>= 1.1.0.pre'
  40
+  gem 'activeadmin'
  41
+end
  42
+
  43
+gem_group :development do
  44
+  gem 'sqlite3'
  45
+  gem 'smusher' if choices.assets
  46
+  gem 'heroku' if choices.heroku
  47
+end
  48
+
  49
+gem_group :development, :test do
  50
+  gem "minitest-rails"
  51
+end
  52
+
  53
+gem_group :test do
  54
+  gem "spinach-rails", group: 'test'
  55
+end
  56
+
  57
+gem_group :assets do
  58
+  gem 'sass-rails'
  59
+  gem 'compass-rails'
  60
+end
  61
+
  62
+gem_group :production do
  63
+  gem 'pg'
  64
+  gem 'fog' if choices.s3
  65
+end
  66
+
  67
+run "bundle install"
  68
+
  69
+# Install devise
  70
+if choices.devise
  71
+  generate "devise:install"
  72
+  generate "devise", choices.devise_user_model
  73
+end
  74
+
  75
+# Install active_admin
  76
+if choices.active_admin
  77
+  generate "active_admin:install", choices.active_admin_user_model
  78
+end
  79
+
  80
+# Use carrierwave with s3
  81
+if choices.s3
  82
+  initializer 'carrierwave.rb', <<-eos
  83
+CarrierWave.configure do |config|
  84
+  config.permissions = 0666
  85
+  if Rails.env.test?
  86
+    config.enable_processing = false
  87
+  end
  88
+  if Rails.env.production?
  89
+    config.storage = :fog
  90
+    config.fog_credentials = {
  91
+      provider: 'AWS',
  92
+      aws_access_key_id: ENV['S3_KEY'],
  93
+      aws_secret_access_key: ENV['S3_SECRET'],
  94
+      region: ENV['S3_REGION']
  95
+    }
  96
+    config.fog_directory = ENV['S3_BUCKET']
  97
+    config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
  98
+    config.fog_public     = true
  99
+  else
  100
+    config.storage = :file
  101
+  end
  102
+end
  103
+  eos
  104
+end
  105
+
  106
+# Optimize asset performance
  107
+if choices.assets
  108
+  application 'config.serve_static_assets = true', env: :production
  109
+  application 'config.static_cache_control = "public, max-age=864000"', env: :production
  110
+  application "config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'", env: :production
  111
+  application "config.middleware.use Rack::Cache, verbose: false", env: :production
  112
+  application "config.middleware.insert_before Rack::Cache, Rack::Deflater", env: :production
  113
+end
  114
+
  115
+# Cleanup
  116
+run "rm app/assets/images/rails.png"
  117
+run "rm public/index.html"
  118
+run "rm public/favicon.ico"
  119
+
  120
+# set up git
  121
+git :init
  122
+git :add => '.'
  123
+git :commit => "-a -m 'Initial commit'"

0 notes on commit 4aef592

Please sign in to comment.
Something went wrong with that request. Please try again.