Skip to content

Instantly share code, notes, and snippets.

@napcs
Forked from lenary/template.rb
Created April 15, 2011 01:34
Show Gist options
  • Save napcs/920968 to your computer and use it in GitHub Desktop.
Save napcs/920968 to your computer and use it in GitHub Desktop.
# Copyright 2011 Sam Elliott
# Released under MIT Licence
app_name = File.basename(Dir.pwd)
git :init
# Remove rails.png and index.html
remove_file("public/index.html")
remove_file("public/images/rails.png")
create_file("public/images/.gitkeep")
# Remove Bullsh*t README Contents
remove_file("README")
create_file("README", <<-README)
#{app_name.capitalize}
#{"="*app_name.length}
TODOS:
------
* <whatever>
*
README
gsub_file("config/routes.rb", %r{^\s+#(.*)$\n}, "")
gsub_file("config/routes.rb", %r{end$}, "\nend")
# Debugger
gem("ruby-debug19", :group => [:development, :test])
# Haml
haml = yes?("Haml?")
if haml
gem("haml-rails")
end
# MongoDB
mongo = yes?("Mongo?")
if mongo
gem("mongoid")
gem("bson_ext")
generate("mongoid:config")
gsub_file("config/application.rb", %r{require 'rails/all'}) do
<<REQUIRES
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
REQUIRES
end
end
# RSpec
rspec = yes?("RSpec?")
if rspec
remove_dir("test")
append_to_file(".gitignore", "test/\n")
gem("rspec-rails", :group => [:development, :test])
gem("fuubar", :group => [:development, :test])
generate("rspec:install")
append_to_file(".rspec", <<RSPEC)
--format Fuubar
RSPEC
# Mongoid Support
if mongo
gem("mongoid-rspec", :group => [:development, :test])
empty_directory("spec/support")
create_file("spec/support/mongoid_support.rb", <<-MONGOID)
RSpec.configure do |configuration|
configuration.include Mongoid::Matchers
end
MONGOID
end
end
# Factory Girl
fg = yes?("Factory Girl?")
if fg
gem("factory_girl_rails", :group => [:development, :test])
if rspec
create_file("spec/factories.rb")
end
end
application <<-APP
config.generators do |g|
#{"g.orm :mongoid" if mongo}
#{"g.template_engine :haml" if haml}
#{"g.test_framework :rspec,
:view_specs => false,
:helper_specs => false,
:routing_specs => false,
:integration_tool => false" if rspec}
g.helper false
g.fixture false
end
APP
git :add => "."
git :commit => "-m 'First Commit!'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment