colin (owner)

Fork Of

gist: 39969 by bumi the new railslove rails tem...

Revisions

gist: 162559 Download_button fork
public
Public Clone URL: git://gist.github.com/162559.git
Embed All Files: show embed
railslove.rb #
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# RAILSLOVE.com template
#
# with help and ideas from:
# http://gist.github.com/33337 By Peter Cooper
# http://github.com/jeremymcanally/rails-templates/tree/master/suspenders.rb Suspenders by Thoughtbot Nathan Esquenazi
 
 
if yes?("symlink local rails copy to vendor?")
  path = ask("what's the directory of your local rails copy?")
  inside('vendor') { run "ln -s #{path} rails" }
end
 
submodules = yes?("Do you want to add plugins as submodules?")
 
# init the git repository
# files added
git :init
 
 
# ---------------------------------
# gems
# ---------------------------------
 
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'
gem 'ruby-openid', :lib => 'openid'
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
gem 'mocha'
 
 
# ---------------------------------
# plugins
# ---------------------------------
 
plugin 'find_by_param', :git => 'git://github.com/bumi/find_by_param.git', :submodule => submodules
plugin 'redirect_love', :git => 'git://github.com/bumi/redirect_love.git', :submodule => submodules
plugin 'serialize_fu', :git => 'git://github.com/bumi/serializefu.git', :submodule => submodules
plugin 'limerick_rake', :git => "git://github.com/thoughtbot/limerick_rake.git", :submodule => submodules
plugin 'hoptoad_notifier', :git => "git://github.com/thoughtbot/hoptoad_notifier.git", :submodule => submodules
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => submodules
plugin 'annotate_models', :git => 'git://github.com/ctran/annotate_models.git', :submodule => submodules
plugin 'rack-bug', :git => 'git://github.com/brynary/rack-bug.git', :submodule => submodules
 
 
# ---------------------------------
# we don't need that
# ---------------------------------
run "rm README && touch README"
run "rm public/index.html"
 
 
# ---------------------------------
# we love edge rails
# ---------------------------------
freeze! if yes?("Do you want to live on the (rails) edge?")
 
 
 
# ---------------------------------
# initializers
# ---------------------------------
 
# mail
initializer 'mail.rb', <<-END
ActionMailer::Base.smtp_settings = {
:address => "smtp.mailer.com",
:port => 25,
:domain => "mailer.com",
:password => ""
}
ActionMailer::Base.default_url_options[:host] = ""
END
 
# exceptions love hoptoad or getexceptional? don't know yet
initializer 'hoptoad.rb',<<-END
 
HoptoadNotifier.configure do |config|
config.api_key = ''
end
END
 
# require extensions
initializer 'requires.rb', <<-END
Dir[File.join(RAILS_ROOT, 'lib', 'extensions', '**/*.rb')].each do |file|
require file
end
Dir[File.join(RAILS_ROOT, 'lib', 'fixes', '**/*.rb')].each do |file|
require file
end
END
 
# ---------------------------------
# Config
# ---------------------------------
 
# not sure if that's really needed.
# add session config to environment.rb
in_root do
  gsub_file 'config/environment.rb', /(#{Regexp.escape('Rails::Initializer.run do |config|')})/mi do |match|
<<-END
#{match}\n
config.action_controller.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' }
config.action_controller.session_store = :active_record_store
END
  end
end
 
 
# we love factories
inside ('test') do
  run "mkdir factories"
end
 
# folders for extensions and fixes
inside ('lib') do
  run "mkdir extensions"
  run "mkdir fixes"
end
 
 
# ---------------------------------
# common files
# ---------------------------------
 
# get application_controller started
file 'app/controllers/application_controller.rb',
<<-END
class ApplicationController < ActionController::Base
include HoptoadNotifier::Catcher
helper :all
protect_from_forgery
filter_parameter_logging :password
end
END
 
# add partial for flash messages
file 'app/views/layouts/_flash_messages.html.erb',
<<-END
<% %w{error notice ok}.each do |type| %>
<% unless flash[type.to_sym].blank? %>
<div class="flash <%= type %>">
<% if flash[type.to_sym].is_a?(ActiveRecord::Errors) %>
<%= error_messages_for(flash[type.to_sym]) %>
<% else %>
<%= flash[type.to_sym] %>
<% end %>
</div>
<% end %>
<% end %>
END
 
# ---------------------------------
# Deploy scripts
# ---------------------------------
capify!
 
 
run "cp config/database.yml config/database.yml.example"
 
 
file '.gitignore', <<-END
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
*.pid
END
 
 
# ---------------------------------
# find empty filders and add a .gitignore # thanks Peter Cooper
# ---------------------------------
run "touch tmp/.gitignore log/.gitignore"
run 'find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;'
 
 
# ---------------------------------
# run installer and generator
# ---------------------------------
rake('gems:install', :sudo => true)
rake('gems:unpack')
 
generate("authenticated", "user session")
rake('db:sessions:create')
 
# ---------------------------------
# generate your resources
# ---------------------------------
if yes?("Want to generate some resources?")
  resources = ask("Which resources? (comma-seperated list)")
  resources.split(",").each do |resource|
    generate(:resource, resource)
  end
end
 
 
git :add => '.'
 
if submodules
  git :submodule => "init"
end
 
git :commit => "-a -m 'initial commit'"
 
 
puts "DONE"
puts "Happy coding!"