rough_draft 1.0.0 → 1.1.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: e09997bba0ca980cb909fd7dd485b4e795541bf2
4
- data.tar.gz: d4ff2645264ca60db7a9912afbd27184b8611bff
3
+ metadata.gz: df405e5e1c9afb4eac866848c0879e98680955c7
4
+ data.tar.gz: 806505cf70909e816098813f4f990bb972af4234
5
5
  SHA512:
6
- metadata.gz: 927607fa82f8eabb18743c62b3261075b3ce1750ac77fed9ecd5a0c76e833602d54d2f8e7ec70083eedc825a4778d645d86c3807ddcfb5fbee7a215b117b5316
7
- data.tar.gz: ae4942594576a02fa1036a86c45840ee153bf6afcdd3f5256040543d9ab8981d5f9b23d5bbdf4b049fda6e4b80c33cde0b1599cf4326975a0e9bbbc136d63de3
6
+ metadata.gz: 41f64d6e2b7610748a40b1569707aa22040e838da3579130b60facc4e1574796d27f94146cbe338ab93a2d94208a45c94ed85a699995620fafb252a2c8cd1f1a
7
+ data.tar.gz: 0bd1be04e349f3572abd1c7fc704eebad488b44481acb322f1fb0fa6074c181eeba68e088da9631bfb73e43d8c3a263eef5e638e76bf1a6a9488e28888240a83
data/bin/rough_draft CHANGED
@@ -1,14 +1,40 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'pathname'
3
3
 
4
- source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
5
- $LOAD_PATH << source_path
4
+ gem_root = (Pathname.new(__FILE__).dirname + '..').expand_path
5
+ code_root = gem_root + 'lib'
6
+ source_root = gem_root + 'source'
7
+
8
+ $LOAD_PATH << code_root
6
9
 
7
10
  require 'rough_draft'
8
11
 
9
- source_root = File.expand_path(File.join('..', 'source'), File.dirname(__FILE__))
12
+ VALID_ROUGH_DRAFT_RESOURCES = %w{rails engine}
13
+
14
+ if VALID_ROUGH_DRAFT_RESOURCES.include?(ARGV.first)
15
+ product = ARGV.shift.titleize
16
+ class_name = "RoughDraft::#{product}Generator"
17
+ generator_class = class_name.constantize
18
+
19
+ generator_class.source_root source_root
20
+ generator_class.source_paths << Rails::Generators::AppGenerator.source_root << source_root
21
+
22
+ generator_class.start
23
+ else
24
+ usage = <<-USAGE
25
+
26
+ This command generates resources which comply with our default styles and
27
+ usage guidelines.
28
+
29
+ Commands:
30
+ 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
10
36
 
11
- RoughDraft::AppGenerator.source_root source_root
12
- RoughDraft::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << source_root
37
+ USAGE
13
38
 
14
- RoughDraft::AppGenerator.start
39
+ puts usage
40
+ end
@@ -2,7 +2,7 @@ require 'rails/generators/rails/app/app_generator'
2
2
  require 'rough_draft/actions'
3
3
 
4
4
  module RoughDraft
5
- class AppBuilder < Rails::AppBuilder
5
+ class RailsBuilder < Rails::AppBuilder
6
6
  include RoughDraft::Actions
7
7
 
8
8
  def readme
@@ -56,7 +56,8 @@ class AppBuilder < Rails::AppBuilder
56
56
  super
57
57
  end
58
58
 
59
- copy_file "#{destination_root}/config/database.yml", 'config/database-example.yml'
59
+ copy_file "#{destination_root}/config/database.yml", 'config/database-example.yml'
60
+ copy_source_file 'config/database-travis.yml'
60
61
  end
61
62
 
62
63
  def db
@@ -77,6 +78,7 @@ class AppBuilder < Rails::AppBuilder
77
78
  git :checkout => 'master --quiet'
78
79
  git :merge => '--no-ff rough-draft --quiet --no-edit'
79
80
  git :branch => '-D rough-draft --quiet'
81
+ git :push => 'origin master'
80
82
  end
81
83
 
82
84
  def ruby_version
@@ -127,6 +129,12 @@ class AppBuilder < Rails::AppBuilder
127
129
  git_commit 'Generate setup script'
128
130
  end
129
131
 
132
+ def rubocop
133
+ copy_file 'rubocop.yml', '.rubocop.yml'
134
+
135
+ git_commit 'Configure Rubocop'
136
+ end
137
+
130
138
  def disable_generators
131
139
  config = <<-RUBY
132
140
  config.generators do |generate|
@@ -167,6 +175,7 @@ class AppBuilder < Rails::AppBuilder
167
175
  end
168
176
 
169
177
  def travis
178
+ run 'travis enable'
170
179
  template 'travis.yml.erb', '.travis.yml'
171
180
 
172
181
  git_commit 'Setup Travis CI'
@@ -358,6 +367,9 @@ skylight:
358
367
 
359
368
  def github_repo(repo_name)
360
369
  run "hub create #{repo_name}"
370
+ git remote: 'remove origin'
371
+ git remote: "add -t master origin git@github.com:#{repo_name}.git"
372
+ git push: "--quiet --set-upstream origin master"
361
373
  end
362
374
 
363
375
  def heroku_specific_gems
@@ -368,25 +380,28 @@ skylight:
368
380
  end
369
381
 
370
382
  def heroku_apps
371
- valid_heroku_app_name=app_name.gsub(/_/, '-')
383
+ run "heroku create #{heroku_production_app_name} --remote=production"
384
+ run "heroku create #{heroku_staging_app_name} --remote=staging"
385
+ run "heroku config:add RACK_ENV=staging RAILS_ENV=staging --app=#{heroku_staging_app_name} --remote=staging"
386
+ end
372
387
 
373
- run "heroku create #{valid_heroku_app_name}-production --remote=production"
374
- run "heroku create #{valid_heroku_app_name}-staging --remote=staging"
375
- run "heroku config:add RACK_ENV=staging RAILS_ENV=staging --app=#{valid_heroku_app_name}-staging --remote=staging"
388
+ def heroku_config
389
+ template 'config/settings/heroku.yml.erb', 'config/settings/heroku.yml'
376
390
  end
377
391
 
378
392
  def heroku_remotes
379
- valid_heroku_app_name=app_name.gsub(/_/, '-')
380
-
381
393
  remotes = <<-RUBY
382
394
 
383
395
  # Set up staging and production git remotes
384
- git remote add staging git@heroku.com:#{valid_heroku_app_name}-staging.git
385
- git remote add production git@heroku.com:#{valid_heroku_app_name}-production.git
396
+ git remote add staging git@heroku.com:#{heroku_staging_app_name}.git
397
+ git remote add production git@heroku.com:#{heroku_production_app_name}.git
386
398
  RUBY
387
399
 
388
400
  append_file 'bin/setup', remotes
389
401
 
402
+ git remote: "add staging git@heroku.com:#{heroku_staging_app_name}.git"
403
+ git remote: "add production git@heroku.com:#{heroku_production_app_name}.git"
404
+
390
405
  git_commit 'Add staging and production remotes to setup script'
391
406
  end
392
407
 
@@ -399,6 +414,7 @@ git remote add production git@heroku.com:#{valid_heroku_app_name}-production.git
399
414
 
400
415
  def secure_configuration_settings
401
416
  run "cd #{destination_root} && chamber secure"
417
+ run "cd #{destination_root} && chamber travis secure" if github_enabled?
402
418
 
403
419
  git_commit 'Add all configuration settings', :include_settings => true
404
420
  end
@@ -1,9 +1,9 @@
1
1
  require 'rails/generators'
2
2
  require 'rails/generators/rails/app/app_generator'
3
- require 'rough_draft/app_builder'
3
+ require 'rough_draft/rails_builder'
4
4
 
5
5
  module RoughDraft
6
- class AppGenerator < Rails::Generators::AppGenerator
6
+ class RailsGenerator < Rails::Generators::AppGenerator
7
7
  class_option :database, :type => :string,
8
8
  :aliases => '-d',
9
9
  :default => 'postgresql',
@@ -14,6 +14,14 @@ class AppGenerator < Rails::Generators::AppGenerator
14
14
  :default => false,
15
15
  :desc => 'Create staging and production Heroku apps'
16
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
+
17
25
  class_option :skip_test_unit, :type => :boolean,
18
26
  :aliases => '-T',
19
27
  :default => true,
@@ -43,11 +51,11 @@ class AppGenerator < Rails::Generators::AppGenerator
43
51
  build :raise_on_unpermitted_parameters
44
52
  build :setup_script
45
53
  build :disable_generators
54
+ build :rubocop
46
55
 
47
56
  # Test
48
57
  build :rspec
49
58
  build :factories
50
- build :travis
51
59
 
52
60
  # Production
53
61
  build :rack_deflator
@@ -74,9 +82,6 @@ class AppGenerator < Rails::Generators::AppGenerator
74
82
  build :unicorn
75
83
  build :foreman
76
84
  build :mail_safe
77
- build :skylight
78
- build :code_climate
79
- build :bugsnag
80
85
 
81
86
  # Database
82
87
  build :database_seeding
@@ -97,9 +102,16 @@ class AppGenerator < Rails::Generators::AppGenerator
97
102
  if options[:heroku]
98
103
  build :heroku_specific_gems
99
104
  build :heroku_apps
105
+ build :heroku_config
100
106
  build :heroku_remotes
101
107
  end
102
108
 
109
+ # Integrations
110
+ build :bugsnag if bugsnag_api_key.present?
111
+ build :skylight
112
+ build :code_climate if options[:github]
113
+ build :travis if options[:github]
114
+
103
115
  # Security
104
116
  build :secret_token
105
117
  build :secure_configuration_settings
@@ -116,22 +128,50 @@ class AppGenerator < Rails::Generators::AppGenerator
116
128
 
117
129
  private
118
130
 
131
+ def heroku_enabled?
132
+ options[:heroku]
133
+ end
134
+
135
+ def github_enabled?
136
+ options[:github]
137
+ end
138
+
139
+ def heroku_base_app_name
140
+ app_name.gsub(/_/, '-')
141
+ end
142
+
143
+ def heroku_production_app_name
144
+ "#{heroku_base_app_name}-production"
145
+ end
146
+
147
+ def heroku_staging_app_name
148
+ "#{heroku_base_app_name}-staging"
149
+ end
150
+
119
151
  def slack_room
120
- @@slack_room ||= ask "What is the Slack room you would like CI notifications posted to?"
152
+ @@slack_room ||= options[:slack]
121
153
  end
122
154
 
123
155
  def code_climate_repo_token
124
- @@code_climate_repo_token ||= ask "What is the repo token for this app on Code Climate?"
156
+ if !defined?(@@code_climate_repo_token) || @@code_climate_repo_token.nil?
157
+ say "Visit codeclimate.com and set up the integration for #{options[:github]}."
158
+ say "When you're done, find the CODECLIMATE_REPO_TOKEN on the code coverage settings page."
159
+ say ""
160
+
161
+ @@code_climate_repo_token = ask "Enter it here:"
162
+ else
163
+ @@code_climate_repo_token
164
+ end
125
165
  end
126
166
 
127
167
  def bugsnag_api_key
128
- @@bugsnag_api_key ||= ask "What is the API key for this app on BugSnag?"
168
+ @@bugsnag_api_key ||= options[:bugsnag]
129
169
  end
130
170
 
131
171
  protected
132
172
 
133
173
  def get_builder_class
134
- RoughDraft::AppBuilder
174
+ RoughDraft::RailsBuilder
135
175
  end
136
176
  end
137
177
  end
@@ -1,3 +1,3 @@
1
1
  module RoughDraft
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/rough_draft.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'rough_draft/version'
2
- require 'rough_draft/app_generator'
2
+ require 'rough_draft/rails_generator'
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: 1.0.0
4
+ version: 1.1.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-02 00:00:00.000000000 Z
12
+ date: 2014-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -39,8 +39,8 @@ files:
39
39
  - bin/rough_draft
40
40
  - lib/rough_draft.rb
41
41
  - lib/rough_draft/actions.rb
42
- - lib/rough_draft/app_builder.rb
43
- - lib/rough_draft/app_generator.rb
42
+ - lib/rough_draft/rails_builder.rb
43
+ - lib/rough_draft/rails_generator.rb
44
44
  - lib/rough_draft/version.rb
45
45
  homepage: https://github.com/thekompanee/blueprints/rails
46
46
  licenses: []