Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Created May 16, 2011 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloaj/973821 to your computer and use it in GitHub Desktop.
Save juanpabloaj/973821 to your computer and use it in GitHub Desktop.
# mongo_template.rb
#
# mongo_template
#
# Usage:
# rails new appname -m /path/to/mongo_template.rb
#
# Also see http://textmate.rubyforge.org/thor/Thor/Actions.html
#
# Check prerequisites
%w{colored bundler compass html5-boilerplate haml capistrano}.each do |component|
unless Gem.available?(component)
run "gem install #{component}"
Gem.refresh
Gem.activate(component)
end
end
require "rails"
require "colored"
require "bundler"
require "haml"
require "net/http"
require "net/https"
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
# add basic layout to start
file 'app/views/layouts/application.html.erb', <<-ERB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Application!</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
<%= stylesheet_link_tag 'global' %>
</head>
<body>
<%= yield %>
</body>
</html>
ERB
# MongoDB FTW!
db_name = ask('What should I call the database? ')
initializer 'database.rb', <<-CODE
MongoMapper.database = "#{db_name}-\#{Rails.env}"
CODE
file 'config/database.yml', <<-CODE
# Using MongoDB
CODE
environment 'config.frameworks -= [:active_record]'
gem 'mongomapper'
# Testing and Cucumber
gem 'redgreen'
gem 'mocha'
gem 'thoughtbot-shoulda', :lib => 'shoulda/rails', :source => 'http://gems.github.com'
gem "cucumber"
gem "webrat"
# Gem management
rake 'gems:unpack'
rake 'rails:freeze:gems'
# Finish Cucumber
run './script/generate cucumber'
# source control
file '.gitignore', <<-FILES
.DS_Store
**/.DS_Store
log/*
tmp/*
tmp/**/*
config/database.yml
coverage/*
coverage/**/*
FILES
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