Class: RoughDraft::RailsBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- RoughDraft::RailsBuilder
show all
- Includes:
- Actions
- Defined in:
- lib/rough_draft/rails_builder.rb
Instance Method Summary
collapse
Methods included from Actions
#copy_source_file, #git_commit
Instance Method Details
#app ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rough_draft/rails_builder.rb', line 20
def app
super
remove_file 'app/controllers/concerns'
remove_file 'app/models/concerns'
empty_directory_with_keep_file 'app/assets/fonts'
empty_directory_with_keep_file 'app/assets/images/backgrounds'
empty_directory_with_keep_file 'app/assets/images/decorations'
empty_directory_with_keep_file 'app/assets/images/emails'
empty_directory_with_keep_file 'app/assets/images/icons'
empty_directory_with_keep_file 'app/assets/images/logos'
empty_directory_with_keep_file 'app/assets/images/placeholders'
empty_directory_with_keep_file 'app/assets/images/text'
empty_directory_with_keep_file 'app/assets/images/ui'
end
|
#bugsnag ⇒ Object
362
363
364
365
366
367
|
# File 'lib/rough_draft/rails_builder.rb', line 362
def bugsnag
copy_source_file 'config/initializers/bugsnag.rb'
template 'config/settings/bugsnag.yml.erb', 'config/settings/bugsnag.yml'
git_commit 'Configure BugSnag'
end
|
#chamber ⇒ Object
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
# File 'lib/rough_draft/rails_builder.rb', line 280
def chamber
'Gemfile', /chamber/
bundle_command 'update'
run "cd #{destination_root} && chamber init"
git_commit 'Configure Chamber'
remove_file 'config/secrets.yml'
create_file 'config/settings.yml', '', force: true
empty_directory 'config/settings'
template 'config/settings/http.yml.erb', 'config/settings/http.yml'
git_commit 'Setup default settings files'
end
|
#code_climate ⇒ Object
356
357
358
359
360
|
# File 'lib/rough_draft/rails_builder.rb', line 356
def code_climate
template 'config/settings/code_climate.yml.erb', 'config/settings/code_climate.yml'
git_commit 'Configure CodeClimate'
end
|
#coffeelint ⇒ Object
144
145
146
147
148
|
# File 'lib/rough_draft/rails_builder.rb', line 144
def coffeelint
copy_source_file 'coffeelint.json'
git_commit 'Configure Coffeelint'
end
|
#config ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/rough_draft/rails_builder.rb', line 44
def config
super
staging_environment
end
|
#css_lint ⇒ Object
150
151
152
153
154
|
# File 'lib/rough_draft/rails_builder.rb', line 150
def css_lint
copy_file 'csslintrc', '.csslintrc'
git_commit 'Configure CSS Lint'
end
|
#database_backup ⇒ Object
379
380
381
382
383
|
# File 'lib/rough_draft/rails_builder.rb', line 379
def database_backup
copy_source_file 'lib/tasks/db-backup.rake'
git_commit 'Setup Database Backup Tasks'
end
|
#database_seeding ⇒ Object
369
370
371
372
373
374
375
376
377
|
# File 'lib/rough_draft/rails_builder.rb', line 369
def database_seeding
remove_file 'db/seeds.rb'
copy_source_file 'lib/tasks/db-seed.rake'
copy_source_file 'db/seed.rb'
copy_source_file 'db/samplize.rb'
git_commit 'Setup Database Seeding and Sampling Tasks'
end
|
#database_yml ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rough_draft/rails_builder.rb', line 52
def database_yml
if options[:database] == 'postgresql'
template 'config/database-example.yml.erb', 'config/database.yml'
else
super
end
copy_file "#{destination_root}/config/database.yml", 'config/database-example.yml'
copy_source_file 'config/database-travis.yml'
end
|
#db ⇒ Object
63
64
65
66
67
|
# File 'lib/rough_draft/rails_builder.rb', line 63
def db
super
bundle_command 'exec rake db:drop:all db:create:all db:migrate db:test:prepare'
end
|
#devise ⇒ Object
266
267
268
269
270
271
|
# File 'lib/rough_draft/rails_builder.rb', line 266
def devise
route "root :to => 'devise/sessions#new'"
'config/routes.rb', /root/
git_commit 'Add Default (Commented) Devise Route'
end
|
#dirty_url ⇒ Object
307
308
309
310
311
312
|
# File 'lib/rough_draft/rails_builder.rb', line 307
def dirty_url
'Gemfile', /dirty_url/
bundle_command 'update'
git_commit 'Install dirty_url for default_url_options'
end
|
#disable_generators ⇒ Object
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/rough_draft/rails_builder.rb', line 168
def disable_generators
config = " config.generators do |generate|\n generate.helper false\n generate.javascript_engine false\n generate.request_specs false\n generate.routing_specs false\n generate.stylesheets false\n generate.test_framework :rspec\n generate.view_specs false\n end\n\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\n\n git_commit 'Disable generators'\nend\n"
|
#disable_turbolinks ⇒ Object
240
241
242
243
244
245
246
|
# File 'lib/rough_draft/rails_builder.rb', line 240
def disable_turbolinks
gsub_file 'app/assets/javascripts/application.js',
%r{//= require turbolinks\n},
''
git_commit 'Disable Turbolinks'
end
|
#environment_banners ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/rough_draft/rails_builder.rb', line 90
def environment_banners
empty_directory 'app/assets/images/decorations/environment-banners'
copy_source_file 'app/assets/images/decorations/environment-banners/development-banner.png'
copy_source_file 'app/assets/images/decorations/environment-banners/test-banner.png'
copy_source_file 'app/assets/images/decorations/environment-banners/staging-banner.png'
git_commit 'Add Environment Banners'
end
|
#factories ⇒ Object
200
201
202
203
204
205
|
# File 'lib/rough_draft/rails_builder.rb', line 200
def factories
copy_source_file 'spec/factories/user.rb'
copy_source_file 'spec/factories/all_factories_are_valid_spec.rb'
git_commit 'Setup Factories'
end
|
#foreman ⇒ Object
326
327
328
329
330
|
# File 'lib/rough_draft/rails_builder.rb', line 326
def foreman
copy_source_file 'Procfile'
git_commit 'Configure Foreman'
end
|
#gemfile ⇒ Object
12
13
14
|
# File 'lib/rough_draft/rails_builder.rb', line 12
def gemfile
template 'Gemfile.erb', 'Gemfile'
end
|
#git_finalize ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/rough_draft/rails_builder.rb', line 76
def git_finalize
git_commit 'Completed Template Initialization'
git :checkout => 'master --quiet'
git :merge => '--no-ff rough-draft --quiet --no-edit'
git :branch => '-D rough-draft --quiet'
git :push => 'origin master'
end
|
#git_hooks ⇒ Object
162
163
164
165
166
|
# File 'lib/rough_draft/rails_builder.rb', line 162
def git_hooks
copy_file 'overcommit.yml', '.overcommit.yml'
git_commit 'Configure Git Hooks'
end
|
#git_repo ⇒ Object
69
70
71
72
73
74
|
# File 'lib/rough_draft/rails_builder.rb', line 69
def git_repo
git :init => '--quiet'
git_commit 'Initial App Generation'
git :branch => 'rough-draft --quiet'
git :checkout => 'rough-draft --quiet'
end
|
#github_repo(repo_name) ⇒ Object
398
399
400
401
402
403
|
# File 'lib/rough_draft/rails_builder.rb', line 398
def github_repo(repo_name)
run "hub create #{repo_name} -p"
git remote: 'remove origin'
git remote: "add -t master origin [email protected]:#{repo_name}.git"
git push: "--quiet --set-upstream origin master"
end
|
#gitignore ⇒ Object
16
17
18
|
# File 'lib/rough_draft/rails_builder.rb', line 16
def gitignore
copy_file 'kompanee-gitignore', '.gitignore'
end
|
#helpers ⇒ Object
254
255
256
257
258
|
# File 'lib/rough_draft/rails_builder.rb', line 254
def helpers
remove_file 'app/helpers/application_helper.rb'
git_commit 'Remove uneeded helper'
end
|
#heroku_apps ⇒ Object
412
413
414
415
416
|
# File 'lib/rough_draft/rails_builder.rb', line 412
def heroku_apps
run "heroku create #{heroku_production_app_name} --remote=production"
run "heroku create #{heroku_staging_app_name} --remote=staging"
run "heroku config:add RACK_ENV=staging RAILS_ENV=staging --app=#{heroku_staging_app_name} --remote=staging"
end
|
#heroku_config ⇒ Object
418
419
420
|
# File 'lib/rough_draft/rails_builder.rb', line 418
def heroku_config
template 'config/settings/heroku.yml.erb', 'config/settings/heroku.yml'
end
|
#heroku_remotes ⇒ Object
422
423
424
425
426
427
428
429
430
431
432
433
|
# File 'lib/rough_draft/rails_builder.rb', line 422
def heroku_remotes
remotes = "\n# Set up staging and production git remotes\ngit remote add staging [email protected]:\#{heroku_staging_app_name}.git\ngit remote add production [email protected]:\#{heroku_production_app_name}.git\n RUBY\n\n append_file 'bin/setup', remotes\n\n git_commit 'Add staging and production remotes to setup script'\nend\n"
|
#heroku_specific_gems ⇒ Object
405
406
407
408
409
410
|
# File 'lib/rough_draft/rails_builder.rb', line 405
def heroku_specific_gems
'Gemfile', /rails_12factor/
bundle_command 'update'
git_commit 'Add Heroku-specific gems'
end
|
#human_text ⇒ Object
248
249
250
251
252
|
# File 'lib/rough_draft/rails_builder.rb', line 248
def human_text
template 'public/humans.txt.erb', 'public/humans.txt'
git_commit 'Add human.txt'
end
|
#i18n ⇒ Object
295
296
297
298
299
|
# File 'lib/rough_draft/rails_builder.rb', line 295
def i18n
template 'config/initializers/i18n.rb.erb', 'config/initializers/i18n.rb'
git_commit 'Configure i18n'
end
|
#jshint ⇒ Object
138
139
140
141
142
|
# File 'lib/rough_draft/rails_builder.rb', line 138
def jshint
copy_file 'jshintrc', '.jshintrc'
git_commit 'Configure JSHint'
end
|
#locales ⇒ Object
392
393
394
395
396
|
# File 'lib/rough_draft/rails_builder.rb', line 392
def locales
copy_file 'config/locales/date-formats-en.yml', 'config/locales/en.yml', force: true
git_commit 'Add default date/time formats'
end
|
#mail_safe ⇒ Object
332
333
334
335
336
|
# File 'lib/rough_draft/rails_builder.rb', line 332
def mail_safe
copy_source_file 'config/initializers/mail_safe.rb'
git_commit 'Configure Mail Safe'
end
|
#public_directory ⇒ Object
38
39
40
41
42
|
# File 'lib/rough_draft/rails_builder.rb', line 38
def public_directory
super
remove_file 'public/favicon.ico'
end
|
#rack_deflator ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/rough_draft/rails_builder.rb', line 214
def rack_deflator
config = "\n# Enable deflate / gzip compression of controller-generated responses\nconfig.middleware.use Rack::Deflater\n\n RUBY\n\n inject_into_file 'config/environments/production.rb',\n config.chomp,\n after: \"config.serve_static_assets = false\\n\"\n\n staging_environment\n\n git_commit 'Setup Rack Deflator'\nend\n"
|
#rack_timeout ⇒ Object
314
315
316
317
318
|
# File 'lib/rough_draft/rails_builder.rb', line 314
def rack_timeout
copy_source_file 'config/initializers/rack_timeout.rb'
git_commit 'Configure Rack Timeout'
end
|
#raise_on_delivery_errors ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/rough_draft/rails_builder.rb', line 99
def raise_on_delivery_errors
gsub_file 'config/environments/development.rb',
'raise_delivery_errors = false',
'raise_delivery_errors = true'
git_commit 'Raise Delivery Errors in Development'
end
|
#raise_on_unpermitted_parameters ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/rough_draft/rails_builder.rb', line 107
def raise_on_unpermitted_parameters
action_on_unpermitted_parameters = "\n\n# Raise an ActionController::UnpermittedParameters exception when\n# a parameter is not explcitly permitted but is passed anyway.\nconfig.action_controller.action_on_unpermitted_parameters = :raise\n RUBY\n\n inject_into_file(\n 'config/environments/development.rb',\n action_on_unpermitted_parameters.chomp,\n before: \"\\nend\"\n )\n\n git_commit 'Raise Errors in Development when unpermitted parameters are used'\nend\n"
|
#readme ⇒ Object
8
9
10
|
# File 'lib/rough_draft/rails_builder.rb', line 8
def readme
template 'README.md.erb', 'README.md'
end
|
#rspec ⇒ Object
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/rough_draft/rails_builder.rb', line 187
def rspec
generate 'rspec:install'
empty_directory_with_keep_file 'spec/shared_examples'
empty_directory_with_keep_file 'spec/support'
empty_directory_with_keep_file 'spec/helpers'
empty_directory_with_keep_file 'spec/acceptance'
copy_source_file 'spec/spec_helper.rb'
git_commit 'Setup RSpec'
end
|
#rubocop ⇒ Object
132
133
134
135
136
|
# File 'lib/rough_draft/rails_builder.rb', line 132
def rubocop
copy_file 'rubocop.yml', '.rubocop.yml'
git_commit 'Configure Rubocop'
end
|
#ruby_version ⇒ Object
84
85
86
87
88
|
# File 'lib/rough_draft/rails_builder.rb', line 84
def ruby_version
template 'ruby-version.erb', '.ruby-version'
git_commit 'Add .ruby-version'
end
|
#scss_lint ⇒ Object
156
157
158
159
160
|
# File 'lib/rough_draft/rails_builder.rb', line 156
def scss_lint
copy_file 'scss-lint.yml', '.scss-lint.yml'
git_commit 'Configure SCSS Lint'
end
|
#secret_token ⇒ Object
435
436
437
438
439
440
|
# File 'lib/rough_draft/rails_builder.rb', line 435
def secret_token
gsub_file 'config/initializers/secret_token.rb', /\s=\s.*/, ' = Chamber.env.application.secret_key'
template 'config/settings/application.yml.erb', 'config/settings/application.yml'
git_commit 'Secure the Secure Application Token'
end
|
#secure_configuration_settings ⇒ Object
442
443
444
445
446
447
|
# File 'lib/rough_draft/rails_builder.rb', line 442
def secure_configuration_settings
run "cd #{destination_root} && chamber secure"
run "cd #{destination_root} && chamber travis secure" if github_enabled?
git_commit 'Add all configuration settings', :include_settings => true
end
|
#setup ⇒ Object
449
450
451
|
# File 'lib/rough_draft/rails_builder.rb', line 449
def setup
run './bin/setup'
end
|
#setup_script ⇒ Object
125
126
127
128
129
130
|
# File 'lib/rough_draft/rails_builder.rb', line 125
def setup_script
copy_source_file 'bin/setup'
chmod 'bin/setup', 0755
git_commit 'Generate setup script'
end
|
273
274
275
276
277
278
|
# File 'lib/rough_draft/rails_builder.rb', line 273
def simple_form
generate 'simple_form:install'
remove_dir 'lib/templates'
git_commit 'Configure SimpleForm'
end
|
#skylight ⇒ Object
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
# File 'lib/rough_draft/rails_builder.rb', line 338
def skylight
bundle_command 'exec skylight setup'
template 'config/initializers/skylight.rb.erb', 'config/initializers/skylight.rb'
require 'yaml'
skylight_config = YAML.load(File.read("#{destination_root}/config/skylight.yml"))
remove_file 'config/skylight.yml'
create_file 'config/settings/skylight.yml' do
"skylight:\n_secure_application: \"\#{skylight_config['application']}\"\n_secure_authentication: \"\#{skylight_config['authentication']}\"\n SKYLIGHT\n end\n\n git_commit 'Configure Skylight'\nend\n"
|
#smtp ⇒ Object
385
386
387
388
389
390
|
# File 'lib/rough_draft/rails_builder.rb', line 385
def smtp
copy_source_file 'config/initializers/action_mailer.rb'
template 'config/settings/smtp.yml.erb', 'config/settings/smtp.yml'
git_commit 'Configure SMTP Options'
end
|
#stylesheets ⇒ Object
231
232
233
234
235
236
237
238
|
# File 'lib/rough_draft/rails_builder.rb', line 231
def stylesheets
remove_file 'app/assets/stylesheets/application.css'
get 'http://necolas.github.io/normalize.css/latest/normalize.css', 'app/assets/stylesheets/normalize.scss'
copy_file 'app/assets/stylesheets/application.css.scss'
git_commit 'Setup Base Stylesheets'
end
|
#travis ⇒ Object
207
208
209
210
211
212
|
# File 'lib/rough_draft/rails_builder.rb', line 207
def travis
run 'travis enable --pro'
template 'travis.yml.erb', '.travis.yml'
git_commit 'Setup Travis CI'
end
|
#unicorn ⇒ Object
320
321
322
323
324
|
# File 'lib/rough_draft/rails_builder.rb', line 320
def unicorn
copy_source_file 'config/unicorn.rb'
git_commit 'Configure Unicorn'
end
|
#views ⇒ Object
260
261
262
263
264
|
# File 'lib/rough_draft/rails_builder.rb', line 260
def views
replace_application_layout
install_shared_partials
install_maintenance_page
end
|
#xml_parsing ⇒ Object
301
302
303
304
305
|
# File 'lib/rough_draft/rails_builder.rb', line 301
def xml_parsing
copy_source_file 'config/initializers/xml.rb'
git_commit 'Disable XML Parsing'
end
|