Skip to content

Instantly share code, notes, and snippets.

@leandrocp
Created May 25, 2011 23:10
Show Gist options
  • Save leandrocp/992213 to your computer and use it in GitHub Desktop.
Save leandrocp/992213 to your computer and use it in GitHub Desktop.
Rails 3 basic template
# rails3_basic_template.rb
# rails new project --skip-test-unit -m https://gist.github.com/992213.txt
#OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
# Questions
#-----------------------------------------------------------------------------------------------
css_framework_option = ask("\r\n\r\nWhat CSS framework do you want to use?\r\n\r\n(1) Bootstrap (default)\r\n(2) Foundation\r\n")
css_framework = "bootstrap-sass" if css_framework_option=="1"
css_framework = "zurb-foundation" if css_framework_option=="2"
css_framework ||= "bootstrap-sass"
# Clean up
#-----------------------------------------------------------------------------------------------
say("Limpando arquivos...", :yellow)
run "rm -Rf .gitignore README public/index.html test app/views/layouts/* public/images/rails.png"
# Gems
#-----------------------------------------------------------------------------------------------
say("Adicionando gems...", :yellow)
gem 'brazilian-rails'
gem 'responders'
gem 'inherited_resources'
gem 'devise'
gem 'cancan'
gem 'slim-rails'
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'
gem "nested_form", :git => 'git://github.com/ryanb/nested_form.git'
gem 'ransack'
gem 'friendly_id'
gem "default_value_for"
gem 'capistrano'
gem css_framework, :group => :assets
gem 'sqlite3', :group => [:test, :development]
gem 'rspec-rails', :group => [:test, :development]
gem 'shoulda-matchers', :group => [:test, :development]
gem 'shoulda-context', :group => [:test, :development]
gem 'fabrication', :group => [:test, :development]
gem 'database_cleaner', :group => [:test, :development]
gem 'faker', :group => [:test, :development]
gem 'capybara', :group => [:test, :development]
gem 'launchy', :group => [:test, :development]
gem 'thin', :group => :development
gem 'rails3-generators', :group => :development
gem 'rails_best_practices', :group => :development
gem 'annotate', :group => :development
gem 'pg', :group => :production
gem 'execjs', :group => :production
gem 'therubyracer', :group => :production
# Bundle
#-----------------------------------------------------------------------------------------------
say("Instalando gems...", :yellow)
run "bundle install --path .bundle/gem --binstubs .bundle/bin --without production"
# Setup Gems
#-----------------------------------------------------------------------------------------------
say("Configurando Gems...", :yellow)
generate "responders:install"
generate "rspec:install"
generate "devise:install"
if css_framework == "zurb-foundation"
generate "foundation:install"
generate "foundation:layout --slim"
end
generate "simple_form:install"
generate "nested_form:install"
# Generators
#-----------------------------------------------------------------------------------------------
generators = <<-GENERATORS
config.generators do |g|
g.test_framework :rspec,
:fixtures => true,
:view_specs => false,
:helper_specs => false,
:routing_specs => false,
:controller_specs => true,
:request_specs => true
g.fixture_replacement :fabrication
end
GENERATORS
application generators
# Locale pt-BR
# http://github.com/lackac/app_lego/blob/master/locale.rb
#-----------------------------------------------------------------------------------------------
say("Localizacao pt-BR...", :yellow)
get "https://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/pt-BR.yml", "config/locales/pt-BR.yml"
gsub_file "config/application.rb",
/(#\s*)?config.i18n.default_locale.*$/,
"config.i18n.default_locale = 'pt-BR'"
# Time Zone Brasilia
#-----------------------------------------------------------------------------------------------
say("Time Zone BR...", :yellow)
gsub_file "config/application.rb",
/(#\s*)?config.time_zone.*$/,
"config.time_zone = 'Brasilia'"
# Database
#-----------------------------------------------------------------------------------------------
say("Banco de dados...", :yellow)
rake "db:create", :env => "test"
rake "db:create", :env => "development"
rake "db:migrate"
# Git
#-----------------------------------------------------------------------------------------------
say("git...", :yellow)
git :init
file ".gitignore", <<-END
log
tmp
config/database.yml
db/*.sqlite3
.DS_Store
vendor/bundle
.bundle/config
END
git :add => "."
git :commit => "-am 'primeiro commit'"
# Notas
#-----------------------------------------------------------------------------------------------
if css_framework == "zurb-foundation"
say("Ver: https://github.com/plataformatec/simple_form/wiki/Zurb%27s-Foundation-integration", :yellow)
elsif css_framework == "bootstrap-sass"
say("Ver: https://github.com/thomas-mcdonald/bootstrap-sass", :yellow)
end
say("Ver: https://github.com/ryanb/nested_form", :yellow)
say("Ver: https://github.com/styleguide/ruby", :yellow)
say("Ver: https://github.com/bbatsov/rails-style-guide", :yellow)
say("Feito!", :green)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment