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/pages.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/pages.rb
|
3
|
+
|
4
|
+
stage_three do
|
5
|
+
say_wizard "recipe stage three"
|
6
|
+
case prefs[:pages]
|
7
|
+
when 'home'
|
8
|
+
generate 'pages:home -f'
|
9
|
+
when 'about'
|
10
|
+
generate 'pages:about -f'
|
11
|
+
when 'users'
|
12
|
+
generate 'pages:users -f'
|
13
|
+
generate 'pages:authorized -f' if prefer :authorization, 'pundit'
|
14
|
+
when 'about+users'
|
15
|
+
generate 'pages:about -f'
|
16
|
+
generate 'pages:users -f'
|
17
|
+
generate 'pages:authorized -f' if prefer :authorization, 'pundit'
|
18
|
+
end
|
19
|
+
generate 'layout:navigation -f'
|
20
|
+
### GIT ###
|
21
|
+
git :add => '-A' if prefer :git, true
|
22
|
+
git :commit => '-qm "rails_apps_composer: add pages"' if prefer :git, true
|
23
|
+
end
|
24
|
+
|
25
|
+
__END__
|
26
|
+
|
27
|
+
name: pages
|
28
|
+
description: "Add pages"
|
29
|
+
author: RailsApps
|
30
|
+
|
31
|
+
requires: [setup, gems, frontend]
|
32
|
+
run_after: [setup, gems, frontend]
|
33
|
+
category: mvc
|
data/recipes/rails_bootstrap.rb
CHANGED
@@ -15,13 +15,7 @@ if prefer :apps4, 'rails-bootstrap'
|
|
15
15
|
prefs[:local_env_file] = false
|
16
16
|
prefs[:pry] = false
|
17
17
|
prefs[:quiet_assets] = true
|
18
|
-
prefs[:
|
19
|
-
add_gem 'high_voltage'
|
20
|
-
after_everything do
|
21
|
-
generate 'pages:home -f'
|
22
|
-
generate 'pages:about -f'
|
23
|
-
generate 'layout:navigation -f'
|
24
|
-
end
|
18
|
+
prefs[:pages] = 'about'
|
25
19
|
end
|
26
20
|
|
27
21
|
__END__
|
data/recipes/rails_devise.rb
CHANGED
@@ -10,10 +10,7 @@ if prefer :apps4, 'rails-devise'
|
|
10
10
|
prefs[:local_env_file] = false
|
11
11
|
prefs[:pry] = false
|
12
12
|
prefs[:quiet_assets] = true
|
13
|
-
prefs[:
|
14
|
-
after_everything do
|
15
|
-
generate 'pages:users -f'
|
16
|
-
end
|
13
|
+
prefs[:pages] = 'users'
|
17
14
|
end
|
18
15
|
|
19
16
|
__END__
|
@@ -10,10 +10,7 @@ if prefer :apps4, 'rails-devise-pundit'
|
|
10
10
|
prefs[:local_env_file] = false
|
11
11
|
prefs[:pry] = false
|
12
12
|
prefs[:quiet_assets] = true
|
13
|
-
prefs[:
|
14
|
-
after_everything do
|
15
|
-
generate 'pages:authorized -f'
|
16
|
-
end
|
13
|
+
prefs[:pages] = 'users'
|
17
14
|
end
|
18
15
|
|
19
16
|
__END__
|
data/recipes/rails_foundation.rb
CHANGED
@@ -15,13 +15,7 @@ if prefer :apps4, 'rails-foundation'
|
|
15
15
|
prefs[:local_env_file] = false
|
16
16
|
prefs[:pry] = false
|
17
17
|
prefs[:quiet_assets] = true
|
18
|
-
prefs[:
|
19
|
-
add_gem 'high_voltage'
|
20
|
-
after_everything do
|
21
|
-
generate 'pages:home -f'
|
22
|
-
generate 'pages:about -f'
|
23
|
-
generate 'layout:navigation -f'
|
24
|
-
end
|
18
|
+
prefs[:pages] = 'about'
|
25
19
|
end
|
26
20
|
|
27
21
|
__END__
|
data/recipes/rails_omniauth.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_omniauth.rb
|
3
3
|
|
4
4
|
if prefer :apps4, 'rails-omniauth'
|
5
|
-
|
6
5
|
prefs[:authentication] = 'omniauth'
|
7
6
|
prefs[:authorization] = 'none'
|
8
7
|
prefs[:better_errors] = true
|
@@ -12,24 +11,7 @@ if prefer :apps4, 'rails-omniauth'
|
|
12
11
|
prefs[:local_env_file] = false
|
13
12
|
prefs[:pry] = false
|
14
13
|
prefs[:quiet_assets] = true
|
15
|
-
prefs[:
|
16
|
-
add_gem 'high_voltage'
|
17
|
-
|
18
|
-
after_everything do
|
19
|
-
generate 'pages:users -f'
|
20
|
-
generate 'pages:about -f'
|
21
|
-
generate 'layout:navigation -f'
|
22
|
-
repo = 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
23
|
-
|
24
|
-
# >-------------------------------[ Models ]--------------------------------<
|
25
|
-
|
26
|
-
copy_from_repo 'app/models/user.rb', :repo => repo
|
27
|
-
|
28
|
-
# >-------------------------------[ Routes ]--------------------------------<
|
29
|
-
|
30
|
-
copy_from_repo 'config/routes.rb', :repo => repo
|
31
|
-
|
32
|
-
end
|
14
|
+
prefs[:pages] = 'about+users'
|
33
15
|
end
|
34
16
|
|
35
17
|
__END__
|
@@ -12,10 +12,9 @@ if prefer :apps4, 'rails-signup-download'
|
|
12
12
|
prefs[:local_env_file] = false
|
13
13
|
prefs[:pry] = false
|
14
14
|
prefs[:quiet_assets] = true
|
15
|
-
prefs[:
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
prefs[:pages] = 'users'
|
16
|
+
stage_three do
|
17
|
+
say_wizard "recipe stage three"
|
19
18
|
repo = 'https://raw.github.com/RailsApps/rails-signup-download/master/'
|
20
19
|
|
21
20
|
# >-------------------------------[ Controllers ]--------------------------------<
|
data/recipes/railsapps.rb
CHANGED
@@ -11,23 +11,18 @@ end
|
|
11
11
|
|
12
12
|
case Rails::VERSION::MAJOR.to_s
|
13
13
|
when "3"
|
14
|
-
|
15
|
-
[["I want to build my own application", "none"],
|
16
|
-
["membership/subscription/saas", "saas"],
|
17
|
-
["rails-prelaunch-signup", "rails-prelaunch-signup"],
|
18
|
-
["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"],
|
19
|
-
["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"],
|
20
|
-
["rails3-mongoid-devise", "rails3-mongoid-devise"],
|
21
|
-
["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
|
22
|
-
["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps
|
14
|
+
say_wizard "Please upgrade to Rails 4.1 or newer."
|
23
15
|
when "4"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
case Rails::VERSION::MINOR.to_s
|
17
|
+
when "0"
|
18
|
+
say_wizard "Please upgrade to Rails 4.1 or newer."
|
19
|
+
else
|
20
|
+
prefs[:apps4] = multiple_choice "Build a starter application?",
|
21
|
+
[["Build a RailsApps example application", "railsapps"],
|
22
|
+
["Contributed applications (none available)", "contributed_app"],
|
23
|
+
["Custom application (experimental)", "none"]] unless prefs.has_key? :apps4
|
24
|
+
case prefs[:apps4]
|
25
|
+
when 'railsapps'
|
31
26
|
prefs[:apps4] = prefs[:rails_4_1_starter_app] || (multiple_choice "Starter apps for Rails 4.1. More to come.",
|
32
27
|
[["learn-rails", "learn-rails"],
|
33
28
|
["rails-bootstrap", "rails-bootstrap"],
|
@@ -36,204 +31,11 @@ when "4"
|
|
36
31
|
["rails-devise", "rails-devise"],
|
37
32
|
["rails-devise-pundit", "rails-devise-pundit"],
|
38
33
|
["rails-signup-download", "rails-signup-download"]])
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
when 'contributed_app'
|
43
|
-
prefs[:apps4] = multiple_choice "No contributed applications are available.",
|
44
|
-
[["create custom application", "railsapps"]]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
case prefs[:railsapps]
|
49
|
-
when 'saas'
|
50
|
-
prefs[:railsapps] = prefs[:billing] || (multiple_choice "Billing with Stripe or Recurly?",
|
51
|
-
[["Stripe", "rails-stripe-membership-saas"],
|
52
|
-
["Recurly", "rails-recurly-subscription-saas"]])
|
53
|
-
end
|
54
|
-
|
55
|
-
case prefs[:railsapps]
|
56
|
-
when 'rails-stripe-membership-saas'
|
57
|
-
prefs[:git] = true
|
58
|
-
prefs[:database] = 'sqlite'
|
59
|
-
prefs[:unit_test] = 'rspec'
|
60
|
-
prefs[:integration] = 'cucumber'
|
61
|
-
prefs[:fixtures] = 'factory_girl'
|
62
|
-
prefs[:frontend] = 'bootstrap2'
|
63
|
-
prefs[:email] = 'gmail'
|
64
|
-
prefs[:authentication] = 'devise'
|
65
|
-
prefs[:devise_modules] = 'default'
|
66
|
-
prefs[:authorization] = 'cancan'
|
67
|
-
prefs[:starter_app] = 'admin_app'
|
68
|
-
prefs[:form_builder] = 'simple_form'
|
69
|
-
prefs[:quiet_assets] = true
|
70
|
-
prefs[:local_env_file] = 'figaro'
|
71
|
-
prefs[:better_errors] = true
|
72
|
-
prefs[:pry] = false
|
73
|
-
prefs[:deployment] = 'none'
|
74
|
-
when 'rails-recurly-subscription-saas'
|
75
|
-
prefs[:git] = true
|
76
|
-
prefs[:database] = 'sqlite'
|
77
|
-
prefs[:unit_test] = 'rspec'
|
78
|
-
prefs[:integration] = 'cucumber'
|
79
|
-
prefs[:fixtures] = 'factory_girl'
|
80
|
-
prefs[:frontend] = 'bootstrap2'
|
81
|
-
prefs[:email] = 'gmail'
|
82
|
-
prefs[:authentication] = 'devise'
|
83
|
-
prefs[:devise_modules] = 'default'
|
84
|
-
prefs[:authorization] = 'cancan'
|
85
|
-
prefs[:starter_app] = 'admin_app'
|
86
|
-
prefs[:form_builder] = 'simple_form'
|
87
|
-
prefs[:quiet_assets] = true
|
88
|
-
prefs[:local_env_file] = 'figaro'
|
89
|
-
prefs[:better_errors] = true
|
90
|
-
prefs[:pry] = false
|
91
|
-
prefs[:deployment] = 'none'
|
92
|
-
when 'rails-prelaunch-signup'
|
93
|
-
prefs[:git] = true
|
94
|
-
prefs[:database] = 'sqlite'
|
95
|
-
prefs[:unit_test] = 'rspec'
|
96
|
-
prefs[:integration] = 'cucumber'
|
97
|
-
prefs[:fixtures] = 'factory_girl'
|
98
|
-
prefs[:frontend] = 'bootstrap2'
|
99
|
-
prefs[:email] = 'mandrill'
|
100
|
-
prefs[:authentication] = 'devise'
|
101
|
-
prefs[:devise_modules] = 'confirmable'
|
102
|
-
prefs[:authorization] = 'cancan'
|
103
|
-
prefs[:starter_app] = 'admin_app'
|
104
|
-
prefs[:form_builder] = 'simple_form'
|
105
|
-
prefs[:quiet_assets] = true
|
106
|
-
prefs[:local_env_file] = 'figaro'
|
107
|
-
prefs[:better_errors] = true
|
108
|
-
prefs[:pry] = false
|
109
|
-
prefs[:deployment] = 'none'
|
110
|
-
if prefer :git, true
|
111
|
-
prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?",
|
112
|
-
[["wip (work-in-progress)", "wip"],
|
113
|
-
["master", "master"],
|
114
|
-
["prelaunch", "prelaunch"],
|
115
|
-
["staging", "staging"]] unless prefs.has_key? :prelaunch_branch
|
116
|
-
|
117
|
-
prefs[:main_branch] = unless 'master' == prefs[:prelaunch_branch]
|
118
|
-
'master'
|
119
|
-
else
|
120
|
-
multiple_choice "Git branch for the main app?",
|
121
|
-
[["None", "none"],
|
122
|
-
["wip (work-in-progress)", "wip"],
|
123
|
-
["edge", "edge"]]
|
124
|
-
end unless prefs.has_key? :main_branch
|
34
|
+
when 'contributed_app'
|
35
|
+
prefs[:apps4] = multiple_choice "No contributed applications are available.",
|
36
|
+
[["create custom application", "railsapps"]]
|
125
37
|
end
|
126
|
-
|
127
|
-
prefs[:git] = true
|
128
|
-
prefs[:database] = 'sqlite'
|
129
|
-
prefs[:unit_test] = 'rspec'
|
130
|
-
prefs[:integration] = 'cucumber'
|
131
|
-
prefs[:fixtures] = 'factory_girl'
|
132
|
-
prefs[:frontend] = 'bootstrap2'
|
133
|
-
prefs[:email] = 'gmail'
|
134
|
-
prefs[:authentication] = 'devise'
|
135
|
-
prefs[:devise_modules] = 'default'
|
136
|
-
prefs[:authorization] = 'cancan'
|
137
|
-
prefs[:starter_app] = 'admin_app'
|
138
|
-
prefs[:form_builder] = 'simple_form'
|
139
|
-
prefs[:quiet_assets] = true
|
140
|
-
prefs[:local_env_file] = 'figaro'
|
141
|
-
prefs[:better_errors] = true
|
142
|
-
prefs[:pry] = false
|
143
|
-
prefs[:deployment] = 'none'
|
144
|
-
when 'rails3-devise-rspec-cucumber'
|
145
|
-
prefs[:git] = true
|
146
|
-
prefs[:database] = 'sqlite'
|
147
|
-
prefs[:unit_test] = 'rspec'
|
148
|
-
prefs[:integration] = 'cucumber'
|
149
|
-
prefs[:fixtures] = 'factory_girl'
|
150
|
-
prefs[:frontend] = 'none'
|
151
|
-
prefs[:email] = 'gmail'
|
152
|
-
prefs[:authentication] = 'devise'
|
153
|
-
prefs[:devise_modules] = 'default'
|
154
|
-
prefs[:authorization] = 'none'
|
155
|
-
prefs[:starter_app] = 'users_app'
|
156
|
-
prefs[:form_builder] = 'none'
|
157
|
-
prefs[:quiet_assets] = true
|
158
|
-
prefs[:local_env_file] = 'figaro'
|
159
|
-
prefs[:better_errors] = true
|
160
|
-
prefs[:pry] = false
|
161
|
-
prefs[:deployment] = 'none'
|
162
|
-
when 'rails3-devise-rspec-cucumber-fabrication'
|
163
|
-
prefs[:git] = true
|
164
|
-
prefs[:database] = 'sqlite'
|
165
|
-
prefs[:unit_test] = 'rspec'
|
166
|
-
prefs[:integration] = 'cucumber'
|
167
|
-
prefs[:fixtures] = 'fabrication'
|
168
|
-
prefs[:frontend] = 'none'
|
169
|
-
prefs[:email] = 'gmail'
|
170
|
-
prefs[:authentication] = 'devise'
|
171
|
-
prefs[:devise_modules] = 'default'
|
172
|
-
prefs[:authorization] = 'none'
|
173
|
-
prefs[:starter_app] = 'users_app'
|
174
|
-
prefs[:form_builder] = 'none'
|
175
|
-
prefs[:quiet_assets] = true
|
176
|
-
prefs[:local_env_file] = 'figaro'
|
177
|
-
prefs[:better_errors] = true
|
178
|
-
prefs[:pry] = false
|
179
|
-
prefs[:deployment] = 'none'
|
180
|
-
when 'rails3-mongoid-devise'
|
181
|
-
prefs[:git] = true
|
182
|
-
prefs[:database] = 'mongodb'
|
183
|
-
prefs[:orm] = 'mongoid'
|
184
|
-
prefs[:unit_test] = 'rspec'
|
185
|
-
prefs[:integration] = 'cucumber'
|
186
|
-
prefs[:fixtures] = 'factory_girl'
|
187
|
-
prefs[:frontend] = 'none'
|
188
|
-
prefs[:email] = 'gmail'
|
189
|
-
prefs[:authentication] = 'devise'
|
190
|
-
prefs[:devise_modules] = 'default'
|
191
|
-
prefs[:authorization] = 'none'
|
192
|
-
prefs[:starter_app] = 'users_app'
|
193
|
-
prefs[:form_builder] = 'none'
|
194
|
-
prefs[:quiet_assets] = true
|
195
|
-
prefs[:local_env_file] = 'figaro'
|
196
|
-
prefs[:better_errors] = true
|
197
|
-
prefs[:pry] = false
|
198
|
-
prefs[:deployment] = 'none'
|
199
|
-
when 'rails3-mongoid-omniauth'
|
200
|
-
prefs[:git] = true
|
201
|
-
prefs[:database] = 'mongodb'
|
202
|
-
prefs[:orm] = 'mongoid'
|
203
|
-
prefs[:unit_test] = 'rspec'
|
204
|
-
prefs[:integration] = 'cucumber'
|
205
|
-
prefs[:fixtures] = 'factory_girl'
|
206
|
-
prefs[:frontend] = 'none'
|
207
|
-
prefs[:email] = 'none'
|
208
|
-
prefs[:authentication] = 'omniauth'
|
209
|
-
prefs[:omniauth_provider] = 'twitter'
|
210
|
-
prefs[:authorization] = 'none'
|
211
|
-
prefs[:starter_app] = 'users_app'
|
212
|
-
prefs[:form_builder] = 'none'
|
213
|
-
prefs[:quiet_assets] = true
|
214
|
-
prefs[:local_env_file] = 'figaro'
|
215
|
-
prefs[:better_errors] = true
|
216
|
-
prefs[:pry] = false
|
217
|
-
prefs[:deployment] = 'none'
|
218
|
-
when 'rails3-subdomains'
|
219
|
-
prefs[:git] = true
|
220
|
-
prefs[:database] = 'mongodb'
|
221
|
-
prefs[:orm] = 'mongoid'
|
222
|
-
prefs[:unit_test] = 'rspec'
|
223
|
-
prefs[:integration] = 'cucumber'
|
224
|
-
prefs[:fixtures] = 'factory_girl'
|
225
|
-
prefs[:frontend] = 'none'
|
226
|
-
prefs[:email] = 'gmail'
|
227
|
-
prefs[:authentication] = 'devise'
|
228
|
-
prefs[:devise_modules] = 'default'
|
229
|
-
prefs[:authorization] = 'none'
|
230
|
-
prefs[:starter_app] = 'subdomains_app'
|
231
|
-
prefs[:form_builder] = 'none'
|
232
|
-
prefs[:quiet_assets] = true
|
233
|
-
prefs[:local_env_file] = 'figaro'
|
234
|
-
prefs[:better_errors] = true
|
235
|
-
prefs[:pry] = false
|
236
|
-
prefs[:deployment] = 'none'
|
38
|
+
end
|
237
39
|
end
|
238
40
|
|
239
41
|
__END__
|
data/recipes/readme.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
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/readme.rb
|
3
3
|
|
4
|
-
|
5
|
-
say_wizard "recipe
|
4
|
+
stage_three do
|
5
|
+
say_wizard "recipe stage three"
|
6
6
|
|
7
7
|
# remove default READMEs
|
8
8
|
%w{
|
@@ -43,10 +43,7 @@ after_everything do
|
|
43
43
|
gsub_file "README.md", /ERB/, "Slim" if prefer :templates, 'slim'
|
44
44
|
|
45
45
|
# Testing Framework
|
46
|
-
gsub_file "README.md", /Test::Unit/, "RSpec" if prefer :
|
47
|
-
gsub_file "README.md", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber'
|
48
|
-
gsub_file "README.md", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl'
|
49
|
-
gsub_file "README.md", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist'
|
46
|
+
gsub_file "README.md", /Test::Unit/, "RSpec" if prefer :tests, 'rspec'
|
50
47
|
|
51
48
|
# Front-end Framework
|
52
49
|
gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Bootstrap 2.3 (Sass)" if prefer :frontend, 'bootstrap2'
|
@@ -74,7 +71,7 @@ after_everything do
|
|
74
71
|
# Authentication and Authorization
|
75
72
|
gsub_file "README.md", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise'
|
76
73
|
gsub_file "README.md", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth'
|
77
|
-
gsub_file "README.md", /Authorization: None/, "Authorization:
|
74
|
+
gsub_file "README.md", /Authorization: None/, "Authorization: Pundit" if prefer :authorization, 'pundit'
|
78
75
|
|
79
76
|
# Admin
|
80
77
|
gsub_file "README.md", /Admin: None/, "Admin: ActiveAdmin" if prefer :admin, 'activeadmin'
|
@@ -83,7 +80,7 @@ after_everything do
|
|
83
80
|
git :add => '-A' if prefer :git, true
|
84
81
|
git :commit => '-qm "rails_apps_composer: add README files"' if prefer :git, true
|
85
82
|
|
86
|
-
end
|
83
|
+
end
|
87
84
|
|
88
85
|
__END__
|
89
86
|
|
data/recipes/roles.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/roles.rb
|
3
|
+
|
4
|
+
stage_two do
|
5
|
+
say_wizard "recipe stage two"
|
6
|
+
if prefer :authorization, 'pundit'
|
7
|
+
generate 'migration AddRoleToUsers role:integer'
|
8
|
+
role_boilerplate = " enum role: [:user, :vip, :admin]\n after_initialize :set_default_role, :if => :new_record?\n\n"
|
9
|
+
role_boilerplate << " def set_default_role\n self.role ||= :user\n end\n\n" if prefer :authentication, 'devise'
|
10
|
+
if prefer :authentication, 'omniauth'
|
11
|
+
role_boilerplate << <<-RUBY
|
12
|
+
def set_default_role
|
13
|
+
if User.count == 0
|
14
|
+
self.role ||= :admin
|
15
|
+
else
|
16
|
+
self.role ||= :user
|
17
|
+
end
|
18
|
+
end
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
inject_into_class 'app/models/user.rb', 'User', role_boilerplate
|
22
|
+
end
|
23
|
+
### GIT ###
|
24
|
+
git :add => '-A' if prefer :git, true
|
25
|
+
git :commit => '-qm "rails_apps_composer: add roles to a User model"' if prefer :git, true
|
26
|
+
end
|
27
|
+
|
28
|
+
__END__
|
29
|
+
|
30
|
+
name: roles
|
31
|
+
description: "Add roles to a User model"
|
32
|
+
author: RailsApps
|
33
|
+
|
34
|
+
requires: [setup, gems, devise, omniauth]
|
35
|
+
run_after: [setup, gems, devise, omniauth]
|
36
|
+
category: mvc
|