flatiron-rails 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/templates/flatiron.rb +69 -63
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 575938bab2932893843465dea7cc4f33f0341d58
4
- data.tar.gz: fdc0ead661e6caefaa504a07f72f831affe78f64
3
+ metadata.gz: 5426da71797f4a9894a1002c1966e7f69c9670c6
4
+ data.tar.gz: ba25f050d02aacc2447835cf63a54cb6b5cfedb2
5
5
  SHA512:
6
- metadata.gz: fd46dc20444894d250545a3523d9abf9ce051d3bfece723d856df7c9f5038add03e25ba40903c3f0ff98a2787fbaac8c70490fa5b2529dfd07529c38b8f58296
7
- data.tar.gz: 897fbeb85f9b45e5f414c8147c66e263aef6f6769c592cd489c76e255fafa85a4879a36e0caf862752c61eac6ca55ff2e96e2b8df80cbfef2bb3f5bee24ecce8
6
+ metadata.gz: 5e93b7030813fdb298c1c041bd34ffcdf000878d42023a483fb36e987894e313edc0d2be1a749e5c771fb419a544b9d59c2fd54dc396c9e514af13c4ed9f2cb1
7
+ data.tar.gz: d2f66aa331e4ad32672e8801dc0641b15ed86e183984b0b5370f8b8c326b88f4b624e1ec583e062e7b78821c0a17eeb2ebd7f8ae635ae187635bec153f2cb3da
@@ -1,16 +1,51 @@
1
1
  # Prevent automatic run of bundle install
2
2
  def run_bundle ; end
3
3
 
4
+ # Helper method to write to secrets.yml
5
+ def add_secret_for(options)
6
+ key = "#{options.first[0].to_s}"
7
+ value = options.first[1]
8
+ env = options[:env].to_s
9
+
10
+ File.open("config/secrets.yml", "r+") do |f|
11
+ out = ""
12
+ f.each do |line|
13
+ if line =~ /#{env}:/
14
+ out << "#{line}"
15
+ out << " #{key}: #{value}\n"
16
+ else
17
+ out << line
18
+ end
19
+ end
20
+ f.pos = 0
21
+ f.print out.chomp
22
+ f.truncate(f.pos)
23
+ end
24
+ end
25
+
26
+ # Helper method to remove gems from Gemfile
27
+ def remove_from_gemfile(gem_name)
28
+ File.open("Gemfile", "r+") do |f|
29
+ out = ""
30
+ f.each do |line|
31
+ unless line =~ /#{gem_name}/i
32
+ out << line
33
+ end
34
+ end
35
+ f.pos = 0
36
+ f.print out.chomp
37
+ f.truncate(f.pos)
38
+ end
39
+ end
40
+
4
41
  # Remove sqlite3 from default gem group and set Ruby version to 2.1.0
42
+ remove_from_gemfile("sqlite3")
43
+
5
44
  File.open("Gemfile", "r+") do |f|
6
45
  out = ""
7
46
  f.each do |line|
8
47
  if line =~ /source 'https:\/\/rubygems.org'/
9
48
  out << line + "\nruby \"2.1.0\"\n"
10
- elsif line =~ /# Use sqlite3 as the database for Active Record/
11
- out << ""
12
- elsif line =~ /gem 'sqlite3'/
13
- out << "\n"
14
49
  else
15
50
  out << line
16
51
  end
@@ -91,17 +126,7 @@ File.open("Gemfile", "r+") do |f|
91
126
  end
92
127
 
93
128
  # Disable Turbolinks
94
- File.open("Gemfile", "r+") do |f|
95
- out = ""
96
- f.each do |line|
97
- unless line =~ /gem 'turbolinks'/ || line =~ /# Turbolinks/
98
- out << line
99
- end
100
- end
101
- f.pos = 0
102
- f.print out.chomp
103
- f.truncate(f.pos)
104
- end
129
+ remove_from_gemfile("turbolinks")
105
130
 
106
131
  File.open("app/assets/javascripts/application.js", "r+") do |f|
107
132
  out = ""
@@ -129,9 +154,32 @@ File.open("app/views/layouts/application.html.erb", "r+") do |f|
129
154
  f.truncate(f.pos)
130
155
  end
131
156
 
157
+ # Optionally set up Devise
158
+ devise = false
159
+
160
+ if yes?("Use Devise? [y/N]")
161
+ devise = true
162
+ gem 'devise'
163
+ environment 'config.action_mailer.default_url_options = { host: Rails.application.secrets.host }', env: 'production'
164
+ add_secret_for(:host => 'YOUR PRODUCTION HOST URL/IP HERE', :env => 'production')
165
+ end
166
+
132
167
  # Bundle
133
168
  system("bundle")
134
169
 
170
+ if devise
171
+ run('rails generate devise:install')
172
+ if yes?("Setup user model for Devise? [y/N]")
173
+ model_name = ask("What do you want to call it (default=User)?").chomp.capitalize
174
+ if model_name.size == 0
175
+ model_name = "User"
176
+ end
177
+
178
+ run("rails generate devise #{model_name}")
179
+ rake("db:migrate")
180
+ end
181
+ end
182
+
135
183
  # Generate RSpec files
136
184
  generate(:"rspec:install")
137
185
 
@@ -238,22 +286,9 @@ File.open("app/views/layouts/application.html.erb", "r+") do |f|
238
286
  f.truncate(f.pos)
239
287
  end
240
288
 
241
- File.open("config/secrets.yml", "r+") do |f|
242
- out = ""
243
- f.each do |line|
244
- if line =~ /production:/
245
- out << "#{line}"
246
- out << " google_analytics_code: 'YOUR CODE HERE'\n"
247
- else
248
- out << line
249
- end
250
- end
251
- f.pos = 0
252
- f.print out.chomp
253
- f.truncate(f.pos)
254
- end
289
+ add_secret_for(google_analytics_code: 'YOUR CODE HERE', env: :production)
255
290
 
256
- #Sset up sprockets_better_errors
291
+ #Set up sprockets_better_errors
257
292
  environment 'config.assets.raise_production_errors = true', env: 'development'
258
293
 
259
294
  # Turn on precompile assets in production
@@ -386,45 +421,16 @@ def setup_database_yml_for_ninefold
386
421
  end
387
422
 
388
423
  def setup_secrets_yml_for_ninefold
389
- File.open("config/secrets.yml", "r+") do |f|
390
- out = ""
391
- f.each do |line|
392
- if line =~ /production:/
393
- out << "#{line}"
394
- out << <<-SECRETS.gsub(/^ {8}/, '')
395
- ninefold_db: 'YOUR NINEFOLD DATABASE NAME HERE'
396
- ninefold_user: 'NINEFOLD DATABASE USERNAME HERE'
397
- ninefold_pass: 'NINEFOLD DATABASE PASSWORD HERE'
398
- SECRETS
399
- else
400
- out << line
401
- end
402
- end
403
- f.pos = 0
404
- f.print out.chomp
405
- f.truncate(f.pos)
406
- end
407
- end
408
-
409
- def remove_12_factor
410
- File.open("Gemfile", "r+") do |f|
411
- out = ""
412
- f.each do |line|
413
- unless line =~ /gem "rails_12factor"/
414
- out << line
415
- end
416
- end
417
- f.pos = 0
418
- f.print out.chomp
419
- f.truncate(f.pos)
420
- end
424
+ add_secret_for(ninefold_db: 'YOUR NINEFOLD DATABASE NAME HERE', env: :production)
425
+ add_secret_for(ninefold_user: 'NINEFOLD DATABASE USERNAME HERE', env: :production)
426
+ add_secret_for(ninefold_pass: 'NINEFOLD DATABASE PASSWORD HERE', env: :production)
421
427
  end
422
428
 
423
429
  # Change setup for Ninefold
424
430
  if yes?("Set up for Ninefold instead of Heroku? [y/N]")
425
431
  setup_database_yml_for_ninefold
426
432
  setup_secrets_yml_for_ninefold
427
- remove_12_factor
433
+ remove_from_gemfile("rails_12factor")
428
434
  else
429
435
  file 'bin/setup', <<-SETUP.strip_heredoc.chomp
430
436
  #!/usr/bin/env ruby
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatiron-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arel English