Created
September 1, 2011 18:41
-
-
Save matiasleidemer/1186903 to your computer and use it in GitHub Desktop.
Meganti's rails template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
say "I'm assuming that you have RVM and Ruby 1.8.7 or 1.9.2 installed throught it.\n If not, you should!" | |
current_ruby = ask("Which version of ruby is configured? 1.8.7 or 1.9.2?") | |
#create rvmrc file / this was a little tricky (http://stackoverflow.com/questions/3604077/setting-up-rvm-gemset-via-rails-3-template) | |
run "rvm gemset create #{app_name}" | |
run "rvm #{current_ruby}@#{app_name} gem install bundler" #we need to install bundler, otherwise we won't be able to run the bundler install | |
#clean up the Gemfile (I don't like the comments there) | |
remove_file "Gemfile" | |
file "Gemfile", %{ | |
source 'http://rubygems.org' | |
gem "rails", '#{Rails::VERSION::STRING}' | |
gem "haml" | |
gem "sass" | |
gem "hoptoad_notifier" | |
gem "newrelic_rpm" | |
gem "mysql2" | |
gem "airbrake" | |
gem "capistrano" | |
gem "jquery-rails" | |
gem 'json' | |
gem 'execjs' | |
gem 'therubyracer' | |
group :assets do | |
gem 'sass-rails', " ~> 3.1.0" | |
gem 'coffee-rails', "~> 3.1.0" | |
gem 'uglifier' | |
end | |
group :development do | |
gem "unicorn" | |
end | |
group :test, :development do | |
gem "capybara" | |
gem "cucumber-rails" | |
gem "database_cleaner" | |
gem "rspec-rails" | |
gem "factory_girl_rails" | |
end | |
}.strip | |
#install those gems | |
run "rvm #{current_ruby}@#{app_name} -S bundle install" | |
create_file ".rvmrc", "rvm use #{current_ruby}@#{app_name}" | |
#create the dbs | |
run "RAILS_ENV=development rvm #{current_ruby}@#{app_name} -S bundle exec rake db:migrate" | |
run "RAILS_ENV=test rvm #{current_ruby}@#{app_name} -S bundle exec rake rake db:migrate" | |
#newrelic's config yaml | |
create_file "config/newrelic.yml", "replace with your newrelic content" | |
#generate some stuff for me. danke. | |
run "rvm #{current_ruby}@#{app_name} -S bundle exec rails g rspec:install" | |
#run "rvm #{current_ruby}@#{app_name} -S bundle exec rails g jquery:install" | |
run "rvm #{current_ruby}@#{app_name} -S bundle exec rails g cucumber:install --rspec --capybara" | |
#to make cucumber (and 'firefox' testing work) 'cause sometimes it takes to long to boot the rack server | |
inject_into_file 'features/support/env.rb', "\nCapybara.server_boot_timeout = 300", :after => "Capybara.default_selector = :css" | |
#factory firl to work with rspec | |
inject_into_file 'spec/spec_helper.rb', "\nrequire 'factory_girl'", :after => "require 'rspec/rails'" | |
create_file "spec/factories.rb" do | |
<<-eos | |
#Factory.define :user do |u| | |
# u.first_name "Foo" | |
# u.last_name "Bar" | |
# u.password "secret" | |
# u.email "[email protected]" | |
#end | |
# | |
#Factory.define :english, :class => Language do |u| | |
# u.name 'English' | |
# u.abbrev 'en' | |
# u.association :country | |
#end | |
eos | |
end | |
#default format documentation for rspec | |
run "echo '--format documentation' >> .rspec" | |
#bullet configuration | |
inject_into_file 'config/environments/development.rb', :after => "config.action_dispatch.best_standards_support = :builtin" do | |
<<-eos | |
\n | |
# Bullet configuration | |
config.after_initialize do | |
Bullet.enable = true | |
Bullet.disable_browser_cache = true | |
Bullet.rails_logger = true | |
Bullet.bullet_logger = true | |
end | |
eos | |
end | |
#gmail mailer configuration for development | |
inject_into_file 'config/environments/development.rb', :after => "config.action_mailer.raise_delivery_errors = false" do | |
<<-eos | |
\n | |
# Gmail configuration | |
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => "smtp.gmail.com", | |
:user_name => "<username>", | |
:password => "<password>", | |
:authentication => "plain", | |
:enable_starttls_auto => true } | |
eos | |
end | |
#mailer testing configuration | |
inject_into_file 'config/environments/test.rb', "\n\tconfig.action_mailer.default_url_options = { :host => 'localhost:3000' }", :after => "config.action_mailer.delivery_method = :test" | |
# clean up rails defaults | |
remove_file 'public/index.html' | |
remove_file 'rm public/images/rails.png' | |
run 'cp config/database.yml config/database.example' | |
inject_into_file '.gitignore', "\nconfig/database.yml", :after => "db/*.sqlite3" | |
inject_into_file '.gitignore', "\n.rspec", :after => ".bundle" | |
inject_into_file '.gitignore', "\db/schema.rb", :after => ".bundle" | |
# commit to git | |
git :init | |
git :add => "." | |
git :commit => "-a -m 'create initial application'" | |
#generate "hoptoad --api-key your_key_here" | |
say "Dont forget to generate your config/newrelic.yml file and to run the hoptoad rake with your credentials" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment