rough_draft 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2123a6f2a2be775c9932f5c3f99a40abbffa8044
4
- data.tar.gz: 1c024fcbf7bebcb0d08973d3b106ada74895563d
3
+ metadata.gz: 6d53c6c06e8c34102c45bacf6171844dca0f5161
4
+ data.tar.gz: 493079c14b06dd2fc202129604b7ef144bb1dce1
5
5
  SHA512:
6
- metadata.gz: 19e0b4961b174ee9d88ccc7df5978d0999639d4e237cb122bc91cc1985d1c54b81d4e5d1e629e9f353627104f8010c00ff709681b6fe19ed184fbb7aa4d93859
7
- data.tar.gz: cc7b6473fbd28258dcb25e58ce91ef7f53452fafc66c04aa831a63229ae958a6425a61711e58befa4b4e2418392dfef6394f8e2878300cff2a5fe0371bcb559e
6
+ metadata.gz: 64ba765a8e6d271c27cd202311da9252c7d5aae79566f2daa6c3d689bb584a51d9a3d425e3362e1f36803745c377e26769b64130c9da718c58a861f538991bec
7
+ data.tar.gz: 36f69803fad43e4cd4d278f12b65c5baad337d0cfb2ee72fd9f0c242dd4fd3d58972473250604cd33fa6009c4f6a708aba0be70c8c41d5db2d74bd2c00e88dd6
data/bin/rough_draft CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'pathname'
3
3
 
4
- gem_root = (Pathname.new(__FILE__).dirname + '..').expand_path
5
- code_root = gem_root + 'lib'
6
- source_root = gem_root + 'source'
4
+ gem_root = (Pathname.new(__FILE__).dirname + '..').expand_path
5
+ code_root = gem_root + 'lib'
6
+
7
+ source_roots = {
8
+ rails: gem_root + 'source' + 'rails',
9
+ ember: gem_root + 'source' + 'ember',
10
+ shared: gem_root + 'source' + 'shared',
11
+ }
7
12
 
8
13
  $LOAD_PATH << code_root
9
14
 
@@ -16,8 +21,8 @@ if VALID_ROUGH_DRAFT_RESOURCES.include?(ARGV.first)
16
21
  class_name = "RoughDraft::#{product}Generator"
17
22
  generator_class = class_name.constantize
18
23
 
19
- generator_class.source_root source_root
20
- generator_class.source_paths << Rails::Generators::AppGenerator.source_root << source_root
24
+
25
+ generator_class.source_roots = source_roots
21
26
 
22
27
  generator_class.start
23
28
  else
@@ -27,13 +32,8 @@ This command generates resources which comply with our default styles and
27
32
  usage guidelines.
28
33
 
29
34
  Commands:
35
+ ember <app_name> - Generate a new Ember app
30
36
  rails <app_name> - Generate a new Rails app
31
- engine <engine_name> - Generate a new Rails engine
32
-
33
- Options:
34
- heroku - Generate an app for Staging and Production on Heroku
35
- github=<repo_name> - Generate a repo named 'repo_name' on Github
36
-
37
37
  USAGE
38
38
 
39
39
  puts usage
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+ require 'json'
1
3
  require 'rails/generators/rails/app/app_generator'
2
4
  require 'rough_draft/actions'
3
5
 
@@ -35,18 +37,10 @@ class RailsBuilder < Rails::AppBuilder
35
37
  empty_directory_with_keep_file 'app/assets/images/ui'
36
38
  end
37
39
 
38
- def public_directory
39
- super
40
-
41
- remove_file 'public/favicon.ico'
42
- end
43
-
44
40
  def config
45
41
  super
46
42
 
47
43
  remove_commented_route_lines
48
-
49
- staging_environment
50
44
  end
51
45
 
52
46
  def database_yml
@@ -63,6 +57,7 @@ class RailsBuilder < Rails::AppBuilder
63
57
  def db
64
58
  super
65
59
 
60
+ bundle_command 'install'
66
61
  bundle_command 'exec rake db:drop:all db:create:all db:migrate db:test:prepare'
67
62
  end
68
63
 
@@ -78,7 +73,7 @@ class RailsBuilder < Rails::AppBuilder
78
73
  git :checkout => 'master --quiet'
79
74
  git :merge => '--no-ff rough-draft --quiet --no-edit'
80
75
  git :branch => '-D rough-draft --quiet'
81
- git :push => 'origin master'
76
+ git :push => '--force -u origin master' if github_enabled?
82
77
  end
83
78
 
84
79
  def ruby_version
@@ -129,6 +124,13 @@ class RailsBuilder < Rails::AppBuilder
129
124
  git_commit 'Generate setup script'
130
125
  end
131
126
 
127
+ def deploy_script
128
+ template 'bin/deploy.erb', 'bin/deploy'
129
+ chmod 'bin/deploy', 0755
130
+
131
+ git_commit 'Generate deploy script'
132
+ end
133
+
132
134
  def rubocop
133
135
  copy_file 'rubocop.yml', '.rubocop.yml'
134
136
 
@@ -190,7 +192,7 @@ class RailsBuilder < Rails::AppBuilder
190
192
  empty_directory_with_keep_file 'spec/shared_examples'
191
193
  empty_directory_with_keep_file 'spec/support'
192
194
  empty_directory_with_keep_file 'spec/helpers'
193
- empty_directory_with_keep_file 'spec/acceptance'
195
+ empty_directory_with_keep_file 'spec/features'
194
196
 
195
197
  copy_source_file 'spec/spec_helper.rb'
196
198
 
@@ -198,12 +200,25 @@ class RailsBuilder < Rails::AppBuilder
198
200
  end
199
201
 
200
202
  def factories
203
+ copy_source_file 'spec/factories/sequences.rb'
201
204
  copy_source_file 'spec/factories/user.rb'
202
- copy_source_file 'spec/factories/all_factories_are_valid_spec.rb'
205
+ copy_source_file 'spec/factories_spec.rb'
203
206
 
204
207
  git_commit 'Setup Factories'
205
208
  end
206
209
 
210
+ def add_staging_environment
211
+ file 'config/environments/staging.rb', <<-HEREDOC
212
+ require File.expand_path('../production', __FILE__)
213
+
214
+ #{app_const_base}::Application.configure do
215
+ # Overwrite any production settings here
216
+ end
217
+ HEREDOC
218
+
219
+ git_commit 'Add a staging environment'
220
+ end
221
+
207
222
  def travis
208
223
  run 'travis login --pro --auto'
209
224
  run 'travis enable --pro'
@@ -212,6 +227,20 @@ class RailsBuilder < Rails::AppBuilder
212
227
  git_commit 'Setup Travis CI'
213
228
  end
214
229
 
230
+ def daily_log_rotation
231
+ inject_into_file 'config/environments/production.rb',
232
+ after: "config.log_level = :info\n" do
233
+ <<-HEREDOC
234
+
235
+ # Setup Daily Log Rotation
236
+ config.logger = Logger.new(config.paths['log'].first, 'daily')
237
+
238
+ HEREDOC
239
+ end
240
+
241
+ git_commit 'Add daily log rotation in production'
242
+ end
243
+
215
244
  def rack_deflator
216
245
  config = <<-RUBY
217
246
 
@@ -224,17 +253,47 @@ class RailsBuilder < Rails::AppBuilder
224
253
  config.chomp,
225
254
  after: "config.serve_static_assets = false\n"
226
255
 
227
- staging_environment
228
-
229
256
  git_commit 'Setup Rack Deflator'
230
257
  end
231
258
 
232
259
  def stylesheets
233
260
  remove_file 'app/assets/stylesheets/application.css'
234
261
 
235
- get 'http://necolas.github.io/normalize.css/latest/normalize.css', 'app/assets/stylesheets/normalize.scss'
262
+ get 'http://necolas.github.io/normalize.css/latest/normalize.css',
263
+ 'app/assets/stylesheets/normalize.scss'
264
+ copy_source_file 'app/assets/stylesheets/_environment-specific.scss'
236
265
  copy_file 'app/assets/stylesheets/application.css.scss'
237
266
 
267
+ empty_directory 'app/assets/stylesheets/base/extends'
268
+
269
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/extends/_button.scss',
270
+ 'app/assets/stylesheets/base/extends/_button.scss'
271
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/extends/_clearfix.scss',
272
+ 'app/assets/stylesheets/base/extends/_clearfix.scss'
273
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/extends/_errors.scss',
274
+ 'app/assets/stylesheets/base/extends/_errors.scss'
275
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/extends/_flashes.scss',
276
+ 'app/assets/stylesheets/base/extends/_flashes.scss'
277
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/extends/_hide-text.scss',
278
+ 'app/assets/stylesheets/base/extends/_hide-text.scss'
279
+
280
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_base.scss',
281
+ 'app/assets/stylesheets/base/_base.scss'
282
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_buttons.scss',
283
+ 'app/assets/stylesheets/base/_buttons.scss'
284
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_forms.scss',
285
+ 'app/assets/stylesheets/base/_forms.scss'
286
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_grid-settings.scss',
287
+ 'app/assets/stylesheets/base/_grid-settings.scss'
288
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_lists.scss',
289
+ 'app/assets/stylesheets/base/_lists.scss'
290
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_tables.scss',
291
+ 'app/assets/stylesheets/base/_tables.scss'
292
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_typography.scss',
293
+ 'app/assets/stylesheets/base/_typography.scss'
294
+ get 'https://raw.githubusercontent.com/thoughtbot/bitters/master/app/assets/stylesheets/_variables.scss',
295
+ 'app/assets/stylesheets/base/_variables.scss'
296
+
238
297
  git_commit 'Setup Base Stylesheets'
239
298
  end
240
299
 
@@ -281,24 +340,93 @@ class RailsBuilder < Rails::AppBuilder
281
340
  def chamber
282
341
  uncomment_lines 'Gemfile', /chamber/
283
342
  bundle_command 'update'
343
+
284
344
  run "cd #{destination_root} && chamber init"
285
345
 
286
346
  git_commit 'Configure Chamber'
287
347
 
288
348
  remove_file 'config/secrets.yml'
289
- create_file 'config/settings.yml', '', force: true
349
+ remove_file 'config/settings.yml'
290
350
  empty_directory 'config/settings'
291
- template 'config/settings/http.yml.erb', 'config/settings/http.yml'
351
+ template 'config/settings/http.yml.erb', 'config/settings/http.yml'
292
352
 
293
353
  git_commit 'Setup default settings files'
294
354
  end
295
355
 
356
+ def redis
357
+ if heroku_enabled?
358
+ run "heroku addons:add redistogo --app=#{heroku_staging_app_name}"
359
+
360
+ redis_config['staging'] = {}
361
+ redis_config['staging']['url'] = %x{heroku config:get REDISTOGO_URL --app=#{heroku_staging_app_name}}.chomp
362
+ redis_config['staging']['username'] = redis_config['staging']['url'][%r{redis://(\w+):(\w+)@}, 1]
363
+ redis_config['staging']['password'] = redis_config['staging']['url'][%r{redis://(\w+):(\w+)@}, 2]
364
+
365
+ run "heroku addons:add redistogo --app=#{heroku_production_app_name}"
366
+
367
+ redis_config['production'] = {}
368
+ redis_config['production']['url'] = %x{heroku config:get REDISTOGO_URL --app=#{heroku_production_app_name}}.chomp
369
+ redis_config['production']['username'] = redis_config['production']['url'][%r{redis://(\w+):(\w+)@}, 1]
370
+ redis_config['production']['password'] = redis_config['production']['url'][%r{redis://(\w+):(\w+)@}, 2]
371
+ end
372
+
373
+ template 'config/settings/redis.yml.erb', 'config/settings/redis.yml'
374
+
375
+ inject_into_file 'bin/setup',
376
+ "brew install redis\n",
377
+ after: "set -e\n\n"
378
+ end
379
+
380
+ def sidekiq
381
+ uncomment_lines 'Gemfile', /gem 'sidekiq'/
382
+ uncomment_lines 'Gemfile', /gem 'sinatra'/
383
+ bundle_command 'update'
384
+
385
+ template 'config/initializers/sidekiq.rb.erb', 'config/initializers/sidekiq.rb'
386
+ copy_source_file 'config/sidekiq.yml'
387
+
388
+ prepend_file 'config/routes.rb',
389
+ "require 'sidekiq/web'\n\n"
390
+ route "mount Sidekiq::Web => '/queue-fusion'"
391
+
392
+ git_commit 'Setup Sidekiq'
393
+ end
394
+
296
395
  def i18n
297
396
  template 'config/initializers/i18n.rb.erb', 'config/initializers/i18n.rb'
298
397
 
299
398
  git_commit 'Configure i18n'
300
399
  end
301
400
 
401
+ def memcached
402
+ if heroku_enabled?
403
+ run "heroku addons:add memcachier --app=#{heroku_staging_app_name}"
404
+
405
+ memcached_config['staging'] = {}
406
+ memcached_config['staging']['servers'] = %x{heroku config:get MEMCACHIER_SERVERS --app=#{heroku_staging_app_name}}.chomp.split(', ')
407
+ memcached_config['staging']['username'] = %x{heroku config:get MEMCACHIER_USERNAME --app=#{heroku_staging_app_name}}.chomp
408
+ memcached_config['staging']['password'] = %x{heroku config:get MEMCACHIER_PASSWORD --app=#{heroku_staging_app_name}}.chomp
409
+
410
+ run "heroku addons:add memcachier --app=#{heroku_production_app_name}"
411
+
412
+ memcached_config['production'] = {}
413
+ memcached_config['production']['servers'] = %x{heroku config:get MEMCACHIER_SERVERS --app=#{heroku_production_app_name}}.chomp.split(', ')
414
+ memcached_config['production']['username'] = %x{heroku config:get MEMCACHIER_USERNAME --app=#{heroku_production_app_name}}.chomp
415
+ memcached_config['production']['password'] = %x{heroku config:get MEMCACHIER_PASSWORD --app=#{heroku_production_app_name}}.chomp
416
+ end
417
+
418
+ template 'config/settings/memcached.yml.erb', 'config/settings/memcached.yml'
419
+ template 'config/initializers/dalli.rb.erb', 'config/initializers/dalli.rb'
420
+
421
+ gsub_file 'config/environments/development.rb',
422
+ 'config.action_controller.perform_caching = false',
423
+ 'config.action_controller.perform_caching = true'
424
+
425
+ inject_into_file 'bin/setup',
426
+ "brew install memcached\n",
427
+ after: "set -e\n\n"
428
+ end
429
+
302
430
  def xml_parsing
303
431
  copy_source_file 'config/initializers/xml.rb'
304
432
 
@@ -325,7 +453,7 @@ class RailsBuilder < Rails::AppBuilder
325
453
  end
326
454
 
327
455
  def foreman
328
- copy_source_file 'Procfile'
456
+ template 'Procfile.erb', 'Procfile'
329
457
 
330
458
  git_commit 'Configure Foreman'
331
459
  end
@@ -337,10 +465,12 @@ class RailsBuilder < Rails::AppBuilder
337
465
  end
338
466
 
339
467
  def skylight
468
+ uncomment_lines 'Gemfile', /gem 'skylight'/
469
+ bundle_command 'update'
470
+
340
471
  bundle_command 'exec skylight setup'
341
472
  template 'config/initializers/skylight.rb.erb', 'config/initializers/skylight.rb'
342
473
 
343
- require 'yaml'
344
474
  skylight_config = YAML.load(File.read("#{destination_root}/config/skylight.yml"))
345
475
  remove_file 'config/skylight.yml'
346
476
  create_file 'config/settings/skylight.yml' do
@@ -355,22 +485,54 @@ skylight:
355
485
  end
356
486
 
357
487
  def code_climate
488
+ uncomment_lines 'Gemfile', /codeclimate\-test\-reporter/
489
+ bundle_command 'update'
490
+
358
491
  template 'config/settings/code_climate.yml.erb', 'config/settings/code_climate.yml'
359
492
 
360
493
  git_commit 'Configure CodeClimate'
361
494
  end
362
495
 
496
+ def segment
497
+ uncomment_lines 'Gemfile', /analytics\-ruby/
498
+ uncomment_lines 'Gemfile', /segment\/analytics/
499
+ bundle_command 'update'
500
+
501
+ copy_source_file 'config/initializers/segment.rb'
502
+ template 'config/settings/segment.yml.erb', 'config/settings/segment.yml'
503
+ copy_source_file 'app/views/shared/_analytics.html.erb'
504
+
505
+ git_commit 'Configure segment.io'
506
+ end
507
+
363
508
  def bugsnag
509
+ uncomment_lines 'Gemfile', /bugsnag/
510
+ bundle_command 'update'
511
+
512
+ unless bugsnag_config['project_api_key']
513
+ raw_response = %x{curl -H "Content-Type: application/json" -H "Authorization: token #{bugsnag_config['user_api_key']}" -X POST --data '{"name": "#{app_title}", "type": "rails"}' https://api.bugsnag.com/account/projects}
514
+ response = JSON.load(raw_response)
515
+
516
+ bugsnag_config['project_api_key'] ||= response['api_key']
517
+ end
518
+
364
519
  copy_source_file 'config/initializers/bugsnag.rb'
365
520
  template 'config/settings/bugsnag.yml.erb', 'config/settings/bugsnag.yml'
366
521
 
367
522
  git_commit 'Configure BugSnag'
368
523
  end
369
524
 
525
+ def logentries
526
+ copy_source_file 'config/initializers/logentries.rb'
527
+ template 'config/settings/logentries.yml.erb', 'config/settings/logentries.yml'
528
+
529
+ git_commit 'Configure LogEntries'
530
+ end
531
+
370
532
  def database_seeding
371
533
  remove_file 'db/seeds.rb'
372
534
 
373
- copy_source_file 'lib/tasks/db-seed.rake'
535
+ copy_source_file 'lib/tasks/db_seed.rake'
374
536
  copy_source_file 'db/seed.rb'
375
537
  copy_source_file 'db/samplize.rb'
376
538
 
@@ -378,7 +540,7 @@ skylight:
378
540
  end
379
541
 
380
542
  def database_backup
381
- copy_source_file 'lib/tasks/db-backup.rake'
543
+ copy_source_file 'lib/tasks/db_backup.rake'
382
544
 
383
545
  git_commit 'Setup Database Backup Tasks'
384
546
  end
@@ -398,9 +560,25 @@ skylight:
398
560
 
399
561
  def github_repo(repo_name)
400
562
  run "hub create #{repo_name} -p"
401
- git remote: 'remove origin'
402
- git remote: "add -t master origin git@github.com:#{repo_name}.git"
403
- git push: "--quiet --set-upstream origin master"
563
+ end
564
+
565
+ def asset_host
566
+ gsub_file 'config/environments/production.rb',
567
+ '# config.action_controller.asset_host = "http://assets.example.com"',
568
+ "config.action_controller.asset_host = Chamber.env.assets.host"
569
+
570
+ gsub_file 'config/environments/production.rb',
571
+ "config.assets.version = '1.0'",
572
+ "config.assets.version = Chamber.env.assets.version"
573
+
574
+ inject_into_file 'config/environments/production.rb',
575
+ %Q{ config.static_cache_control = "public, max-age=31557600"\n},
576
+ after: "config.serve_static_assets = false\n"
577
+
578
+ empty_directory 'config/settings'
579
+ template 'config/settings/assets.yml.erb', 'config/settings/assets.yml'
580
+
581
+ git_commit 'Configure custom asset host'
404
582
  end
405
583
 
406
584
  def heroku_specific_gems
@@ -416,7 +594,27 @@ skylight:
416
594
  run "heroku config:add RACK_ENV=staging RAILS_ENV=staging --app=#{heroku_staging_app_name} --remote=staging"
417
595
  end
418
596
 
419
- def heroku_config
597
+ def heroku_addons
598
+ run "heroku addons:add heroku-postgresql --app=#{heroku_staging_app_name}"
599
+ run "heroku addons:add heroku-postgresql --app=#{heroku_production_app_name}"
600
+ run "heroku addons:add pgbackups --app=#{heroku_staging_app_name}"
601
+ run "heroku addons:add pgbackups --app=#{heroku_production_app_name}"
602
+ end
603
+
604
+ def heroku_app_config
605
+ config = <<-RUBY
606
+
607
+ # On Heroku don't initialize the entire Rails stack before compiling assets
608
+ config.assets.initialize_on_precompile = false
609
+
610
+ RUBY
611
+
612
+ if heroku_enabled?
613
+ inject_into_file 'config/environments/production.rb',
614
+ config,
615
+ after: "config.serve_static_assets = false\n"
616
+ end
617
+
420
618
  template 'config/settings/heroku.yml.erb', 'config/settings/heroku.yml'
421
619
  end
422
620
 
@@ -426,6 +624,10 @@ skylight:
426
624
  # Set up staging and production git remotes
427
625
  git remote add staging git@heroku.com:#{heroku_staging_app_name}.git
428
626
  git remote add production git@heroku.com:#{heroku_production_app_name}.git
627
+
628
+ # Join the staging and production apps.
629
+ #{join_heroku_app(heroku_staging_app_name)}
630
+ #{join_heroku_app(heroku_production_app_name)}
429
631
  RUBY
430
632
 
431
633
  append_file 'bin/setup', remotes
@@ -444,6 +646,8 @@ git remote add production git@heroku.com:#{heroku_production_app_name}.git
444
646
  run "cd #{destination_root} && chamber secure"
445
647
  run "cd #{destination_root} && chamber travis secure" if github_enabled?
446
648
 
649
+ run 'travis encrypt $(heroku auth:token) --pro --add deploy.api_key' if heroku_enabled? && github_enabled?
650
+
447
651
  git_commit 'Add all configuration settings', :include_settings => true
448
652
  end
449
653
 
@@ -458,10 +662,6 @@ git remote add production git@heroku.com:#{heroku_production_app_name}.git
458
662
  gsub_file 'config/routes.rb', /\n\n/, "\n"
459
663
  end
460
664
 
461
- def staging_environment
462
- copy_file File.expand_path('config/environments/production.rb'), 'config/environments/staging.rb', force: true
463
- end
464
-
465
665
  def replace_application_layout
466
666
  template 'app/views/layouts/application.html.erb.erb', 'app/views/layouts/application.html.erb', force: true
467
667
 
@@ -471,7 +671,7 @@ git remote add production git@heroku.com:#{heroku_production_app_name}.git
471
671
  def install_shared_partials
472
672
  directory 'app/views/shared'
473
673
  copy_source_file 'app/views/shared/_flashes.html.erb'
474
- copy_source_file 'app/views/shared/_javascript.html.erb'
674
+ template 'app/views/shared/_javascript.html.erb.erb', 'app/views/shared/_javascript.html.erb'
475
675
 
476
676
  git_commit 'Add shared partials'
477
677
  end
@@ -481,5 +681,15 @@ git remote add production git@heroku.com:#{heroku_production_app_name}.git
481
681
 
482
682
  git_commit 'Add basic maintenance page'
483
683
  end
684
+
685
+ def join_heroku_app(app_name)
686
+ <<-SHELL
687
+ # if heroku join --app #{app_name} &> /dev/null; then
688
+ # echo 'You are a collaborator on the "#{app_name}" Heroku app'
689
+ # else
690
+ # echo 'Ask for access to the "#{app_name}" Heroku app'
691
+ # fi
692
+ SHELL
693
+ end
484
694
  end
485
695
  end
@@ -1,3 +1,4 @@
1
+ require 'yaml'
1
2
  require 'rails/generators'
2
3
  require 'rails/generators/rails/app/app_generator'
3
4
  require 'rough_draft/rails_builder'
@@ -9,19 +10,6 @@ class RailsGenerator < Rails::Generators::AppGenerator
9
10
  :default => 'postgresql',
10
11
  :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
11
12
 
12
- class_option :heroku, :type => :boolean,
13
- :aliases => '-H',
14
- :default => false,
15
- :desc => 'Create staging and production Heroku apps'
16
-
17
- class_option :slack, :type => :string,
18
- :default => nil,
19
- :desc => 'The Slack room identifier where CI notifications should be posted'
20
-
21
- class_option :bugsnag, :type => :string,
22
- :default => nil,
23
- :desc => 'The API key used for integrating the app with BugSnag'
24
-
25
13
  class_option :skip_test_unit, :type => :boolean,
26
14
  :aliases => '-T',
27
15
  :default => true,
@@ -32,11 +20,6 @@ class RailsGenerator < Rails::Generators::AppGenerator
32
20
  :default => true,
33
21
  :desc => "Don't run bundle install"
34
22
 
35
- class_option :github, :type => :string,
36
- :aliases => '-G',
37
- :default => nil,
38
- :desc => 'Create Github repository and add remote origin pointed to repo'
39
-
40
23
  def finish_template
41
24
  super
42
25
 
@@ -50,6 +33,7 @@ class RailsGenerator < Rails::Generators::AppGenerator
50
33
  build :raise_on_delivery_errors
51
34
  build :raise_on_unpermitted_parameters
52
35
  build :setup_script
36
+ build :deploy_script
53
37
  build :disable_generators
54
38
  build :rubocop
55
39
  build :jshint
@@ -62,8 +46,13 @@ class RailsGenerator < Rails::Generators::AppGenerator
62
46
  build :rspec
63
47
  build :factories
64
48
 
49
+ # Staging
50
+ build :add_staging_environment
51
+
65
52
  # Production
66
53
  build :rack_deflator
54
+ build :daily_log_rotation if !logentries_config && !heroku_enabled?
55
+ build :asset_host if asset_host_config
67
56
 
68
57
  # Stylesheets
69
58
  build :stylesheets
@@ -99,23 +88,30 @@ class RailsGenerator < Rails::Generators::AppGenerator
99
88
  build :locales
100
89
 
101
90
  # Github
102
- if !options[:skip_git] && options[:github]
103
- build :github_repo, options[:github]
91
+ if !options[:skip_git] && github_enabled?
92
+ build :github_repo, github_config['repo']
104
93
  end
105
94
 
106
95
  # Heroku
107
- if options[:heroku]
96
+ if heroku_enabled?
108
97
  build :heroku_specific_gems
109
98
  build :heroku_apps
110
- build :heroku_config
99
+ build :heroku_app_config
111
100
  build :heroku_remotes
112
101
  end
113
102
 
103
+ # Caching
104
+ build :memcached if memcached_config
105
+
114
106
  # Integrations
115
- build :bugsnag if bugsnag_api_key.present?
116
- build :skylight
117
- build :code_climate if options[:github]
118
- build :travis if options[:github]
107
+ build :redis if redis_config
108
+ build :sidekiq if sidekiq_config && redis_config
109
+ build :segment if segment_config
110
+ build :bugsnag if bugsnag_config
111
+ build :logentries if logentries_config
112
+ build :skylight if skylight_config
113
+ build :code_climate if code_climate_config
114
+ build :travis if github_enabled?
119
115
 
120
116
  # Security
121
117
  build :secret_token
@@ -135,11 +131,19 @@ class RailsGenerator < Rails::Generators::AppGenerator
135
131
  private
136
132
 
137
133
  def heroku_enabled?
138
- options[:heroku]
134
+ heroku_config
139
135
  end
140
136
 
141
137
  def github_enabled?
142
- options[:github]
138
+ github_config
139
+ end
140
+
141
+ def app_title
142
+ app_name.titleize
143
+ end
144
+
145
+ def heroku_config
146
+ configuration['heroku']
143
147
  end
144
148
 
145
149
  def heroku_base_app_name
@@ -154,24 +158,64 @@ class RailsGenerator < Rails::Generators::AppGenerator
154
158
  "#{heroku_base_app_name}-staging"
155
159
  end
156
160
 
157
- def slack_room
158
- @@slack_room ||= options[:slack]
161
+ def slack_config
162
+ configuration['slack']
163
+ end
164
+
165
+ def github_config
166
+ configuration['github']
167
+ end
168
+
169
+ def memcached_config
170
+ configuration['memcached']
159
171
  end
160
172
 
161
- def code_climate_repo_token
162
- if !defined?(@@code_climate_repo_token) || @@code_climate_repo_token.nil?
163
- say "Visit codeclimate.com and set up the integration for #{options[:github]}."
173
+ def code_climate_config
174
+ return {} if !configuration['code_climate'] || !github_enabled?
175
+
176
+ if configuration['code_climate'].is_a? TrueClass
177
+ say "Visit codeclimate.com and set up the integration for #{configuration['github']['repo']}."
164
178
  say "When you're done, find the CODECLIMATE_REPO_TOKEN on the code coverage settings page."
165
179
  say ""
166
180
 
167
- @@code_climate_repo_token = ask "Enter it here:"
181
+ configuration['code_climate'] = ask "Enter it here:"
168
182
  else
169
- @@code_climate_repo_token
183
+ configuration['code_climate']
170
184
  end
171
185
  end
172
186
 
173
- def bugsnag_api_key
174
- @@bugsnag_api_key ||= options[:bugsnag]
187
+ def segment_config
188
+ configuration['segment']
189
+ end
190
+
191
+ def bugsnag_config
192
+ configuration['bugsnag']
193
+ end
194
+
195
+ def logentries_config
196
+ configuration['logentries']
197
+ end
198
+
199
+ def redis_config
200
+ configuration['redis']
201
+ end
202
+
203
+ def sidekiq_config
204
+ configuration['sidekiq']
205
+ end
206
+
207
+ def asset_host_config
208
+ configuration['asset_hosts']
209
+ end
210
+
211
+ def skylight_config
212
+ configuration['skylight']
213
+ end
214
+
215
+ def self.source_roots=(other)
216
+ source_paths << Rails::Generators::AppGenerator.source_root
217
+ source_paths << other[:shared]
218
+ source_paths << other[:rails]
175
219
  end
176
220
 
177
221
  protected
@@ -179,5 +223,17 @@ class RailsGenerator < Rails::Generators::AppGenerator
179
223
  def get_builder_class
180
224
  RoughDraft::RailsBuilder
181
225
  end
226
+
227
+ def configuration
228
+ @@configuration ||= YAML.load(configuration_data)
229
+ end
230
+
231
+ def configuration_data
232
+ File.read(configuration_file_location)
233
+ end
234
+
235
+ def configuration_file_location
236
+ Pathname.new(ENV['HOME']) + '.rough_draft.yml'
237
+ end
182
238
  end
183
239
  end
@@ -1,3 +1,4 @@
1
1
  module RoughDraft
2
- VERSION = '2.1.0'
2
+ VERSION = '2.3.0'
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rough_draft
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-09 00:00:00.000000000 Z
12
+ date: 2014-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails