run "rm Gemfile" file 'Gemfile', <<-FILE source 'http://rubygems.org' gem 'rails', '3.0.3' gem 'rake', '~> 0.8.7' gem 'devise', '~> 1.2.0' gem 'cancan' gem 'will_paginate', '~> 3.0.pre2' gem 'tzinfo' gem 'hoptoad_notifier' group :staging, :production do gem 'mysql' end group :development, :test do gem 'test-unit', '= 2.0.9', :require => 'test/unit' gem 'sqlite3-ruby', :require => 'sqlite3' # This is for gems without generators - like factory girl gem 'rails3-generators' # These help with tests gem 'shoulda' # This is a cool library for easily writing boring tests gem 'shoulda-matchers' # These are handy matchers from the above library gem 'factory_girl_rails' # This lets us define objects using factories gem 'faker' # This lets us easily define fake data in our factories # This makes our tests colorful gem 'turn' gem 'ansi' # Coffeescript gem 'therubyracer' # Growl notifications for testing gem 'growl' # Trying this out for now gem 'guard', '>= 0.3.0' gem 'guard-livereload' gem 'guard-coffeescript' gem 'guard-test' gem 'rb-fsevent' end FILE current_ruby = %x{rvm list}.match(/^=>\s+(.*)\s\[/)[1].strip run "rvm gemset create #{app_name}" run "rvm #{current_ruby}@#{app_name} gem install bundler --no-rdoc --no-ri" run "rvm #{current_ruby}@#{app_name} -S bundle install" file ".rvmrc", <<-END rvm use #{current_ruby}@#{app_name} END # Clean up rails defaults remove_file 'public/index.html' remove_file 'rm public/images/rails.png' inside "public" do run "git clone http://github.com/paulirish/html5-boilerplate.git" run 'cp -R html5-boilerplate/* .' run 'mv js/* javascripts/' run 'mv javascripts/libs/* javascripts/' run 'mv css/* stylesheets/' run 'rm -Rf js css html5-boilerplate' run 'mv index.html example-html5b.html' run 'rm README.md' inside "javascripts" do FileUtils.rm_rf %w(controls.js dragdrop.js effects.js prototype.js rails.js) run "wget https://github.com/rails/jquery-ujs/raw/master/src/rails.js --no-check-certificate" run "mv jquery-*.min.js jquery.js" run "mv modernizr-* modernizr.js" end inside "stylesheets" do run "wget 'http://grids.heroku.com/grid.css?column_width=20&column_amount=24&gutter_width=20' -O 960.gs" end end # Layout run 'rm app/views/layouts/application.html.erb' file 'app/views/layouts/application.html.erb', <<-FILE #{app_name} <%= stylesheet_link_tag :all %> <%= javascript_include_tag 'jquery', 'rails', 'modernizr' %> <%= csrf_meta_tag %>

<%= notice %>

<%= alert %>

<%= yield %>
<%= render :partial => 'shared/yahoo_profiling' %> <%= render :partial => 'shared/google_analytics' %> FILE run "mkdir -p app/views/shared" file 'app/views/shared/_yahoo_profiling.html.erb', <<-FILE <% if Rails.env == 'development' %> <% end %> FILE file 'app/views/shared/_google_analytics.html.erb', <<-FILE <% if Rails.env == 'production' %> <% end %> FILE inject_into_file 'config/environments/production.rb', :after => 'end' do <<-eos GOOGLE_ANALYTICS_TOKEN = "UA-123456" eos end # Add factory_girl into the thing inject_into_file 'config/application.rb', :after => "config.filter_parameters += [:password]" do <<-eos # Customize generators config.generators do |g| g.fixture_replacement :factory_girl end eos end run 'mkdir -p test/shoulda_macros' file 'test/shoulda_macros/anafm.rb', %q{ module AcceptsNestedAttributesForMacros def should_accept_nested_attributes_for(*attr_names) klass = self.name.gsub(/Test$/, '').constantize context "#{klass}" do attr_names.each do |association_name| should "accept nested attrs for #{association_name}" do assert klass.instance_methods.include?(\"#{association_name}_attributes="), "#{klass} does not accept nested attributes for #{association_name}" end end end end end class ActiveSupport::TestCase extend AcceptsNestedAttributesForMacros end } # Update the test helper run "rm test/test_helper.rb" file "test/test_helper.rb", <<-FILE ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require File.join(File.dirname(__FILE__), 'shoulda_macros', 'anafm') module #{app_name.camelize}ControllerHelpers # Put helpers for your controllers in here # Ex: # def login_as_admin # @user = Factory.create(:admin_user) # sign_in @user # end end class ActiveSupport::TestCase end class ActionController::TestCase include Devise::TestHelpers include #{app_name.camelize}ControllerHelpers end FILE file 'Guardfile', %q{ guard 'test' do watch(%r{app/models/(.+)\.rb}) { |m| "test/unit/#{m[1]}_test.rb" } watch(%r{app/controllers/(.+)\.rb}) { |m| "test/functional/#{m[1]}_test.rb" } watch(%r{app/views/.+\.rb}) { "test/integration" } watch(%r{lib/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" } watch(%r{test/.+_test.rb}) watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] } watch('test/test_helper.rb') { "test" } end guard 'coffeescript', :output => 'public/javascripts/compiled' do watch('^app/coffeescripts/(.*)\.coffee') end guard 'coffeescript', :output => 'spec/javascripts' do watch('^spec/coffeescripts/(.*)\.coffee') end guard 'livereload', :apply_js_live => false do watch('^spec/javascripts/.+\.js$') watch('^public/javascripts/compiled/.+\.js$') end guard 'livereload' do watch(%r{app/.+\.(erb|haml|jst)}) watch(%r{app/helpers/.+\.rb}) watch(%r{public/.+\.(css|js|html)}) watch(%r{.*\.(sass|scss$)}) { 'css' } watch(%r{config/locales/.+\.yml}) end } # authentication and authorization setup generate "devise:install" generate "devise user" generate "devise:views" rake "db:migrate" generate "cancan:ability" rake "db:create", :env => 'development' rake "db:create", :env => 'test' rake "db:migrate" # create a git repo git :init git :add => '.' git :commit => '-a -m "new rails app"'