Created
October 20, 2012 11:15
-
-
Save macbury/3923003 to your computer and use it in GitHub Desktop.
Rails Template 0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create rvmrc file | |
create_file ".rvmrc", "rvm use ruby-1.9.3-head@#{app_name} --create" | |
gem 'mysql2', group: :orm | |
gem "carrierwave", group: :orm | |
gem "devise", group: :authorization | |
gem "cancan", group: :authorization | |
gem "yettings", group: :other | |
gem "rmagick", group: :other | |
gem "simple_form", group: :views | |
gem 'haml', group: :views | |
gem 'haml-rails', group: :views | |
gem 'draper', group: :views | |
gem 'kaminari', group: :views | |
gem 'therubyracer', platforms: :ruby, group: :assets | |
gem 'compass-rails', group: :assets | |
gem 'quiet_assets', group: :assets | |
gem 'rspec-rails', group: [:development, :test ] | |
gem "factory_girl_rails", group: [:development, :test ] | |
gem 'sextant', group: [:development, :test ] | |
gem 'annotator', group: [:development, :test ] | |
gem "timecop", group: :test | |
gem "nyan-cat-formatter", group: :test | |
gem 'database_cleaner', group: :test | |
gem 'shoulda-matchers', group: :test | |
gem "nyan-cat-formatter", group: :test | |
gem "spork", group: :test | |
run 'bundle install' | |
rake "db:create", :env => 'development' | |
rake "db:create", :env => 'test' | |
generate 'simple_form:install' | |
generate 'rspec:install' | |
inject_into_file 'spec/spec_helper.rb', :after => "require 'rspec/rails'" do | |
<<-eos | |
require 'factory_girl' | |
require 'rspec/autorun' | |
require "cancan/matchers" | |
require 'carrierwave/test/matchers' | |
eos | |
end | |
inject_into_file 'config/application.rb', :after => "class Application < Rails::Application" do | |
<<-eos | |
config.autoload_paths += %W(\#{Rails.root}/lib \#{Rails.root}/lib/validators \#{Rails.root}/app/workers) | |
config.assets.paths << "\#{Rails.root}/app/assets/fonts" | |
config.assets.paths << "\#{Rails.root}/app/assets/flash" | |
eos | |
end | |
inject_into_file 'config/application.rb', :after => "config.filter_parameters += [:password]" do | |
<<-eos | |
# Customize generators | |
config.generators do |g| | |
g.view_specs false | |
g.helper_specs false | |
g.stylesheets false | |
g.form_builder :simple_form | |
g.fixture_replacement :factory_girl, :dir => 'spec/factories' | |
end | |
eos | |
end | |
gsub_file 'config/environments/production.rb', /config.i18n.fallbacks = true/ do | |
<<-eos | |
config.i18n.fallbacks = true | |
config.action_mailer.default_url_options = { :host => 'yourhost.com' } | |
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.perform_deliveries = true | |
config.action_mailer.raise_delivery_errors = false | |
config.action_mailer.default :charset => "utf-8" | |
eos | |
end | |
gsub_file 'config/application.rb', /\Aif\sdefined\?\(Bundler\)\s.+\send/i do | |
if defined?(Bundler) | |
Bundler.require(*Rails.groups(:assets => %w(development test))+[:other, :orm, :views, :authorization, :worker, :docs]) | |
end | |
end | |
create_file 'config/initializers/mailer.rb' do | |
<<-eos | |
unless Rails.env == "test" | |
config.action_mailer.delivery_method = MailerYetting.deliver_method.to_sym | |
config.action_mailer.smtp_settings = MailerYetting.smtp_settings.symbolize_keys | |
config.action_mailer.default_url_options = MailerYetting.default_url_options.symbolize_keys | |
end | |
eos | |
end | |
create_file 'config/yettings/mailer.yml' do | |
<<-eos | |
development: | |
devise_mail: "noreply@local.local" | |
notification: "noreply@local.local" | |
default_url_options: | |
host: noreply@local.local | |
deliver_method: "smtp" | |
smtp_settings: | |
address: "local.local" | |
port: 25 | |
domain: 'local.local' | |
user_name: 'elvis' | |
authentication: 'plain' | |
enable_starttls_auto: false | |
test: | |
devise_mail: "noreply@local.local" | |
notification: "noreply@local.local" | |
default_url_options: | |
host: noreply@local.local | |
deliver_method: "none" | |
smtp_settings: | |
address: "local.local" | |
port: 25 | |
domain: 'local.local' | |
user_name: 'elvis' | |
authentication: 'plain' | |
enable_starttls_auto: false | |
eos | |
end | |
run "echo '--format documentation' >> .rspec" | |
# authentication and authorization setup | |
generate "devise:install" | |
generate "devise User" | |
generate "devise:views" | |
generate "rails g decorator user" | |
rake "db:migrate" | |
generate "cancan:ability" | |
# clean up rails defaults | |
remove_file 'public/index.html' | |
remove_file 'rm public/images/rails.png' | |
run 'cp config/database.yml config/database.example' | |
run "echo 'config/database.yml' >> .gitignore" | |
run "gem install haml hpricot ruby_parser slim haml2slim" | |
run "for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; done" | |
# commit to git | |
git :init | |
git :add => "." | |
git :commit => "-a -m 'create initial application'" | |
say <<-eos | |
============================================================================ | |
Your new Rails application is ready to go. | |
Don't forget to scroll up for important messages from installed generators. | |
eos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment