Skip to content

Instantly share code, notes, and snippets.

@verticonaut
Created August 17, 2010 21:34
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 verticonaut/532166 to your computer and use it in GitHub Desktop.
Save verticonaut/532166 to your computer and use it in GitHub Desktop.
Rails3 application template
# *******************************************************************************************
# Collected and assembled from various sources - thanks to all OS providers
#
# call> rails new my_app -J -T -m 'this template'
# *******************************************************************************************
rvmrc = <<-RVMRC
rvm_gemset_create_on_use_flag=1
rvm gemset use 1.9.2-pre@#{app_name}
RVMRC
create_file ".rvmrc", rvmrc
# empty_directory "lib/generators"
# git :clone => "--depth 0 http://github.com/leshill/rails3-app.git lib/generators"
# remove_dir "lib/generators/.git"
puts "removing unneeded files..."
run 'rm public/index.html'
run 'rm public/favicon.ico'
run 'rm public/images/rails.png'
run 'rm README'
run 'touch README'
gem "haml", ">= 3.0.12"
gem 'sqlite3-ruby', :group => [:test, :cucumber], :require => 'sqlite3'
gem "capybara", ">= 0.3.8", :group => [:test, :cucumber]
gem "cucumber-rails", ">= 0.3.2", :group => [:test, :cucumber]
gem "database_cleaner", ">= 0.5.2", :group => [:test, :cucumber]
gem "factory_girl_rails", ">= 1.0.0", :group => [:test, :cucumber]
gem "launchy", ">= 0.3.5", :group => [:test, :cucumber]
gem "rspec-rails", ">= 2.0.0.beta.12", :group => [:test, :cucumber]
gem "spork", ">= 0.8.4", :group => [:test, :cucumber]
gem "capybara", ">= 0.3.8", :group => [:test, :cucumber]
gem 'rails3-generators', :group => [:test, :cucumber]
gem 'populator'
gem 'faker'
gem 'rcov'
gem 'activerecord-oracle_enhanced-adapter', :group => [:oracle]
gem 'ruby-oci8', :group => [:oracle]
generators = <<-GENERATORS
config.generators do |g|
g.template_engine :haml
g.test_framework :rspec, :fixture => true, :views => false
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
GENERATORS
application generators
get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.js"
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "public/javascripts/jquery-ui.js"
get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
if Rails::VERSION::STRING =~ /beta/
jquery = <<-JQUERY
module ActionView::Helpers::AssetTagHelper
remove_const :JAVASCRIPT_DEFAULT_SOURCES
JAVASCRIPT_DEFAULT_SOURCES = %w(jquery.js jquery-ui.js rails.js)
reset_javascript_include_default
end
JQUERY
initializer "jquery.rb", jquery
else
gsub_file 'config/application.rb', 'config.action_view.javascript_expansions[:defaults] = %w()', 'config.action_view.javascript_expansions[:defaults] = %w(jquery.js jquery-ui.js rails.js)'
end
puts "Set up basic layout file ..."
layout = <<-LAYOUT
!!!
%html
%head
%title #{app_name.humanize}
= stylesheet_link_tag :all
= javascript_include_tag :defaults
= csrf_meta_tag
%body
= yield
LAYOUT
remove_file "app/views/layouts/application.html.erb"
create_file "app/views/layouts/application.html.haml", layout
create_file "log/.gitkeep"
create_file "tmp/.gitkeep"
puts "setting up source control with 'git'..."
# specific to Mac OS X
append_file '.gitignore' do
'.DS_Store'
'/.idea/*'
'# move all this to file in repo and fetch from there ...'
end
if yes?('Would you like to init git and add/commit? (yes/no)')
git :init
git :add => '.'
git :commit => "-m 'Initial commit of unmodified new Rails app'"
end
docs = <<-DOCS
Run the following commands to complete the setup of #{app_name.humanize}:
% edit my_app/.rvmrc to change ruby if not 1.9.2-head should be used
%
% cd #{app_name}
% gem install bundler --pre
% bundle install
% script/rails generate rspec:install
% script/rails generate cucumber:install --rspec --capybara
DOCS
log docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment