Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 89 lines (71 sloc) 1.955 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
# Prevent automatic bundle install by Rails app generator
def run_bundle; end

def path(relative)
  File.expand_path("../#{relative}", __FILE__)
end

def clean(path)
  gsub_file path, /#.*\n/, "\n"
  gsub_file path, /\n^\s*\n/, "\n"
end

# Commit all changes with given message.
#
# The commit operation will attempt to sign the commit using your GPG key. This
# needs to be configured as `user.signingkey=<KEY_ID>` in your git config.
def commit_all(message)
  yield if block_given?

  git add: '.'
  git commit: %(-aqm "#{message}")
end

git :init

commit_all 'Initial commit' do
  %w(
README
README.rdoc
app/assets/images/rails.png
app/views/layouts/application.html.erb
doc/README_FOR_APP
public/index.html
test
).each { |path| remove_file path }
end

commit_all 'Configure RSpec generators' do
  application <<-RUBY

config.generators do |g|
g.test_framework :rspec, routing_specs: false, views: false
end
RUBY
end

if ua = ENV['GA_TRACKER']
  commit_all 'Configure Rack Google Analytics' do
    environment "config.middleware.use Rack::GoogleAnalytics, tracker: '#{ua}'",
      env: :production
  end
end

commit_all 'Setup default rake task' do
  append_to_file 'Rakefile', <<-RUBY.gsub(/^\s+/, '')
task(:default).clear
task :default => [:spec, :cucumber]
RUBY
end

commit_all 'Install & configure gems' do
  directory path('templates'), destination_root

  apply path('recipes/gems.rb')
  apply path('recipes/pg_config.rb')

  run 'bundle install --quiet'
end

rake 'db:create:all'

commit_all 'Setup authentication' do
  apply path('recipes/authentication.rb')
end

if system 'gem which zeus &>/dev/null'
  commit_all('Bootstrap zeus') { run 'zeus init' }
end

commit_all 'Clean-up generated files' do
  %w(
Gemfile
config/application.rb
config/environments/development.rb
config/environments/test.rb
config/environments/production.rb
).each { |path| clean path }
end
Something went wrong with that request. Please try again.