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/setup.rb
CHANGED
@@ -34,51 +34,21 @@ if prefs[:prod_webserver] == 'same'
|
|
34
34
|
end
|
35
35
|
|
36
36
|
## Database Adapter
|
37
|
-
|
38
|
-
|
39
|
-
["MySQL", "mysql"]] unless prefs.has_key? :database
|
40
|
-
else
|
41
|
-
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
|
42
|
-
["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database
|
43
|
-
end
|
44
|
-
case prefs[:database]
|
45
|
-
when 'mongodb'
|
46
|
-
unless sqlite_detected
|
47
|
-
prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm
|
48
|
-
else
|
49
|
-
say_wizard "WARNING! SQLite gem detected in the Gemfile"
|
50
|
-
say_wizard "If you wish to use MongoDB you must skip Active Record."
|
51
|
-
say_wizard "If using rails_apps_composer, choose 'skip Active Record'."
|
52
|
-
say_wizard "If using Rails Composer or an application template, use the '-O' flag as in 'rails new foo -O'."
|
53
|
-
prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]]
|
54
|
-
if prefer :fail, 'abort'
|
55
|
-
raise StandardError.new "SQLite detected in the Gemfile. Use '-O' or '--skip-activerecord' as in 'rails new foo -O' if you don't want ActiveRecord and SQLite"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
37
|
+
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
|
38
|
+
["MySQL", "mysql"]] unless prefs.has_key? :database
|
59
39
|
|
60
40
|
## Template Engine
|
61
41
|
prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates
|
62
42
|
|
63
43
|
## Testing Framework
|
64
|
-
if
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
else
|
75
|
-
if recipes.include? 'testing'
|
76
|
-
prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"], ["MiniTest", "minitest"]] unless prefs.has_key? :unit_test
|
77
|
-
prefs[:integration] = multiple_choice "Integration testing?", [["None", "none"], ["RSpec with Capybara", "rspec-capybara"],
|
78
|
-
["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"], ["MiniTest with Capybara", "minitest-capybara"]] unless prefs.has_key? :integration
|
79
|
-
prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing
|
80
|
-
prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"], ["Fabrication","fabrication"]] unless prefs.has_key? :fixtures
|
81
|
-
end
|
44
|
+
if recipes.include? 'tests'
|
45
|
+
prefs[:tests] = multiple_choice "Test framework?", [["None", "none"],
|
46
|
+
["RSpec with Capybara", "rspec"]] unless prefs.has_key? :tests
|
47
|
+
case prefs[:tests]
|
48
|
+
when 'rspec'
|
49
|
+
say_wizard "Adding DatabaseCleaner, FactoryGirl, Faker, Launchy, Selenium"
|
50
|
+
prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing
|
51
|
+
end
|
82
52
|
end
|
83
53
|
|
84
54
|
## Front-end Framework
|
@@ -101,51 +71,28 @@ else
|
|
101
71
|
end
|
102
72
|
|
103
73
|
## Authentication and Authorization
|
104
|
-
if recipes.include? '
|
74
|
+
if (recipes.include? 'devise') || (recipes.include? 'omniauth')
|
105
75
|
prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
|
106
76
|
case prefs[:authentication]
|
107
77
|
when 'devise'
|
108
|
-
|
109
|
-
|
110
|
-
else
|
111
|
-
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"],
|
112
|
-
["Devise with Confirmable module","confirmable"]] unless prefs.has_key? :devise_modules
|
113
|
-
end
|
78
|
+
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"],
|
79
|
+
["Devise with Confirmable module","confirmable"]] unless prefs.has_key? :devise_modules
|
114
80
|
when 'omniauth'
|
115
81
|
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
|
116
82
|
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
|
117
83
|
end
|
118
|
-
unless prefs.has_key? :authorization
|
119
|
-
if rails_4_1?
|
120
|
-
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["Pundit", "pundit"]]
|
121
|
-
else
|
122
|
-
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]]
|
123
|
-
end
|
124
|
-
end
|
84
|
+
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["Pundit", "pundit"]] unless prefs.has_key? :authorization
|
125
85
|
end
|
126
86
|
|
127
87
|
## Form Builder
|
128
88
|
prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder
|
129
89
|
|
130
|
-
##
|
131
|
-
if
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
if prefer :orm, 'mongoid'
|
137
|
-
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
138
|
-
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app
|
139
|
-
else
|
140
|
-
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
141
|
-
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
|
142
|
-
end
|
143
|
-
elsif prefer :authentication, 'omniauth'
|
144
|
-
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
145
|
-
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
|
146
|
-
else
|
147
|
-
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app
|
148
|
-
end
|
90
|
+
## Pages
|
91
|
+
if recipes.include? 'pages'
|
92
|
+
prefs[:pages] = multiple_choice "Add pages?", [["None", "none"],
|
93
|
+
["Home", "home"], ["Home and About", "about"],
|
94
|
+
["Home and Users", "users"],
|
95
|
+
["Home, About, and Users", "about+users"]] unless prefs.has_key? :pages
|
149
96
|
end
|
150
97
|
|
151
98
|
# save diagnostics before anything can fail
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
-
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/tests.rb
|
3
3
|
|
4
|
-
|
5
|
-
say_wizard "recipe
|
4
|
+
stage_two do
|
5
|
+
say_wizard "recipe stage two"
|
6
6
|
if prefer :tests, 'rspec'
|
7
7
|
say_wizard "recipe installing RSpec"
|
8
8
|
generate 'testing:configure rspec -f'
|
@@ -15,8 +15,8 @@ after_bundler do
|
|
15
15
|
git :commit => '-qm "rails_apps_composer: testing framework"' if prefer :git, true
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
say_wizard "recipe
|
18
|
+
stage_three do
|
19
|
+
say_wizard "recipe stage three"
|
20
20
|
if (prefer :authentication, 'devise') && (prefer :tests, 'rspec')
|
21
21
|
generate 'testing:configure devise -f'
|
22
22
|
end
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
__END__
|
32
32
|
|
33
|
-
name:
|
33
|
+
name: tests
|
34
34
|
description: "Add testing framework."
|
35
35
|
author: RailsApps
|
36
36
|
|
data/templates/helpers.erb
CHANGED
@@ -10,14 +10,6 @@ def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m
|
|
10
10
|
def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
|
11
11
|
def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
|
12
12
|
|
13
|
-
def rails_4?
|
14
|
-
Rails::VERSION::MAJOR.to_s == "4"
|
15
|
-
end
|
16
|
-
|
17
|
-
def rails_4_1?
|
18
|
-
Rails::VERSION::MAJOR.to_s == "4" && Rails::VERSION::MINOR.to_s == "1"
|
19
|
-
end
|
20
|
-
|
21
13
|
def ask_wizard(question)
|
22
14
|
ask "\033[1m\033[36m" + (@current_recipe || "prompt").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m"
|
23
15
|
end
|
@@ -51,9 +43,9 @@ end
|
|
51
43
|
@configs = {}
|
52
44
|
|
53
45
|
@after_blocks = []
|
54
|
-
def
|
55
|
-
@
|
56
|
-
def
|
46
|
+
def stage_two(&block); @after_blocks << [@current_recipe, block]; end
|
47
|
+
@stage_three_blocks = []
|
48
|
+
def stage_three(&block); @stage_three_blocks << [@current_recipe, block]; end
|
57
49
|
@before_configs = {}
|
58
50
|
def before_config(&block); @before_configs[@current_recipe] = block; end
|
59
51
|
|
data/templates/layout.erb
CHANGED
@@ -116,7 +116,7 @@ say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\
|
|
116
116
|
say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\033[0m")
|
117
117
|
say_wizard("\033[1m\033[36m" + '' + "\033[0m")
|
118
118
|
say_wizard("\033[1m\033[36m" + "Rails Composer, open source, supported by subscribers." + "\033[0m")
|
119
|
-
say_wizard("\033[1m\033[36m" + "Please join RailsApps
|
119
|
+
say_wizard("\033[1m\033[36m" + "Please join RailsApps to support development of Rails Composer." + "\033[0m")
|
120
120
|
say_wizard("Need help? Ask on Stack Overflow with the tag \'railsapps.\'")
|
121
121
|
say_wizard("Your new application will contain diagnostics in its README file.")
|
122
122
|
|
@@ -199,9 +199,9 @@ say_wizard "Installing gems. This will take a while."
|
|
199
199
|
run 'bundle install --without production'
|
200
200
|
say_wizard "Updating gem paths."
|
201
201
|
Gem.clear_paths
|
202
|
-
# >-----------------------------[ Run '
|
202
|
+
# >-----------------------------[ Run 'stage_two' Callbacks ]-------------------------------<
|
203
203
|
|
204
|
-
say_wizard "
|
204
|
+
say_wizard "Stage Two (running recipe 'stage_two' callbacks)."
|
205
205
|
if prefer :templates, 'haml'
|
206
206
|
say_wizard "importing html2haml conversion tool"
|
207
207
|
require 'html2haml'
|
@@ -213,11 +213,11 @@ say_wizard "importing html2haml and haml2slim conversion tools"
|
|
213
213
|
end
|
214
214
|
@after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; puts @current_recipe; b[1].call}
|
215
215
|
|
216
|
-
# >-----------------------------[ Run '
|
216
|
+
# >-----------------------------[ Run 'stage_three' Callbacks ]-------------------------------<
|
217
217
|
|
218
218
|
@current_recipe = nil
|
219
|
-
say_wizard "
|
220
|
-
@
|
219
|
+
say_wizard "Stage Three (running recipe 'stage_three' callbacks)."
|
220
|
+
@stage_three_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; puts @current_recipe; b[1].call}
|
221
221
|
|
222
222
|
@current_recipe = nil
|
223
223
|
say_wizard("Your new application will contain diagnostics in its README file.")
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_apps_composer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kehoe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -119,9 +119,9 @@ files:
|
|
119
119
|
- lib/rails_wizard/recipes.rb
|
120
120
|
- lib/rails_wizard/template.rb
|
121
121
|
- recipes/admin.rb
|
122
|
-
- recipes/controllers.rb
|
123
122
|
- recipes/core.rb
|
124
123
|
- recipes/deployment.rb
|
124
|
+
- recipes/devise.rb
|
125
125
|
- recipes/email.rb
|
126
126
|
- recipes/email_dev.rb
|
127
127
|
- recipes/example.rb
|
@@ -131,8 +131,8 @@ files:
|
|
131
131
|
- recipes/git.rb
|
132
132
|
- recipes/init.rb
|
133
133
|
- recipes/learn_rails.rb
|
134
|
-
- recipes/
|
135
|
-
- recipes/
|
134
|
+
- recipes/omniauth.rb
|
135
|
+
- recipes/pages.rb
|
136
136
|
- recipes/rails_bootstrap.rb
|
137
137
|
- recipes/rails_devise.rb
|
138
138
|
- recipes/rails_devise_pundit.rb
|
@@ -141,12 +141,9 @@ files:
|
|
141
141
|
- recipes/rails_signup_download.rb
|
142
142
|
- recipes/railsapps.rb
|
143
143
|
- recipes/readme.rb
|
144
|
-
- recipes/
|
145
|
-
- recipes/saas.rb
|
144
|
+
- recipes/roles.rb
|
146
145
|
- recipes/setup.rb
|
147
|
-
- recipes/
|
148
|
-
- recipes/tests4.rb
|
149
|
-
- recipes/views.rb
|
146
|
+
- recipes/tests.rb
|
150
147
|
- spec/rails_wizard/config_spec.rb
|
151
148
|
- spec/rails_wizard/recipe_spec.rb
|
152
149
|
- spec/rails_wizard/recipes/sanity_spec.rb
|
data/recipes/controllers.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
-
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/controllers.rb
|
3
|
-
|
4
|
-
after_bundler do
|
5
|
-
say_wizard "recipe running after 'bundle install'"
|
6
|
-
### APPLICATION_CONTROLLER ###
|
7
|
-
if prefer :authentication, 'omniauth'
|
8
|
-
copy_from_repo 'app/controllers/application_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
9
|
-
end
|
10
|
-
if prefer :authorization, 'pundit'
|
11
|
-
copy_from_repo 'app/controllers/application_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
12
|
-
end
|
13
|
-
if prefer :authorization, 'cancan'
|
14
|
-
inject_into_file 'app/controllers/application_controller.rb', :before => "\nend" do <<-RUBY
|
15
|
-
\n
|
16
|
-
rescue_from CanCan::AccessDenied do |exception|
|
17
|
-
redirect_to root_path, :alert => exception.message
|
18
|
-
end
|
19
|
-
RUBY
|
20
|
-
end
|
21
|
-
end
|
22
|
-
### HOME_CONTROLLER ###
|
23
|
-
if ['home_app','users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
|
24
|
-
generate 'controller home --skip-assets --skip-helper'
|
25
|
-
end
|
26
|
-
### USERS_CONTROLLER ###
|
27
|
-
case prefs[:starter_app]
|
28
|
-
when 'users_app'
|
29
|
-
if (prefer :authentication, 'devise') and (not prefer :apps4, 'rails-devise')
|
30
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
|
31
|
-
elsif prefer :authentication, 'omniauth'
|
32
|
-
if rails_4?
|
33
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
34
|
-
else
|
35
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
when 'admin_app'
|
39
|
-
if (prefer :authentication, 'devise') and (not prefer :apps4, 'rails-devise')
|
40
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
|
41
|
-
elsif prefer :authentication, 'omniauth'
|
42
|
-
if rails_4?
|
43
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
44
|
-
else
|
45
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
if prefer :authorization, 'pundit'
|
49
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
50
|
-
copy_from_repo 'app/policies/user_policy.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
51
|
-
end
|
52
|
-
when 'subdomains_app'
|
53
|
-
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
|
54
|
-
end
|
55
|
-
### REGISTRATIONS_CONTROLLER ###
|
56
|
-
if rails_4?
|
57
|
-
if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
|
58
|
-
## accommodate strong parameters in Rails 4
|
59
|
-
copy_from_repo 'app/controllers/registrations_controller-devise.rb', :prefs => 'devise'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
### SESSIONS_CONTROLLER ###
|
63
|
-
if prefer :authentication, 'omniauth'
|
64
|
-
filename = 'app/controllers/sessions_controller.rb'
|
65
|
-
copy_from_repo filename, :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
66
|
-
gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
|
67
|
-
if prefer :authorization, 'cancan'
|
68
|
-
inject_into_file filename, " user.add_role :admin if User.count == 1 # make the first user an admin\n", :after => "session[:user_id] = user.id\n"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
### PROFILES_CONTROLLER ###
|
72
|
-
copy_from_repo 'app/controllers/profiles_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
|
73
|
-
### GIT ###
|
74
|
-
git :add => '-A' if prefer :git, true
|
75
|
-
git :commit => '-qm "rails_apps_composer: controllers"' if prefer :git, true
|
76
|
-
end # after_bundler
|
77
|
-
|
78
|
-
__END__
|
79
|
-
|
80
|
-
name: controllers
|
81
|
-
description: "Add controllers needed for starter apps."
|
82
|
-
author: RailsApps
|
83
|
-
|
84
|
-
requires: [setup, gems, models]
|
85
|
-
run_after: [setup, gems, models]
|
86
|
-
category: mvc
|
data/recipes/models.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
-
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/models.rb
|
3
|
-
|
4
|
-
after_bundler do
|
5
|
-
say_wizard "recipe running after 'bundle install'"
|
6
|
-
### DEVISE ###
|
7
|
-
if prefer :authentication, 'devise'
|
8
|
-
if rails_4_1?
|
9
|
-
# prevent logging of password_confirmation
|
10
|
-
gsub_file 'config/initializers/filter_parameter_logging.rb', /:password/, ':password, :password_confirmation'
|
11
|
-
end
|
12
|
-
generate 'devise:install'
|
13
|
-
generate 'devise_invitable:install' if prefer :devise_modules, 'invitable'
|
14
|
-
generate 'devise user' # create the User model
|
15
|
-
if prefer :orm, 'mongoid'
|
16
|
-
## DEVISE AND MONGOID
|
17
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-devise/master/' unless rails_4?
|
18
|
-
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
19
|
-
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
|
20
|
-
gsub_file 'app/models/user.rb', /# field :confirmation_token/, "field :confirmation_token"
|
21
|
-
gsub_file 'app/models/user.rb', /# field :confirmed_at/, "field :confirmed_at"
|
22
|
-
gsub_file 'app/models/user.rb', /# field :confirmation_sent_at/, "field :confirmation_sent_at"
|
23
|
-
gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email"
|
24
|
-
end
|
25
|
-
if (prefer :devise_modules, 'invitable')
|
26
|
-
gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
|
27
|
-
<<-RUBY
|
28
|
-
#invitable
|
29
|
-
field :invitation_token, :type => String
|
30
|
-
field :invitation_sent_at, :type => Time
|
31
|
-
field :invitation_accepted_at, :type => Time
|
32
|
-
field :invitation_limit, :type => Integer
|
33
|
-
field :invited_by_id, :type => String
|
34
|
-
field :invited_by_type, :type => String
|
35
|
-
end
|
36
|
-
RUBY
|
37
|
-
end
|
38
|
-
end
|
39
|
-
else
|
40
|
-
## DEVISE AND ACTIVE RECORD
|
41
|
-
unless prefer :railsapps, 'rails-recurly-subscription-saas'
|
42
|
-
generate 'migration AddNameToUsers name:string'
|
43
|
-
end
|
44
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' unless rails_4?
|
45
|
-
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
46
|
-
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
|
47
|
-
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
|
48
|
-
end
|
49
|
-
run 'bundle exec rake db:migrate'
|
50
|
-
end
|
51
|
-
## DEVISE AND CUCUMBER
|
52
|
-
if prefer :integration, 'cucumber'
|
53
|
-
# Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
|
54
|
-
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
|
55
|
-
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
### OMNIAUTH ###
|
59
|
-
if prefer :authentication, 'omniauth'
|
60
|
-
if rails_4_1?
|
61
|
-
copy_from_repo 'config/initializers/omniauth.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
62
|
-
else
|
63
|
-
copy_from_repo 'config/initializers/omniauth.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
64
|
-
end
|
65
|
-
gsub_file 'config/initializers/omniauth.rb', /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
|
66
|
-
if prefer :orm, 'mongoid'
|
67
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
68
|
-
else
|
69
|
-
generate 'model User name:string email:string provider:string uid:string'
|
70
|
-
run 'bundle exec rake db:migrate'
|
71
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
### SUBDOMAINS ###
|
75
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
|
76
|
-
### AUTHORIZATION ###
|
77
|
-
if prefer :authorization, 'pundit'
|
78
|
-
generate 'migration AddRoleToUsers role:integer'
|
79
|
-
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/'
|
80
|
-
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
81
|
-
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
|
82
|
-
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
|
83
|
-
end
|
84
|
-
end
|
85
|
-
if prefer :authorization, 'cancan'
|
86
|
-
generate 'cancan:ability'
|
87
|
-
if prefer :starter_app, 'admin_app'
|
88
|
-
# Limit access to the users#index page
|
89
|
-
copy_from_repo 'app/models/ability.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
|
90
|
-
# allow an admin to update roles
|
91
|
-
insert_into_file 'app/models/user.rb', " attr_accessible :role_ids, :as => :admin\n", :before => " attr_accessible"
|
92
|
-
end
|
93
|
-
unless prefer :orm, 'mongoid'
|
94
|
-
generate 'rolify Role User'
|
95
|
-
else
|
96
|
-
generate 'rolify Role User --orm=mongoid'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
### GIT ###
|
100
|
-
git :add => '-A' if prefer :git, true
|
101
|
-
git :commit => '-qm "rails_apps_composer: models"' if prefer :git, true
|
102
|
-
end # after_bundler
|
103
|
-
|
104
|
-
__END__
|
105
|
-
|
106
|
-
name: models
|
107
|
-
description: "Add models needed for starter apps."
|
108
|
-
author: RailsApps
|
109
|
-
|
110
|
-
requires: [setup, gems]
|
111
|
-
run_after: [setup, gems]
|
112
|
-
category: mvc
|