Created
October 18, 2010 23:27
-
-
Save lguardiola/633287 to your computer and use it in GitHub Desktop.
app template for rails 3, include capistrano, rspec, haml, sass, jquery and config timezone
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
# Usage: | |
# rails new YOUR_APP_NAME -m http://gist.github.com/633287.txt | |
# | |
# gems sources | |
add_source :gemcutter | |
add_source 'http://gems.github.com' | |
# gems | |
gem 'capistrano' | |
gem 'haml' | |
gem 'haml-rails' | |
gem 'jquery-rails' | |
gem 'simple_form' | |
gem 'unicorn', :group => :development | |
gem 'rspec', :group => :test | |
gem 'rspec-rails', :group => :test | |
gem 'factory_girl', :group => :test | |
# change defaults defaults testing generators | |
generate_views_specs = yes?('Do you want to generate view specs? (y/n):', :green) | |
environment do | |
<<EOF | |
# Here is where we reap the benefits of the modularity in Rails 3. | |
# What this says is that we want to use RSpec as the test framework and we want to generate fixtures | |
# with our generated specs, but we don't want to generate view specs and | |
# that instead of fixtures, we actually want to use factory girl and | |
# we want the factories to be put into spec/factories. Whew! So does this all work? | |
config.generators do |generator| | |
generator.test_framework :rspec, :fixture => true, :views => #{generate_views_specs} | |
generator.fixture_replacement :factory_girl, :dir => "spec/factories" | |
end | |
EOF | |
end | |
# set timezone | |
if yes?('Do you want define timezone?') | |
unless (timezone = ask('timezone:', :green)).nil? | |
gsub_file('config/application.rb', /#\s*(config\.time_zone\s*=)\s*.*$/, '\1 \'' + timezone + '\'') | |
end | |
end | |
# RSpec | |
generate('rspec:install') | |
# SimpleForm | |
generate('simple_form:install') | |
gsub_file('config/initializers/simple_form.rb', /#\s*(config.default_input_size\ =)\ 50/, '\1 30') | |
# JQuery | |
jquery_enable_ui = '--ui' unless no?('Add JQuery UI? (default:n):', :green) | |
#generate('jquery:install', '--force', "--version=1", jquery_enable_ui) | |
append_file('public/javascripts/application.js') do | |
<<-EOF | |
jQuery.ajaxSetup({ | |
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | |
}) | |
$(document).ready(function() { | |
// All non-GET requests will add the authenticity token | |
// if not already present in the data packet | |
$(document).ajaxSend(function(event, request, settings) { | |
if (typeof(window._auth_token) == "undefined") return; | |
// <acronym title="Internet Explorer 6">IE6</acronym> fix for http://dev.jquery.com/ticket/3155 | |
if (settings.type == 'GET' || settings.type == 'get') return; | |
settings.data = settings.data || ""; | |
settings.data += (settings.data ? "&" : "") + window._auth_token_name + "=" + encodeURIComponent(window._auth_token); | |
}); | |
}); | |
EOF | |
end | |
# Delete all unecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
# copy default database config for versioned | |
run('cp config/database.yml config/database.yml.example') | |
# Setup git ignore file | |
append_file('.gitignore')do | |
<<-EOF | |
.DS_Store | |
.dotest | |
nbproject | |
config/database.yml | |
public/stylesheets/*.css | |
public/system/* | |
*.swo | |
*.swp | |
*.nogit | |
*~ | |
EOF | |
end | |
# capify the project | |
capify! | |
# versioned the project | |
git :init | |
git :add => '.' | |
git :commit => "-a -m 'Initial commit'" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment