imajes / rails-template

based on the awesome rg by mrn

This URL has Read+Write access

rails-template / rails_template.rb
100644 122 lines (98 sloc) 4.088 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# My version of an app template, modified by James Cox (imajes)
# SUPER DARING APP TEMPLATE 1.0 - By Peter Cooper
 
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/src/git/rails rails' }
inside('vendor/rails') { run 'git pull' }
 
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm public/images/rails.png"
run "rm -f public/javascripts/*"
 
# Download JQuery
run "curl -s -L http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js > public/javascripts/jquery.js"
run "curl -s -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
 
# Set up git repository
git :init
git :add => '.'
 
# Copy database.yml for distribution use
run "cp config/database.yml config/database.yml.example"
 
# Set up .gitignore files
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
file '.gitignore', <<-END
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
vendor/rails
END
 
# Set up session store initializer
initializer 'session_store.rb', <<-END
ActionController::Base.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' }
ActionController::Base.session_store = :active_record_store
END
 
# Install plugins
## Those that relate to testing
# RSpec is the original Behaviour Driven Development framework for Ruby.
plugin 'rspec', :git => "git://github.com/dchelimsky/rspec.git"
 
# RSpec's official Ruby on Rails plugin
plugin 'rspec-rails', :git => "git://github.com/dchelimsky/rspec-rails.git"
 
# Fixture replacement for focused and readable tests.
plugin 'object_daddy', :git => "git://github.com/flogic/object_daddy.git"
 
# BDD that talks to domain experts first and code 2nd
plugin 'cucumber', :git => "git://github.com/aslakhellesoy/cucumber.git"
 
generate("rspec")
generate("cucumber")
gem 'faker'
 
## setup for the win
inside ('spec') {
  run "mkdir exemplars"
  run "rm -rf fixtures"
  run "rm spec_helper.rb spec.opts rcov.opts"
  run "curl -sL http://github.com/imajes/rails-template/raw/master/spec_helper.rb > spec_helper.rb"
  run "curl -sL http://github.com/imajes/rails-template/raw/master/rcov.opts > rcov.opts"
  run "curl -sL http://github.com/imajes/rails-template/raw/master/spec.opts > spec.opts"
  
}
 
## Potentially Useful
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git'
plugin 'hoptoad_notifier', :git => 'git://github.com/thoughtbot/hoptoad_notifier.git'
 
## user related
if yes?("Will this app have authenticated users?")
  plugin 'role_requirement', :git => 'git://github.com/timcharper/role_requirement.git'
  plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
  plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git'
  gem 'ruby-openid', :lib => 'openid'
  generate("authenticated", "user session")
  generate("roles", "Role User")
end
 
if yes?("OpenID Support?")
  plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git'
  rake('open_id_authentication:db:create')
end
 
# tags
if yes?("Do you want tags with that?")
  plugin 'acts_as_taggable_redux', :git => 'git://github.com/geemus/acts_as_taggable_redux.git'
  rake('acts_as_taggable:db:create')
end
 
# require some gems
if yes?("Want to require a bunch of useful gems?")
  gem 'hpricot', :source => 'http://code.whytheluckystiff.net'
  gem 'RedCloth', :lib => 'redcloth'
end
 
# Final install steps
rake('gems:install', :sudo => true)
rake('db:sessions:create')
rake('db:migrate')
 
first = ask("What'll be your first action?")
generate(:model, first)
 
# Commit all work so far to the repository
git :add => '.'
git :commit => "-a -m 'First POST!'"
 
# Success!
puts "SUCCESS! - remember to setup hoptoad with the following:"
puts "HoptoadNotifier.configure do |config|
config.api_key = '1234567890abcdef'
end"