rails_apps_composer 2.6.13 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_wizard/diagnostics.rb +12 -25
- data/recipes/admin.rb +3 -6
- data/recipes/core.rb +4 -5
- data/recipes/deployment.rb +2 -1
- data/recipes/devise.rb +32 -0
- data/recipes/email.rb +22 -108
- data/recipes/email_dev.rb +4 -7
- data/recipes/example.rb +5 -5
- data/recipes/extras.rb +9 -16
- data/recipes/frontend.rb +4 -4
- data/recipes/gems.rb +29 -100
- data/recipes/git.rb +2 -1
- data/recipes/init.rb +29 -100
- data/recipes/learn_rails.rb +3 -3
- data/recipes/omniauth.rb +32 -0
- data/recipes/pages.rb +33 -0
- data/recipes/rails_bootstrap.rb +1 -7
- data/recipes/rails_devise.rb +1 -4
- data/recipes/rails_devise_pundit.rb +1 -4
- data/recipes/rails_foundation.rb +1 -7
- data/recipes/rails_omniauth.rb +1 -19
- data/recipes/rails_signup_download.rb +3 -4
- data/recipes/railsapps.rb +15 -213
- data/recipes/readme.rb +5 -8
- data/recipes/roles.rb +36 -0
- data/recipes/setup.rb +20 -73
- data/recipes/{tests4.rb → tests.rb} +6 -6
- data/templates/helpers.erb +3 -11
- data/templates/layout.erb +6 -6
- data/version.rb +1 -1
- metadata +7 -10
- data/recipes/controllers.rb +0 -86
- data/recipes/models.rb +0 -112
- data/recipes/prelaunch.rb +0 -118
- data/recipes/routes.rb +0 -53
- data/recipes/saas.rb +0 -216
- data/recipes/testing.rb +0 -276
- data/recipes/views.rb +0 -65
data/recipes/gems.rb
CHANGED
@@ -11,8 +11,6 @@ insert_into_file('Gemfile', "ruby '#{RUBY_VERSION}'\n", :before => /^ *gem 'rail
|
|
11
11
|
gsub_file 'Gemfile', /group :doc do/, ''
|
12
12
|
gsub_file 'Gemfile', /\s*gem 'sdoc', require: false\nend/, ''
|
13
13
|
|
14
|
-
assets_group = rails_4? ? nil : :assets
|
15
|
-
|
16
14
|
## Web Server
|
17
15
|
if (prefs[:dev_webserver] == prefs[:prod_webserver])
|
18
16
|
add_gem 'thin' if prefer :dev_webserver, 'thin'
|
@@ -32,20 +30,10 @@ else
|
|
32
30
|
add_gem 'passenger', :group => :production if prefer :prod_webserver, 'passenger_standalone'
|
33
31
|
end
|
34
32
|
|
35
|
-
## Rails 4.0 attr_accessible Compatibility
|
36
|
-
# if prefer :apps4, false
|
37
|
-
# add_gem 'protected_attributes' if rails_4?
|
38
|
-
# end
|
39
|
-
|
40
33
|
## Database Adapter
|
41
34
|
unless prefer :database, 'default'
|
42
35
|
gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
|
43
36
|
end
|
44
|
-
if rails_4?
|
45
|
-
add_gem 'mongoid', github: 'mongoid/mongoid' if prefer :orm, 'mongoid'
|
46
|
-
else
|
47
|
-
add_gem 'mongoid' if prefer :orm, 'mongoid'
|
48
|
-
end
|
49
37
|
gsub_file 'Gemfile', /gem 'pg'.*/, ''
|
50
38
|
add_gem 'pg' if prefer :database, 'postgresql'
|
51
39
|
gsub_file 'Gemfile', /gem 'mysql2'.*/, ''
|
@@ -66,63 +54,23 @@ if prefer :templates, 'slim'
|
|
66
54
|
end
|
67
55
|
|
68
56
|
## Testing Framework
|
69
|
-
if
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
add_gem 'selenium-webdriver', :group => :test
|
79
|
-
if prefer :continuous_testing, 'guard'
|
80
|
-
add_gem 'guard-bundler', :group => :development
|
81
|
-
add_gem 'guard-rails', :group => :development
|
82
|
-
add_gem 'guard-rspec', :group => :development
|
83
|
-
add_gem 'rb-inotify', :group => :development, :require => false
|
84
|
-
add_gem 'rb-fsevent', :group => :development, :require => false
|
85
|
-
add_gem 'rb-fchange', :group => :development, :require => false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
else
|
89
|
-
if prefer :unit_test, 'rspec'
|
90
|
-
add_gem 'rspec-rails', :group => [:development, :test]
|
91
|
-
add_gem 'capybara', :group => :test if prefer :integration, 'rspec-capybara'
|
92
|
-
add_gem 'database_cleaner', '1.0.1', :group => :test
|
93
|
-
if prefer :orm, 'mongoid'
|
94
|
-
if rails_4?
|
95
|
-
add_gem 'mongoid-rspec', '>= 1.10.0', :group => :test
|
96
|
-
else
|
97
|
-
add_gem 'mongoid-rspec', :group => :test
|
98
|
-
end
|
99
|
-
end
|
100
|
-
add_gem 'email_spec', :group => :test
|
101
|
-
end
|
102
|
-
if prefer :unit_test, 'minitest'
|
103
|
-
add_gem 'minitest-spec-rails', :group => :test
|
104
|
-
add_gem 'minitest-wscolor', :group => :test
|
105
|
-
add_gem 'capybara', :group => :test if prefer :integration, 'minitest-capybara'
|
106
|
-
end
|
107
|
-
if prefer :integration, 'cucumber'
|
108
|
-
add_gem 'cucumber-rails', :group => :test, :require => false
|
109
|
-
add_gem 'database_cleaner', '1.0.1', :group => :test unless prefer :unit_test, 'rspec'
|
110
|
-
add_gem 'launchy', :group => :test
|
111
|
-
add_gem 'capybara', :group => :test
|
112
|
-
end
|
113
|
-
add_gem 'turnip', '>= 1.1.0', :group => :test if prefer :integration, 'turnip'
|
57
|
+
if prefer :tests, 'rspec'
|
58
|
+
add_gem 'rails_apps_testing', :group => :development
|
59
|
+
add_gem 'rspec-rails', :group => [:development, :test]
|
60
|
+
add_gem 'factory_girl_rails', :group => [:development, :test]
|
61
|
+
add_gem 'faker', :group => :test
|
62
|
+
add_gem 'capybara', :group => :test
|
63
|
+
add_gem 'database_cleaner', :group => :test
|
64
|
+
add_gem 'launchy', :group => :test
|
65
|
+
add_gem 'selenium-webdriver', :group => :test
|
114
66
|
if prefer :continuous_testing, 'guard'
|
115
67
|
add_gem 'guard-bundler', :group => :development
|
116
|
-
add_gem 'guard-cucumber', :group => :development if prefer :integration, 'cucumber'
|
117
68
|
add_gem 'guard-rails', :group => :development
|
118
|
-
add_gem 'guard-rspec', :group => :development
|
69
|
+
add_gem 'guard-rspec', :group => :development
|
119
70
|
add_gem 'rb-inotify', :group => :development, :require => false
|
120
71
|
add_gem 'rb-fsevent', :group => :development, :require => false
|
121
72
|
add_gem 'rb-fchange', :group => :development, :require => false
|
122
73
|
end
|
123
|
-
add_gem 'factory_girl_rails', :group => [:development, :test] if prefer :fixtures, 'factory_girl'
|
124
|
-
add_gem 'fabrication', :group => [:development, :test] if prefer :fixtures, 'fabrication'
|
125
|
-
add_gem 'machinist', :group => :test if prefer :fixtures, 'machinist'
|
126
74
|
end
|
127
75
|
|
128
76
|
## Front-end Framework
|
@@ -133,17 +81,20 @@ case prefs[:frontend]
|
|
133
81
|
when 'bootstrap3'
|
134
82
|
add_gem 'bootstrap-sass'
|
135
83
|
when 'foundation4'
|
136
|
-
|
137
|
-
|
138
|
-
add_gem 'compass-rails', '~> 1.1.2'
|
139
|
-
else
|
140
|
-
add_gem 'zurb-foundation', '~> 4.3.2', :group => assets_group
|
141
|
-
add_gem 'compass-rails', '~> 1.0.3', :group => assets_group
|
142
|
-
end
|
84
|
+
add_gem 'zurb-foundation', '~> 4.3.2'
|
85
|
+
add_gem 'compass-rails', '~> 1.1.2'
|
143
86
|
when 'foundation5'
|
144
87
|
add_gem 'foundation-rails'
|
145
88
|
end
|
146
89
|
|
90
|
+
## Pages
|
91
|
+
case prefs[:pages]
|
92
|
+
when 'about'
|
93
|
+
add_gem 'high_voltage'
|
94
|
+
when 'about+users'
|
95
|
+
add_gem 'high_voltage'
|
96
|
+
end
|
97
|
+
|
147
98
|
## Email
|
148
99
|
add_gem 'sendgrid' if prefer :email, 'sendgrid'
|
149
100
|
|
@@ -161,34 +112,11 @@ add_gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google_oauth2'
|
|
161
112
|
add_gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
|
162
113
|
|
163
114
|
## Authorization
|
164
|
-
if prefer :authorization, 'cancan'
|
165
|
-
add_gem 'cancan'
|
166
|
-
add_gem 'rolify'
|
167
|
-
end
|
168
115
|
add_gem 'pundit' if prefer :authorization, 'pundit'
|
169
116
|
|
170
117
|
## Form Builder
|
171
118
|
add_gem 'simple_form' if prefer :form_builder, 'simple_form'
|
172
119
|
|
173
|
-
## Membership App
|
174
|
-
if prefer :railsapps, 'rails-stripe-membership-saas'
|
175
|
-
add_gem 'stripe'
|
176
|
-
add_gem 'stripe_event'
|
177
|
-
end
|
178
|
-
if prefer :railsapps, 'rails-recurly-subscription-saas'
|
179
|
-
add_gem 'recurly'
|
180
|
-
add_gem 'nokogiri'
|
181
|
-
add_gem 'countries'
|
182
|
-
add_gem 'httpi'
|
183
|
-
add_gem 'httpclient'
|
184
|
-
end
|
185
|
-
|
186
|
-
## Signup App
|
187
|
-
if prefer :railsapps, 'rails-prelaunch-signup'
|
188
|
-
add_gem 'gibbon'
|
189
|
-
add_gem 'capybara-webkit', :group => :test
|
190
|
-
end
|
191
|
-
|
192
120
|
## Gems from a defaults file or added interactively
|
193
121
|
gems.each do |g|
|
194
122
|
gem(*g)
|
@@ -199,12 +127,12 @@ git :add => '-A' if prefer :git, true
|
|
199
127
|
git :commit => '-qm "rails_apps_composer: Gemfile"' if prefer :git, true
|
200
128
|
|
201
129
|
### CREATE DATABASE ###
|
202
|
-
|
130
|
+
stage_two do
|
131
|
+
say_wizard "recipe stage two"
|
132
|
+
say_wizard "configuring database"
|
203
133
|
unless prefer :database, 'default'
|
204
134
|
copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql'
|
205
135
|
copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql'
|
206
|
-
generate 'mongoid:config' if prefer :orm, 'mongoid'
|
207
|
-
remove_file 'config/database.yml' if prefer :orm, 'mongoid'
|
208
136
|
if prefer :database, 'postgresql'
|
209
137
|
begin
|
210
138
|
pg_username = prefs[:pg_username] || ask_wizard("Username for PostgreSQL?(leave blank to use the app name)")
|
@@ -252,16 +180,17 @@ after_bundler do
|
|
252
180
|
raise "aborted at user's request"
|
253
181
|
end
|
254
182
|
end
|
255
|
-
run 'bundle exec rake db:create:all'
|
256
|
-
run 'bundle exec rake db:create' if prefer :orm, 'mongoid'
|
183
|
+
run 'bundle exec rake db:create:all'
|
257
184
|
## Git
|
258
185
|
git :add => '-A' if prefer :git, true
|
259
186
|
git :commit => '-qm "rails_apps_composer: create database"' if prefer :git, true
|
260
187
|
end
|
261
|
-
end
|
188
|
+
end
|
262
189
|
|
263
190
|
### GENERATORS ###
|
264
|
-
|
191
|
+
stage_two do
|
192
|
+
say_wizard "recipe stage two"
|
193
|
+
say_wizard "running generators"
|
265
194
|
## Form Builder
|
266
195
|
if prefer :form_builder, 'simple_form'
|
267
196
|
case prefs[:frontend]
|
@@ -325,7 +254,7 @@ FILE
|
|
325
254
|
## Git
|
326
255
|
git :add => '-A' if prefer :git, true
|
327
256
|
git :commit => '-qm "rails_apps_composer: generators"' if prefer :git, true
|
328
|
-
end
|
257
|
+
end
|
329
258
|
|
330
259
|
__END__
|
331
260
|
|
data/recipes/git.rb
CHANGED
@@ -10,7 +10,8 @@ if prefer :git, true
|
|
10
10
|
git :add => '-A'
|
11
11
|
git :commit => '-qm "rails_apps_composer: initial commit"'
|
12
12
|
else
|
13
|
-
|
13
|
+
stage_three do
|
14
|
+
say_wizard "recipe stage three"
|
14
15
|
say_wizard "removing .gitignore and .gitkeep files"
|
15
16
|
git_files = Dir[File.join('**','.gitkeep')] + Dir[File.join('**','.gitignore')]
|
16
17
|
File.unlink git_files
|
data/recipes/init.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
2
|
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb
|
3
3
|
|
4
|
-
|
5
|
-
say_wizard "recipe
|
6
|
-
if (!prefs[:secrets].nil?)
|
4
|
+
stage_three do
|
5
|
+
say_wizard "recipe stage three"
|
6
|
+
if (!prefs[:secrets].nil?)
|
7
7
|
prefs[:secrets].each do |secret|
|
8
8
|
env_var = " #{secret}: <%= ENV[\"#{secret.upcase}\"] %>"
|
9
9
|
inject_into_file 'config/secrets.yml', "\n" + env_var, :after => "development:"
|
@@ -34,46 +34,33 @@ after_everything do
|
|
34
34
|
secrets_omniauth = " omniauth_provider_key: <%= ENV[\"OMNIAUTH_PROVIDER_KEY\"] %>\n omniauth_provider_secret: <%= ENV[\"OMNIAUTH_PROVIDER_SECRET\"] %>"
|
35
35
|
foreman_omniauth = "OMNIAUTH_PROVIDER_KEY: Your_Provider_Key\nOMNIAUTH_PROVIDER_SECRET: Your_Provider_Secret\n"
|
36
36
|
figaro_omniauth = foreman_omniauth.gsub('=', ': ')
|
37
|
-
secrets_cancan = " roles: <%= ENV[\"ROLES\"] %>" # unnecessary? CanCan will not be used with Rails 4.1?
|
38
|
-
foreman_cancan = "ROLES=[admin, user, VIP]\n\n"
|
39
|
-
figaro_cancan = foreman_cancan.gsub('=', ': ')
|
40
37
|
## EMAIL
|
41
|
-
inject_into_file 'config/secrets.yml', "\n" + " domain_name: example.com", :after => "development:"
|
42
|
-
inject_into_file 'config/secrets.yml', "\n" + " domain_name: <%= ENV[\"DOMAIN_NAME\"] %>", :after => "production:"
|
43
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_email, :after => "development:"
|
38
|
+
inject_into_file 'config/secrets.yml', "\n" + " domain_name: example.com", :after => "development:"
|
39
|
+
inject_into_file 'config/secrets.yml', "\n" + " domain_name: <%= ENV[\"DOMAIN_NAME\"] %>", :after => "production:"
|
40
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_email, :after => "development:"
|
44
41
|
unless prefer :email, 'none'
|
45
42
|
### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why?
|
46
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_email + " ", :after => "production:"
|
43
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_email + " ", :after => "production:"
|
47
44
|
append_file '.env', foreman_email if prefer :local_env_file, 'foreman'
|
48
45
|
append_file 'config/application.yml', figaro_email if prefer :local_env_file, 'figaro'
|
49
46
|
end
|
50
47
|
## DEVISE
|
51
48
|
if prefer :authentication, 'devise'
|
52
|
-
inject_into_file 'config/secrets.yml', "\n" + ' domain_name: example.com' + " ", :after => "test:"
|
53
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_d_devise, :after => "development:"
|
54
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_p_devise, :after => "production:"
|
49
|
+
inject_into_file 'config/secrets.yml', "\n" + ' domain_name: example.com' + " ", :after => "test:"
|
50
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_d_devise, :after => "development:"
|
51
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_p_devise, :after => "production:"
|
55
52
|
append_file '.env', foreman_devise if prefer :local_env_file, 'foreman'
|
56
53
|
append_file 'config/application.yml', figaro_devise if prefer :local_env_file, 'figaro'
|
57
54
|
gsub_file 'config/initializers/devise.rb', /'please-change-me-at-config-initializers-devise@example.com'/, "'no-reply@' + Rails.application.secrets.domain_name"
|
58
55
|
end
|
59
56
|
## OMNIAUTH
|
60
57
|
if prefer :authentication, 'omniauth'
|
61
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth, :after => "development:"
|
58
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth, :after => "development:"
|
62
59
|
### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why?
|
63
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth + " ", :after => "production:"
|
60
|
+
inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth + " ", :after => "production:"
|
64
61
|
append_file '.env', foreman_omniauth if prefer :local_env_file, 'foreman'
|
65
62
|
append_file 'config/application.yml', figaro_omniauth if prefer :local_env_file, 'figaro'
|
66
63
|
end
|
67
|
-
## CANCAN
|
68
|
-
if (prefer :authorization, 'cancan')
|
69
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_cancan, :after => "development:" if rails_4_1?
|
70
|
-
### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why?
|
71
|
-
inject_into_file 'config/secrets.yml', "\n" + secrets_cancan + " ", :after => "production:" if rails_4_1?
|
72
|
-
append_file '.env', foreman_cancan if prefer :local_env_file, 'foreman'
|
73
|
-
append_file 'config/application.yml', figaro_cancan if prefer :local_env_file, 'figaro'
|
74
|
-
end
|
75
|
-
### SUBDOMAINS (FIGARO ONLY) ###
|
76
|
-
copy_from_repo 'config/application.yml', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
|
77
64
|
### EXAMPLE FILE FOR FOREMAN AND FIGARO ###
|
78
65
|
if prefer :local_env_file, 'figaro'
|
79
66
|
copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml'
|
@@ -81,15 +68,14 @@ after_everything do
|
|
81
68
|
copy_file destination_root + '/.env', destination_root + '/.env.example'
|
82
69
|
end
|
83
70
|
### DATABASE SEED ###
|
84
|
-
if
|
71
|
+
if prefer :authentication, 'devise'
|
85
72
|
copy_from_repo 'db/seeds.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise/master/'
|
86
|
-
|
73
|
+
if prefer :authorization, 'pundit'
|
74
|
+
copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
75
|
+
else
|
87
76
|
copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise/master/'
|
88
77
|
end
|
89
78
|
end
|
90
|
-
if prefer :authorization, 'pundit'
|
91
|
-
copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
92
|
-
end
|
93
79
|
if prefer :local_env_file, 'figaro'
|
94
80
|
append_file 'db/seeds.rb' do <<-FILE
|
95
81
|
# Environment variables (ENV['...']) can be set in the file config/application.yml.
|
@@ -102,50 +88,9 @@ FILE
|
|
102
88
|
FILE
|
103
89
|
end
|
104
90
|
end
|
105
|
-
if (prefer :authorization, 'cancan')
|
106
|
-
unless prefer :orm, 'mongoid'
|
107
|
-
append_file 'db/seeds.rb' do <<-FILE
|
108
|
-
puts 'ROLES'
|
109
|
-
YAML.load(ENV['ROLES']).each do |role|
|
110
|
-
Role.find_or_create_by_name({ :name => role }, :without_protection => true)
|
111
|
-
puts 'role: ' << role
|
112
|
-
end
|
113
|
-
FILE
|
114
|
-
end
|
115
|
-
## Fix db seed for Rails 4.0
|
116
|
-
gsub_file 'db/seeds.rb', /{ :name => role }, :without_protection => true/, 'role' if rails_4?
|
117
|
-
else
|
118
|
-
append_file 'db/seeds.rb' do <<-FILE
|
119
|
-
puts 'ROLES'
|
120
|
-
YAML.load(ENV['ROLES']).each do |role|
|
121
|
-
Role.mongo_session['roles'].insert({ :name => role })
|
122
|
-
puts 'role: ' << role
|
123
|
-
end
|
124
|
-
FILE
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
## DEVISE-DEFAULT
|
129
|
-
if (prefer :authentication, 'devise') and (not prefer :apps4, 'rails-devise') and (not rails_4_1?)
|
130
|
-
append_file 'db/seeds.rb' do <<-FILE
|
131
|
-
puts 'DEFAULT USERS'
|
132
|
-
user = User.find_or_create_by_email :name => ENV['ADMIN_NAME'].dup, :email => ENV['ADMIN_EMAIL'].dup, :password => ENV['ADMIN_PASSWORD'].dup, :password_confirmation => ENV['ADMIN_PASSWORD'].dup
|
133
|
-
puts 'user: ' << user.name
|
134
|
-
FILE
|
135
|
-
end
|
136
|
-
# Mongoid doesn't have a 'find_or_create_by' method
|
137
|
-
gsub_file 'db/seeds.rb', /find_or_create_by_email/, 'create!' if prefer :orm, 'mongoid'
|
138
|
-
end
|
139
91
|
## DEVISE-CONFIRMABLE
|
140
92
|
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
141
|
-
|
142
|
-
inject_into_file 'app/services/create_admin_service.rb', " user.confirm!\n", :after => "user.password_confirmation = Rails.application.secrets.admin_password\n"
|
143
|
-
else
|
144
|
-
append_file 'db/seeds.rb', "user.confirm!\n"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
if (prefer :authorization, 'cancan') && !(prefer :authentication, 'omniauth')
|
148
|
-
append_file 'db/seeds.rb', 'user.add_role :admin'
|
93
|
+
inject_into_file 'app/services/create_admin_service.rb', " user.confirm!\n", :after => "user.password_confirmation = Rails.application.secrets.admin_password\n"
|
149
94
|
end
|
150
95
|
## DEVISE-INVITABLE
|
151
96
|
if prefer :devise_modules, 'invitable'
|
@@ -157,34 +102,20 @@ FILE
|
|
157
102
|
generate 'devise_invitable user'
|
158
103
|
end
|
159
104
|
### APPLY DATABASE SEED ###
|
160
|
-
unless prefer :
|
161
|
-
|
162
|
-
|
163
|
-
say_wizard "applying migrations and seeding the database"
|
164
|
-
if prefer :local_env_file, 'foreman'
|
165
|
-
run 'foreman run bundle exec rake db:migrate'
|
166
|
-
else
|
167
|
-
run 'bundle exec rake db:migrate'
|
168
|
-
end
|
169
|
-
end
|
170
|
-
else
|
171
|
-
## MONGOID
|
172
|
-
say_wizard "dropping database, creating indexes and seeding the database"
|
105
|
+
unless prefer :database, 'default'
|
106
|
+
## ACTIVE_RECORD
|
107
|
+
say_wizard "applying migrations and seeding the database"
|
173
108
|
if prefer :local_env_file, 'foreman'
|
174
|
-
run 'foreman run bundle exec rake db:
|
175
|
-
run 'foreman run bundle exec rake db:mongoid:create_indexes'
|
109
|
+
run 'foreman run bundle exec rake db:migrate'
|
176
110
|
else
|
177
|
-
run 'bundle exec rake db:
|
178
|
-
run 'bundle exec rake db:mongoid:create_indexes'
|
111
|
+
run 'bundle exec rake db:migrate'
|
179
112
|
end
|
180
113
|
end
|
181
114
|
unless prefs[:skip_seeds]
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
run 'bundle exec rake db:seed'
|
187
|
-
end
|
115
|
+
if prefer :local_env_file, 'foreman'
|
116
|
+
run 'foreman run bundle exec rake db:seed'
|
117
|
+
else
|
118
|
+
run 'bundle exec rake db:seed'
|
188
119
|
end
|
189
120
|
end
|
190
121
|
### GIT ###
|
@@ -202,12 +133,10 @@ FILE
|
|
202
133
|
end
|
203
134
|
# create navigation links using the rails_layout gem
|
204
135
|
generate 'layout:navigation -f'
|
205
|
-
# replace with specialized navigation partials
|
206
|
-
copy_from_repo 'app/views/layouts/_navigation-subdomains_app.html.erb', :prefs => 'subdomains_app'
|
207
136
|
### GIT ###
|
208
137
|
git :add => '-A' if prefer :git, true
|
209
138
|
git :commit => '-qm "rails_apps_composer: navigation links"' if prefer :git, true
|
210
|
-
end
|
139
|
+
end
|
211
140
|
|
212
141
|
__END__
|
213
142
|
|
@@ -215,6 +144,6 @@ name: init
|
|
215
144
|
description: "Set up and initialize database."
|
216
145
|
author: RailsApps
|
217
146
|
|
218
|
-
requires: [setup, gems,
|
219
|
-
run_after: [setup, gems,
|
147
|
+
requires: [setup, gems, devise, omniauth]
|
148
|
+
run_after: [setup, gems, pages]
|
220
149
|
category: initialize
|
data/recipes/learn_rails.rb
CHANGED
@@ -22,9 +22,9 @@ if prefer :apps4, 'learn-rails'
|
|
22
22
|
prefs[:pry] = false
|
23
23
|
prefs[:quiet_assets] = true
|
24
24
|
prefs[:secrets] = ['owner_email', 'mailchimp_list_id', 'mailchimp_api_key']
|
25
|
-
prefs[:starter_app] = false
|
26
25
|
prefs[:templates] = 'erb'
|
27
26
|
prefs[:tests] = false
|
27
|
+
prefs[:pages] = 'none'
|
28
28
|
|
29
29
|
# gems
|
30
30
|
add_gem 'activerecord-tableless'
|
@@ -37,8 +37,8 @@ if prefer :apps4, 'learn-rails'
|
|
37
37
|
add_gem 'thin', :group => :production
|
38
38
|
add_gem 'rails_12factor', :group => :production
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
stage_three do
|
41
|
+
say_wizard "recipe stage three"
|
42
42
|
repo = 'https://raw.github.com/RailsApps/learn-rails/master/'
|
43
43
|
|
44
44
|
# >-------------------------------[ Models ]--------------------------------<
|
data/recipes/omniauth.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/omniauth.rb
|
3
|
+
|
4
|
+
stage_two do
|
5
|
+
say_wizard "recipe stage two"
|
6
|
+
if prefer :authentication, 'omniauth'
|
7
|
+
repo = 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
8
|
+
copy_from_repo 'config/initializers/omniauth.rb', :repo => repo
|
9
|
+
gsub_file 'config/initializers/omniauth.rb', /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
|
10
|
+
generate 'model User name:string email:string provider:string uid:string'
|
11
|
+
run 'bundle exec rake db:migrate'
|
12
|
+
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
13
|
+
copy_from_repo 'app/controllers/application_controller.rb', :repo => repo
|
14
|
+
filename = 'app/controllers/sessions_controller.rb'
|
15
|
+
copy_from_repo filename, :repo => repo
|
16
|
+
gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
|
17
|
+
copy_from_repo 'config/routes.rb', :repo => repo
|
18
|
+
end
|
19
|
+
### GIT ###
|
20
|
+
git :add => '-A' if prefer :git, true
|
21
|
+
git :commit => '-qm "rails_apps_composer: omniauth"' if prefer :git, true
|
22
|
+
end
|
23
|
+
|
24
|
+
__END__
|
25
|
+
|
26
|
+
name: omniauth
|
27
|
+
description: "Add OmniAuth for authentication"
|
28
|
+
author: RailsApps
|
29
|
+
|
30
|
+
requires: [setup, gems]
|
31
|
+
run_after: [setup, gems]
|
32
|
+
category: mvc
|