Skip to content

Instantly share code, notes, and snippets.

@f440
Created December 15, 2010 04:22
Show Gist options
  • Save f440/741621 to your computer and use it in GitHub Desktop.
Save f440/741621 to your computer and use it in GitHub Desktop.
rials template
#
# This work is in the public domain.
#
if yes? "Do you use haml? [yes/no]"
gem 'haml-rails'
end
if yes? "Do you use compass? [yes/no]"
gem 'compass'
if yes? "Do you use html5-boilerplate? (notice:haml only) [yes/no]"
gem 'html5-boilerplate'
run 'yes | compass init --app rails -r html5-boilerplate --using html5-boilerplate'
elsif yes? "Do you use blueprint? [yes/no]"
run 'yes | compass init --app rails --using blueprint/semantic'
else
run 'yes | compass init --app rails'
end
append_file ".gitignore" do
"public/stylesheets/compiled\n"
end
run 'touch public/stylesheets/compiled/.gitkeep'
gsub_file 'app/views/layouts/application.html.erb', / <%= stylesheet_link_tag :all %>/ do
<<-STYLESHEET.chomp
<%= stylesheet_link_tag :all %>
<%= stylesheet_link_tag 'compiled/screen', :media => 'screen,projection' %>
<%= stylesheet_link_tag 'compiled/print', :media => 'print' %>
<!--[if IE]><%= stylesheet_link_tag 'compiled/ie', :media => 'screen,projection'%><![endif]-->
STYLESHEET
end
end
# if yes? %(Do you use rails3_generators)
# log 'rails3 generators'
# gem 'rails3-generators'
# end
if yes? "Do you use jquery? [yes/no]"
gem 'jquery-rails'
generate "jquery:install", '--ui --force'
application ' config.action_view.javascript_expansions[:defaults] = %w(jquery jquery-ui rails)'
end
if yes? "Do you use rspec? [yes/no]"
gem 'rspec', :group => :test
gem 'rspec-rails', :group => :test
generate "rspec:install"
end
if yes? "Do you use shoulda? [yes/no]"
gem 'shoulda', :group => :test
end
# if yes? %(Do you use simple_form? [yes/no])
# gem 'simple_form'
# plugin 'country_select', 'git://github.com/rails/country_select.git'
# generate 'simple_form:install'
# end
# if yes? %(Do you use formtastic? [yes/no])
# gem 'formtastic'
# generate 'formtastic:install'
# elsif yes? %(Do you use factory_girl? [yes/no])
# gem 'factory_girl_rails'
# end
# if yes? %(Do you use inherited_resources? [yes/no])
# gem 'inherited_resources'
# gem 'responders'
# gem 'has_scope'
# end
if yes? %(Do you use i18n_generators? [yes/no])
gem 'i18n_generators'
generate "i18n", "ja --force"
end
if yes? %(Do you use paperclip? [yes/no])
gem 'paperclip'
elsif yes? %(Do you use carrierwave? [yes/no])
gem 'carrierwave'
end
if yes? %(Do you use mongoid? [yes/no])
gem 'mongoid', '2.0.0.beta.20'
gem 'bson_ext'
generate 'mongoid:config'
end
if yes? %(Do you use mongohq? [yes/no])
run "ruby -i -pe 'next if $_.match /MONGOID/; END{puts \" uri: <%= ENV['MONGOHQ_URL'] %>\"} ' config/mongoid.yml"
end
if yes? %(Do you use devise? [yes/no])
gem 'devise'
generate 'devise:install'
gsub_file 'app/views/layouts/application.html.erb', /<body>/ do
<<-TEMPLATE.chomp
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
TEMPLATE
end
run "ruby -r 'open-uri' -e 'puts OpenURI.open_uri(\"https://gist.github.com/raw/606476/15605bdbc28067c7983cefae3ae12105ee93c243/devise.ja.yml\"){|sio| sio.read }' > config/locales/devise.ja.yml"
if yes? %(Do you create users model? [yes/no])
generate 'scaffold User email:string --timestamps --versioning'
# fix bug
gsub_file 'app/models/user.rb', /include Mongoid::Versioning/ do
<<-USERMODEL
include Mongoid::Versioning
USERMODEL
end
generate 'devise user'
generate 'devise:views users'
generate 'mongoid:devise user'
append_file 'db/seeds.rb' do
<<-SEED
puts 'EMPTY THE MONGODB DATABASE'
Mongoid.master.collections.reject{|c| c.name =~ /^system\./ }.each(&:drop)
puts 'SETTING UP DEFAULT USER LOGIN'
user = User.create! :email => '[email protected]', :password => 'password'
puts 'New user created: ' << user.email
SEED
end
gsub_file 'config/routes.rb', ' # root :to => "welcome#index"' do
' root :to => "users#index"'
end
gsub_file 'app/views/users/index.html.erb', '<h1>Listing users</h1>' do
<<-LOGIN.chomp
<h1>Listing users</h1>
<% if user_signed_in? %>
<%= link_to 'Logout', destroy_user_session_path %>
<% else %>
<%= link_to 'Login', new_user_session_path %>
<% end %>
LOGIN
end
end
end
if yes? "Do you use capistano? [yes/no]"
run "capify ."
end
log "remove default files"
run `rm README`
run `rm public/index.html`
run `rm public/favicon.ico`
run `touch public/favicon.ico`
run `rm public/images/rails.png`
log "initial commit"
append_file '.gitignore' do
<<-GITIGNORE
*.swp
*~
.DS_Store
.bundle
db/*.sqlite3
doc/api
doc/app
log/*.log
tmp/*
GITIGNORE
end
git :init
git :add => "."
git :commit => '-m "initial commit"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment