Skip to content

Instantly share code, notes, and snippets.

@lfborjas
Created November 8, 2010 20:51
Show Gist options
  • Save lfborjas/668237 to your computer and use it in GitHub Desktop.
Save lfborjas/668237 to your computer and use it in GitHub Desktop.
My rails 3 templates, given that now jquery-ujs has a generator
# >---------------------------[ Install Command ]-----------------------------<
# rails new APP_NAME -m http://railswizard.org/257558554d274cfab160.rb -J
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
# application template builder. Get started at http://railswizard.org
#
# ___________________________________________________________________________
# |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
# | | |
# | Name: | progra 4, social crawler |
# | URL: | http://railswizard.org/257558554d274cfab160.rb |
# | Updated: | November 08, 2010 at 21:08PM |
# | | |
# |\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
# ---------------------------------------------------------------------------
# >----------------------------[ Initial Setup ]------------------------------<
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
end
RUBY
template = {"authentication"=>"omniauth", "templating"=>"on", "unit_testing"=>"test_unit", "css"=>"on", "javascript"=>"jquery", "integration_testing"=>"cucumber", "orm"=>"activerecord-1"}
recipes = template.values.flatten
def say_recipe(name); say "\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say "\033[36m" + "wizard".rjust(10) + "\033[0m" + " #{text}" end
@after_blocks = []
def after_bundler(&block); @after_blocks << block; end
# >-----------------------------[ ActiveRecord ]------------------------------<
# Use the default ActiveRecord database store.
say_recipe 'ActiveRecord'
# No additional code required.
# >------------------------------[ Test::Unit ]-------------------------------<
# Utilize the default Rails test facilities.
say_recipe 'Test::Unit'
# No additional code required.
# >-------------------------------[ Cucumber ]--------------------------------<
# Use Cucumber for integration testing with Capybara.
say_recipe 'Cucumber'
gem 'cucumber-rails', :group => :test
gem 'capybara', :group => :test
after_bundler do
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
end
# >--------------------------------[ jQuery ]---------------------------------<
# Adds the latest jQuery and Rails UJS helpers for jQuery.
say_recipe 'jQuery'
gem 'jquery-rails'
generate 'jquery:install --ui'
# >-------------------------------[ OmniAuth ]--------------------------------<
# Adds basic OmniAuth support through the gem and an initializer. Requires additional setup.
say_recipe 'OmniAuth'
gem 'omniauth'
initializer 'omniauth.rb', <<-RUBY
Rails.application.config.middleware.use OmniAuth::Builder do
# Set up your authentication providers here.
# Once you've done that you will need to set up a
# route that handles /auth/:provider/callback
# and takes a look at request.env['omniauth.auth']
# for authentication information.
#
# provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
# provider :facebook, 'APP_ID', 'APP_SECRET'
# provider :open_id, OpenID::Storage::Filesystem.new('/tmp')
end
RUBY
#based on http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth
route "match '/auth/:provider/callback' => 'sessions#create'"
generate "controller sessions create"
generate "model authorization provider:string uid:string user_id:integer token:string secret:string"
generate "model user name:string"
say_wizard "Now finish this up with this info 'http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth'"
gem 'formtastic', '~> 1.1.0'
gem 'heroku', '1.10.6', :group => :development
gem 'autotest', '4.3.2'
gem 'autotest-rails-pure', '4.1.0', :group=> [ :development, :test]
gem 'redgreen', :group=> [ :development, :test]
gem 'test_notifier', :group=> [ :development, :test]
gem 'annotate-models', '~> 1.0.4', :group=> [ :development, :test]
git :init
git :add => '.'
git :commit => "-m 'Initial commit"
generate "formtastic:install"
git :add => '.'
git :commit => "-m 'Installed formtastic'"
# >-----------------------------[ Run Bundler ]-------------------------------<
say_wizard "Running Bundler install. This will take a while."
run 'bundle install'
say_wizard "Running after Bundler callbacks."
@after_blocks.each{|b| b.call}
# >---------------------------[ Install Command ]-----------------------------<
# rails new APP_NAME -m http://railswizard.org/962ad8fa752f8e20bcb4.rb -J -O
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
# application template builder. Get started at http://railswizard.org
#
# ___________________________________________________________________________
# |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
# | | |
# | Name: | progra4, inline comments |
# | URL: | http://railswizard.org/962ad8fa752f8e20bcb4.rb |
# | Updated: | November 08, 2010 at 20:49PM |
# | | |
# |\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
# ---------------------------------------------------------------------------
# >----------------------------[ Initial Setup ]------------------------------<
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
end
RUBY
template = {"authentication"=>"devise", "templating"=>"haml", "unit_testing"=>"test_unit", "css"=>"on", "javascript"=>"jquery", "integration_testing"=>"cucumber", "orm"=>"mongoid"}
recipes = template.values.flatten
def say_recipe(name); say "\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say "\033[36m" + "wizard".rjust(10) + "\033[0m" + " #{text}" end
@after_blocks = []
def after_bundler(&block); @after_blocks << block; end
# >--------------------------------[ Mongoid ]--------------------------------<
# Utilize MongoDB with Mongoid as the ORM.
say_recipe 'Mongoid'
gem 'mongoid', '>= 2.0.0.beta.19'
after_bundler do
generate 'mongoid:config'
end
# >------------------------------[ Test::Unit ]-------------------------------<
# Utilize the default Rails test facilities.
say_recipe 'Test::Unit'
# No additional code required.
# >-------------------------------[ Cucumber ]--------------------------------<
# Use Cucumber for integration testing with Capybara.
say_recipe 'Cucumber'
gem 'cucumber-rails', :group => :test
gem 'capybara', :group => :test
after_bundler do
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}"
end
# >--------------------------------[ jQuery ]---------------------------------<
# Adds the latest jQuery and Rails UJS helpers for jQuery.
say_recipe 'jQuery'
gem 'jquery-rails'
generate 'jquery:install --ui'
#application do
# "\n config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails)\n"
#end
#gsub_file "config/application.rb", /# JavaScript.*\n/, ""
#gsub_file "config/application.rb", /# config\.action_view\.javascript.*\n/, ""
# >--------------------------------[ Devise ]---------------------------------<
# Utilize Devise for authentication, automatically configured for your selected ORM.
say_recipe 'Devise'
gem 'devise'
after_bundler do
generate 'devise:install'
case template['orm']
when 'mongo_mapper'
gem 'mm-devise'
gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongo_mapper_active_model'
when 'mongoid'
gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
when 'active_record'
# Nothing to do
end
generate 'devise user'
end
# >---------------------------------[ HAML ]----------------------------------<
# Utilize HAML for templating.
say_recipe 'HAML'
gem 'haml', '>= 3.0.0'
gem 'haml-rails'
# >-----------------------------[ Custom Code ]-------------------------------<
gem 'formtastic', '~> 1.1.0'
gem 'heroku', '1.10.6', :group => :development
gem 'autotest', '4.3.2'
gem 'autotest-rails-pure', '4.1.0', :group=> [ :development, :test]
gem 'redgreen', :group=> [ :development, :test]
gem 'test_notifier', :group=> [ :development, :test]
gem 'annotate-models', '~> 1.0.4', :group=> [ :development, :test]
git :init
git :add => '.'
git :commit => "-m 'Initial commit"
generate "formtastic:install"
git :add => '.'
git :commit => "-m 'Installed formtastic'"
# >-----------------------------[ Run Bundler ]-------------------------------<
say_wizard "Running Bundler install. This will take a while."
run 'bundle install'
say_wizard "Running after Bundler callbacks."
@after_blocks.each{|b| b.call}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment