Created
June 9, 2010 20:57
-
-
Save bru/432156 to your computer and use it in GitHub Desktop.
Basic Rails 2.3.5 Template with Bundler gem
This file contains hidden or 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
@app_name = File.basename(@root) | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm public/images/rails.png" | |
run "rm -f public/javascripts/*" | |
run "rm config/database.yml" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Create stub database.yml and database.yml.example | |
file 'config/database.yml', | |
%Q{ | |
development: | |
adapter: mysql | |
database: #{@app_name}_development | |
username: root | |
password: | |
host: localhost | |
encoding: utf8 | |
test: | |
adapter: mysql | |
database: #{@app_name}_test | |
username: root | |
password: | |
host: localhost | |
encoding: utf8 | |
} | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
vendor/rails | |
vendor/bundle | |
END | |
file 'Gemfile', %{ | |
source :rubygems | |
gem 'rails', '#{Rails::VERSION::STRING}' | |
gem 'mysql' | |
group :development do | |
gem 'ruby-debug' | |
end | |
group :test do | |
gem 'rspec' | |
gem 'rspec-rails' | |
end | |
}.strip | |
append_file '/.gitignore', %{ | |
/.bundle | |
} | |
append_file '/config/preinitializer.rb', %{ | |
begin | |
require "rubygems" | |
require "bundler" | |
rescue LoadError | |
raise "Could not load the bundler gem. Install it with `gem install bundler`." | |
end | |
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") | |
raise RuntimeError, "Your bundler version is too old." + | |
"Run `gem install bundler` to upgrade." | |
end | |
begin | |
# Set up load paths for all bundled gems | |
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__) | |
Bundler.setup | |
rescue Bundler::GemNotFound | |
raise RuntimeError, "Bundler couldn't find some gems." + | |
"Did you run `bundle install`?" | |
end | |
}.strip | |
gsub_file 'config/boot.rb', "Rails.boot!", %{ | |
class Rails::Boot | |
def run | |
load_initializer | |
Rails::Initializer.class_eval do | |
def load_gems | |
@bundler_loaded ||= Bundler.require :default, Rails.env | |
end | |
end | |
Rails::Initializer.run(:set_load_path) | |
end | |
end | |
Rails.boot! | |
} | |
# Prepare for BDD | |
generate("rspec") | |
generate("cucumber") | |
# Commit all work so far to the repository | |
git :add => '.' | |
git :commit => "-a -m 'First commit'" | |
run 'bundle install vendor/bundle --disable-shared-gems' | |
puts "Now you're all set up." | |
puts "Please go on, write some features, and make them pass." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment