mattpolito (owner)

Fork Of

gist: 89169 by andrew Rails template

Revisions

gist: 178837 Download_button fork
public
Public Clone URL: git://gist.github.com/178837.git
Embed All Files: show embed
rails_template.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
# Delete unnecessary files
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/images/rails.png"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
 
# Copy database.yml for distribution use
run "cp config/database.yml config/database.yml.example"
 
# Plugins
plugin 'make_resourceful', :git => "git://github.com/hcatlin/make_resourceful.git"
plugin 'permalink_fu', :git => "git://github.com/technoweenie/permalink_fu.git"
plugin 'hoptoad_notifier', :git => "git://github.com/thoughtbot/hoptoad_notifier.git"
plugin 'country_select', :git => "git://github.com/rails/country_select.git"
 
# Gems
gem 'will_paginate'
gem 'haml'
gem 'authlogic'
gem 'newrelic_rpm'
gem 'thoughtbot-paperclip', :lib => 'paperclip', :source => 'http://gems.github.com'
gem "jchupp-is_paranoid", :lib => 'is_paranoid', :source => 'http://gems.github.com'
gem 'javan-whenever', :lib => false, :source => 'http://gems.github.com'
 
# Commands
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.js > public/javascripts/jquery.js"
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}
run 'wheneverize .'
 
# add a layout
run "touch app/views/layouts/application.html.haml"
 
# make some stylesheets
inside('public/stylesheets/sass') do
  run "curl -L http://gist.github.com/130941.txt > reset.sass"
  run "touch application.sass print.sass iphone.sass"
end
 
# Gems for test env
inside('config/environments') do
  File.open("test.rb", "a+") {|f| f.write(<<-TASK
 
 
config.gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com"
config.gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => "http://gems.github.com"
TASK
  )}
end
 
# initializers
initializer 'hoptoad.rb', <<-CODE
HoptoadNotifier.configure do |config|
config.api_key = '1234567890abcdef'
end
CODE
 
initializer 'paperclip.rb', <<-CODE
# hack for passenger so it resizes images properly
# change path to where you installed imagemagick
if Rails.env.development?
Paperclip.options[:image_magick_path] = '/opt/local/bin/'
end
class Paperclip::Attachment
def self.default_options
@default_options ||= {
:url => "/system/:attachment/:id/:style/:filename",
:path => ":rails_root/public:url",
:styles => {},
:default_url => "/images/default_:attachment_:style.png",
:default_style => :original,
:validations => [],
:storage => :filesystem,
:whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails]
}
end
end
CODE
 
# rcov rake task
rakefile("coverage.rake") do
  <<-TASK
namespace :test do
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
rm_f "coverage.data"
rcov = 'rcov test/test_helper.rb --rails --aggregate coverage.data --text-summary -Ilib -x \\gem'
system("\#{rcov} --no-html test/unit/*_test.rb")
system("\#{rcov} --no-html test/functional/*_test.rb")
system("\#{rcov} --html test/integration/*_test.rb")
system("open coverage/index.html") if PLATFORM['darwin']
end
end
TASK
end
 
# add metric fu rake tasks
File.open("Rakefile", "a+") {|f| f.write(<<-TASK
 
 
begin
require 'metric_fu'
rescue LoadError
end
TASK
)}
 
# capify
run 'capify .'
 
# add whenever capistrano task
inside('config') do
  File.open("deploy.rb", "a+") {|f| f.write(<<-TASK
 
 
namespace :deploy do
desc "Update the crontab file"
task :update_crontab, :roles => :db do
run "cd \#{release_path} && whenever --update-crontab \#{application} --set environment=\#{rails_env}"
end
end
 
after "deploy:symlink", "deploy:update_crontab"
TASK
  )}
end
 
if yes?('Do you want thinking sphinx?')
  # add thinking sphinx gem
  gem 'freelancing-god-thinking-sphinx', :lib => 'thinking_sphinx', :source => "http://gems.github.com"
 
  # add sphinx deploy tasks
  inside('config') do
    File.open("deploy.rb", "a+") {|f| f.write(<<-TASK
 
 
namespace :sphinx do
desc "Generate the sphinx index"
task :index, :roles => :app do
run "cd \#{current_path} && rake thinking_sphinx:index RAILS_ENV=\#{rails_env}"
end
 
desc "Configure sphinx"
task :configure, :roles => :app do
run "cd \#{current_path} && rake thinking_sphinx:configure RAILS_ENV=\#{rails_env}"
end
 
desc "Stop the sphinx server"
task :stop, :roles => :app do
run "cd \#{current_path} && rake thinking_sphinx:stop RAILS_ENV=\#{rails_env}"
end
 
desc "Start the sphinx server"
task :start, :roles => :app do
run "cd \#{current_path} && rake thinking_sphinx:start RAILS_ENV=\#{rails_env}"
end
 
desc "Restart the sphinx server"
task :rebuild, :roles => :app do
run "cd \#{current_path} && rake thinking_sphinx:rebuild RAILS_ENV=\#{rails_env}"
end
end
 
after "deploy", "sphinx:rebuild"
TASK
    )}
  end
 
File.open("Rakefile", "a+") {|f| f.write(<<-TASK
 
 
begin
require 'thinking_sphinx/tasks'
rescue LoadError
end
TASK
)}
end
 
# Set up git repository and Commit all work so far to the repository
file '.gitignore', <<-END
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
db/schema.rb
log/*.pid
public/system/**/*
public/stylesheets/*.css
tmp/restart.txt
coverage/
coverage.data
END
 
git :init
git :add => '.'
git :commit => "-a -m 'Initial commit'"
 
# Success!
puts "SUCCESS!"