intersect_rails_composer 0.0.2
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.
- checksums.yaml +7 -0
- data/README.textile +433 -0
- data/bin/intersect_rails_composer +7 -0
- data/lib/rails_wizard/command.rb +204 -0
- data/lib/rails_wizard/config.rb +88 -0
- data/lib/rails_wizard/diagnostics.rb +68 -0
- data/lib/rails_wizard/recipe.rb +114 -0
- data/lib/rails_wizard/recipes.rb +56 -0
- data/lib/rails_wizard/template.rb +111 -0
- data/lib/rails_wizard.rb +7 -0
- data/recipes/apps4.rb +150 -0
- data/recipes/controllers.rb +75 -0
- data/recipes/core.rb +14 -0
- data/recipes/email.rb +110 -0
- data/recipes/example.rb +70 -0
- data/recipes/extras.rb +187 -0
- data/recipes/frontend.rb +45 -0
- data/recipes/gems.rb +277 -0
- data/recipes/git.rb +20 -0
- data/recipes/init.rb +136 -0
- data/recipes/models.rb +109 -0
- data/recipes/prelaunch.rb +119 -0
- data/recipes/railsapps.rb +277 -0
- data/recipes/readme.rb +85 -0
- data/recipes/routes.rb +45 -0
- data/recipes/saas.rb +218 -0
- data/recipes/setup.rb +134 -0
- data/recipes/testing.rb +276 -0
- data/recipes/views.rb +57 -0
- data/spec/rails_wizard/config_spec.rb +108 -0
- data/spec/rails_wizard/recipe_spec.rb +115 -0
- data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
- data/spec/rails_wizard/recipes_spec.rb +41 -0
- data/spec/rails_wizard/template_spec.rb +92 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_directory.rb +17 -0
- data/spec/support/template_runner.rb +28 -0
- data/spec/test_recipes/test_recipe_in_file.rb +9 -0
- data/templates/helpers.erb +135 -0
- data/templates/layout.erb +232 -0
- data/templates/recipe.erb +13 -0
- data/version.rb +3 -0
- metadata +210 -0
data/recipes/gems.rb
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb
|
3
|
+
|
4
|
+
### GEMFILE ###
|
5
|
+
|
6
|
+
## Ruby on Rails
|
7
|
+
insert_into_file('Gemfile', "ruby '#{RUBY_VERSION}'\n", :before => /^ *gem 'rails'/, :force => false)
|
8
|
+
|
9
|
+
## Cleanup
|
10
|
+
# remove the 'sdoc' gem
|
11
|
+
gsub_file 'Gemfile', /group :doc do/, ''
|
12
|
+
gsub_file 'Gemfile', /\s*gem 'sdoc', require: false\nend/, ''
|
13
|
+
|
14
|
+
assets_group = rails_4? ? nil : :assets
|
15
|
+
|
16
|
+
## Web Server
|
17
|
+
if (prefs[:dev_webserver] == prefs[:prod_webserver])
|
18
|
+
add_gem 'thin' if prefer :dev_webserver, 'thin'
|
19
|
+
add_gem 'unicorn' if prefer :dev_webserver, 'unicorn'
|
20
|
+
add_gem 'puma' if prefer :dev_webserver, 'puma'
|
21
|
+
else
|
22
|
+
add_gem 'thin', :group => [:development, :test] if prefer :dev_webserver, 'thin'
|
23
|
+
add_gem 'unicorn', :group => [:development, :test] if prefer :dev_webserver, 'unicorn'
|
24
|
+
add_gem 'puma', :group => [:development, :test] if prefer :dev_webserver, 'puma'
|
25
|
+
add_gem 'thin', :group => :production if prefer :prod_webserver, 'thin'
|
26
|
+
add_gem 'unicorn', :group => :production if prefer :prod_webserver, 'unicorn'
|
27
|
+
add_gem 'puma', :group => :production if prefer :prod_webserver, 'puma'
|
28
|
+
end
|
29
|
+
|
30
|
+
## Rails 4.0 attr_accessible Compatibility
|
31
|
+
# if prefer :apps4, false
|
32
|
+
# add_gem 'protected_attributes' if rails_4?
|
33
|
+
# end
|
34
|
+
|
35
|
+
## Database Adapter
|
36
|
+
unless prefer :database, 'default'
|
37
|
+
gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
|
38
|
+
end
|
39
|
+
if rails_4?
|
40
|
+
add_gem 'mongoid', '~> 4', github: 'mongoid/mongoid' if prefer :orm, 'mongoid'
|
41
|
+
else
|
42
|
+
add_gem 'mongoid' if prefer :orm, 'mongoid'
|
43
|
+
end
|
44
|
+
gsub_file 'Gemfile', /gem 'pg'.*/, ''
|
45
|
+
add_gem 'pg' if prefer :database, 'postgresql'
|
46
|
+
gsub_file 'Gemfile', /gem 'mysql2'.*/, ''
|
47
|
+
add_gem 'mysql2' if prefer :database, 'mysql'
|
48
|
+
|
49
|
+
## Template Engine
|
50
|
+
if prefer :templates, 'haml'
|
51
|
+
add_gem 'haml-rails'
|
52
|
+
add_gem 'html2haml', :group => :development
|
53
|
+
end
|
54
|
+
if prefer :templates, 'slim'
|
55
|
+
add_gem 'slim'
|
56
|
+
add_gem 'haml2slim', :group => :development
|
57
|
+
# Haml is needed for conversion of HTML to Slim
|
58
|
+
add_gem 'haml-rails', :group => :development
|
59
|
+
add_gem 'html2haml', :group => :development
|
60
|
+
end
|
61
|
+
|
62
|
+
## Testing Framework
|
63
|
+
if prefer :unit_test, 'rspec'
|
64
|
+
add_gem 'rspec-rails', :group => [:development, :test]
|
65
|
+
add_gem 'capybara', :group => :test if prefer :integration, 'rspec-capybara'
|
66
|
+
add_gem 'database_cleaner', '1.0.1', :group => :test
|
67
|
+
if prefer :orm, 'mongoid'
|
68
|
+
if rails_4?
|
69
|
+
add_gem 'mongoid-rspec', '>= 1.6.0', github: 'evansagge/mongoid-rspec', :group => :test
|
70
|
+
else
|
71
|
+
add_gem 'mongoid-rspec', :group => :test
|
72
|
+
end
|
73
|
+
end
|
74
|
+
add_gem 'email_spec', :group => :test
|
75
|
+
end
|
76
|
+
if prefer :unit_test, 'minitest'
|
77
|
+
add_gem 'minitest-spec-rails', :group => :test
|
78
|
+
add_gem 'minitest-wscolor', :group => :test
|
79
|
+
add_gem 'capybara', :group => :test if prefer :integration, 'minitest-capybara'
|
80
|
+
end
|
81
|
+
if prefer :integration, 'cucumber'
|
82
|
+
add_gem 'cucumber-rails', :group => :test, :require => false
|
83
|
+
add_gem 'database_cleaner', '1.0.1', :group => :test unless prefer :unit_test, 'rspec'
|
84
|
+
add_gem 'launchy', :group => :test
|
85
|
+
add_gem 'capybara', :group => :test
|
86
|
+
end
|
87
|
+
add_gem 'turnip', '>= 1.1.0', :group => :test if prefer :integration, 'turnip'
|
88
|
+
if prefer :continuous_testing, 'guard'
|
89
|
+
add_gem 'guard-bundler', :group => :development
|
90
|
+
add_gem 'guard-cucumber', :group => :development if prefer :integration, 'cucumber'
|
91
|
+
add_gem 'guard-rails', :group => :development
|
92
|
+
add_gem 'guard-rspec', :group => :development if prefer :unit_test, 'rspec'
|
93
|
+
add_gem 'rb-inotify', :group => :development, :require => false
|
94
|
+
add_gem 'rb-fsevent', :group => :development, :require => false
|
95
|
+
add_gem 'rb-fchange', :group => :development, :require => false
|
96
|
+
end
|
97
|
+
add_gem 'factory_girl_rails', :group => [:development, :test] if prefer :fixtures, 'factory_girl'
|
98
|
+
add_gem 'fabrication', :group => [:development, :test] if prefer :fixtures, 'fabrication'
|
99
|
+
add_gem 'machinist', :group => :test if prefer :fixtures, 'machinist'
|
100
|
+
|
101
|
+
## Front-end Framework
|
102
|
+
add_gem 'rails_layout', :group => :development
|
103
|
+
case prefs[:frontend]
|
104
|
+
when 'bootstrap2'
|
105
|
+
add_gem 'bootstrap-sass', '~> 2.3.2.2'
|
106
|
+
when 'bootstrap3'
|
107
|
+
add_gem 'bootstrap-sass', '>= 3.0.0.0'
|
108
|
+
when 'foundation4'
|
109
|
+
if rails_4?
|
110
|
+
add_gem 'zurb-foundation'
|
111
|
+
add_gem 'compass-rails', '~> 2.0.alpha.0'
|
112
|
+
else
|
113
|
+
add_gem 'zurb-foundation', :group => assets_group
|
114
|
+
add_gem 'compass-rails', '~> 1.0.3', :group => assets_group
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
## Email
|
119
|
+
add_gem 'sendgrid' if prefer :email, 'sendgrid'
|
120
|
+
|
121
|
+
## Authentication (Devise)
|
122
|
+
add_gem 'devise' if prefer :authentication, 'devise'
|
123
|
+
add_gem 'devise_invitable' if prefer :devise_modules, 'invitable'
|
124
|
+
|
125
|
+
## Authentication (OmniAuth)
|
126
|
+
add_gem 'omniauth' if prefer :authentication, 'omniauth'
|
127
|
+
add_gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter'
|
128
|
+
add_gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook'
|
129
|
+
add_gem 'omniauth-github' if prefer :omniauth_provider, 'github'
|
130
|
+
add_gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin'
|
131
|
+
add_gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google_oauth2'
|
132
|
+
add_gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
|
133
|
+
|
134
|
+
## Authorization
|
135
|
+
if prefer :authorization, 'cancan'
|
136
|
+
add_gem 'cancan'
|
137
|
+
add_gem 'rolify'
|
138
|
+
end
|
139
|
+
|
140
|
+
## Form Builder
|
141
|
+
add_gem 'simple_form' if prefer :form_builder, 'simple_form'
|
142
|
+
|
143
|
+
## Membership App
|
144
|
+
if prefer :railsapps, 'rails-stripe-membership-saas'
|
145
|
+
add_gem 'stripe'
|
146
|
+
add_gem 'stripe_event'
|
147
|
+
end
|
148
|
+
if prefer :railsapps, 'rails-recurly-subscription-saas'
|
149
|
+
add_gem 'recurly'
|
150
|
+
add_gem 'nokogiri'
|
151
|
+
add_gem 'countries'
|
152
|
+
add_gem 'httpi'
|
153
|
+
add_gem 'httpclient'
|
154
|
+
end
|
155
|
+
|
156
|
+
## Signup App
|
157
|
+
if prefer :railsapps, 'rails-prelaunch-signup'
|
158
|
+
add_gem 'gibbon'
|
159
|
+
add_gem 'capybara-webkit', :group => :test
|
160
|
+
end
|
161
|
+
|
162
|
+
## Gems from a defaults file or added interactively
|
163
|
+
gems.each do |g|
|
164
|
+
gem(*g)
|
165
|
+
end
|
166
|
+
|
167
|
+
## Git
|
168
|
+
git :add => '-A' if prefer :git, true
|
169
|
+
git :commit => '-qm "rails_apps_composer: Gemfile"' if prefer :git, true
|
170
|
+
|
171
|
+
### CREATE DATABASE ###
|
172
|
+
after_bundler do
|
173
|
+
unless prefer :database, 'default'
|
174
|
+
copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql'
|
175
|
+
copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql'
|
176
|
+
generate 'mongoid:config' if prefer :orm, 'mongoid'
|
177
|
+
remove_file 'config/database.yml' if prefer :orm, 'mongoid'
|
178
|
+
if prefer :database, 'postgresql'
|
179
|
+
begin
|
180
|
+
pg_username = prefs[:pg_username] || ask_wizard("Username for PostgreSQL?(leave blank to use the app name)")
|
181
|
+
if pg_username.blank?
|
182
|
+
say_wizard "Creating a user named '#{app_name}' for PostgreSQL"
|
183
|
+
run "createuser #{app_name}" if prefer :database, 'postgresql'
|
184
|
+
gsub_file "config/database.yml", /username: .*/, "username: #{app_name}"
|
185
|
+
else
|
186
|
+
gsub_file "config/database.yml", /username: .*/, "username: #{pg_username}"
|
187
|
+
pg_password = prefs[:pg_password] || ask_wizard("Password for PostgreSQL user #{pg_username}?")
|
188
|
+
gsub_file "config/database.yml", /password:/, "password: #{pg_password}"
|
189
|
+
say_wizard "set config/database.yml for username/password #{pg_username}/#{pg_password}"
|
190
|
+
end
|
191
|
+
rescue StandardError => e
|
192
|
+
raise "unable to create a user for PostgreSQL, reason: #{e}"
|
193
|
+
end
|
194
|
+
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
|
195
|
+
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
|
196
|
+
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
|
197
|
+
end
|
198
|
+
if prefer :database, 'mysql'
|
199
|
+
mysql_username = prefs[:mysql_username] || ask_wizard("Username for MySQL? (leave blank to use the app name)")
|
200
|
+
if mysql_username.blank?
|
201
|
+
gsub_file "config/database.yml", /username: .*/, "username: #{app_name}"
|
202
|
+
else
|
203
|
+
gsub_file "config/database.yml", /username: .*/, "username: #{mysql_username}"
|
204
|
+
mysql_password = prefs[:mysql_password] || ask_wizard("Password for MySQL user #{mysql_username}?")
|
205
|
+
gsub_file "config/database.yml", /password:/, "password: #{mysql_password}"
|
206
|
+
say_wizard "set config/database.yml for username/password #{mysql_username}/#{mysql_password}"
|
207
|
+
end
|
208
|
+
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
|
209
|
+
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
|
210
|
+
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
|
211
|
+
end
|
212
|
+
unless prefer :database, 'sqlite'
|
213
|
+
if (prefs.has_key? :drop_database) ? prefs[:drop_database] :
|
214
|
+
(yes_wizard? "Okay to drop all existing databases named #{app_name}? 'No' will abort immediately!")
|
215
|
+
run 'bundle exec rake db:drop'
|
216
|
+
else
|
217
|
+
raise "aborted at user's request"
|
218
|
+
end
|
219
|
+
end
|
220
|
+
run 'bundle exec rake db:create:all' unless prefer :orm, 'mongoid'
|
221
|
+
run 'bundle exec rake db:create' if prefer :orm, 'mongoid'
|
222
|
+
## Git
|
223
|
+
git :add => '-A' if prefer :git, true
|
224
|
+
git :commit => '-qm "rails_apps_composer: create database"' if prefer :git, true
|
225
|
+
end
|
226
|
+
end # after_bundler
|
227
|
+
|
228
|
+
### GENERATORS ###
|
229
|
+
after_bundler do
|
230
|
+
## Form Builder
|
231
|
+
if prefer :form_builder, 'simple_form'
|
232
|
+
case prefs[:frontend]
|
233
|
+
when 'bootstrap2'
|
234
|
+
say_wizard "recipe installing simple_form for use with Twitter Bootstrap"
|
235
|
+
generate 'simple_form:install --bootstrap'
|
236
|
+
when 'bootstrap3'
|
237
|
+
say_wizard "recipe installing simple_form for use with Twitter Bootstrap"
|
238
|
+
generate 'simple_form:install --bootstrap'
|
239
|
+
when 'foundation4'
|
240
|
+
say_wizard "recipe installing simple_form for use with Zurb Foundation"
|
241
|
+
generate 'simple_form:install --foundation'
|
242
|
+
else
|
243
|
+
say_wizard "recipe installing simple_form"
|
244
|
+
generate 'simple_form:install'
|
245
|
+
end
|
246
|
+
end
|
247
|
+
## Figaro Gem
|
248
|
+
if prefs[:local_env_file]
|
249
|
+
generate 'figaro:install'
|
250
|
+
gsub_file 'config/application.yml', /# PUSHER_.*\n/, ''
|
251
|
+
gsub_file 'config/application.yml', /# STRIPE_.*\n/, ''
|
252
|
+
prepend_to_file 'config/application.yml' do <<-FILE
|
253
|
+
# Add account credentials and API keys here.
|
254
|
+
# See http://railsapps.github.io/rails-environment-variables.html
|
255
|
+
# This file should be listed in .gitignore to keep your settings secret!
|
256
|
+
# Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
|
257
|
+
# For example, setting:
|
258
|
+
# GMAIL_USERNAME: Your_Gmail_Username
|
259
|
+
# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
|
260
|
+
|
261
|
+
FILE
|
262
|
+
end
|
263
|
+
end
|
264
|
+
## Git
|
265
|
+
git :add => '-A' if prefer :git, true
|
266
|
+
git :commit => '-qm "rails_apps_composer: generators"' if prefer :git, true
|
267
|
+
end # after_bundler
|
268
|
+
|
269
|
+
__END__
|
270
|
+
|
271
|
+
name: gems
|
272
|
+
description: "Add the gems your application needs."
|
273
|
+
author: RailsApps
|
274
|
+
|
275
|
+
requires: [setup]
|
276
|
+
run_after: [setup]
|
277
|
+
category: configuration
|
data/recipes/git.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb
|
3
|
+
|
4
|
+
## Git
|
5
|
+
say_wizard "initialize git"
|
6
|
+
prefs[:git] = true unless prefs.has_key? :git
|
7
|
+
if prefer :git, true
|
8
|
+
copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
|
9
|
+
git :init
|
10
|
+
git :add => '-A'
|
11
|
+
git :commit => '-qm "rails_apps_composer: initial commit"'
|
12
|
+
end
|
13
|
+
|
14
|
+
__END__
|
15
|
+
|
16
|
+
name: git
|
17
|
+
description: "Initialize git for your application."
|
18
|
+
author: RailsApps
|
19
|
+
|
20
|
+
category: configuration
|
data/recipes/init.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb
|
3
|
+
|
4
|
+
after_everything do
|
5
|
+
say_wizard "recipe running after everything"
|
6
|
+
### CONFIGURATION FILE ###
|
7
|
+
## EMAIL
|
8
|
+
case prefs[:email]
|
9
|
+
when 'none'
|
10
|
+
credentials = ''
|
11
|
+
when 'smtp'
|
12
|
+
credentials = ''
|
13
|
+
when 'gmail'
|
14
|
+
credentials = "GMAIL_USERNAME: Your_Username\nGMAIL_PASSWORD: Your_Password\n"
|
15
|
+
when 'sendgrid'
|
16
|
+
credentials = "SENDGRID_USERNAME: Your_Username\nSENDGRID_PASSWORD: Your_Password\n"
|
17
|
+
when 'mandrill'
|
18
|
+
credentials = "MANDRILL_USERNAME: Your_Username\nMANDRILL_API_KEY: Your_API_Key\n"
|
19
|
+
end
|
20
|
+
append_file 'config/application.yml', credentials if prefs[:local_env_file]
|
21
|
+
if prefs[:local_env_file]
|
22
|
+
## DEFAULT USER
|
23
|
+
unless prefer :starter_app, false
|
24
|
+
append_file 'config/application.yml' do <<-FILE
|
25
|
+
ADMIN_NAME: First User
|
26
|
+
ADMIN_EMAIL: user@example.com
|
27
|
+
ADMIN_PASSWORD: changeme
|
28
|
+
FILE
|
29
|
+
end
|
30
|
+
end
|
31
|
+
## AUTHENTICATION
|
32
|
+
if prefer :authentication, 'omniauth'
|
33
|
+
append_file 'config/application.yml' do <<-FILE
|
34
|
+
OMNIAUTH_PROVIDER_KEY: Your_OmniAuth_Provider_Key
|
35
|
+
OMNIAUTH_PROVIDER_SECRET: Your_OmniAuth_Provider_Secret
|
36
|
+
FILE
|
37
|
+
end
|
38
|
+
end
|
39
|
+
## AUTHORIZATION
|
40
|
+
if (prefer :authorization, 'cancan')
|
41
|
+
append_file 'config/application.yml', "ROLES: [admin, user, VIP]\n"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
### SUBDOMAINS ###
|
45
|
+
copy_from_repo 'config/application.yml', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
|
46
|
+
### APPLICATION.EXAMPLE.YML ###
|
47
|
+
if prefs[:local_env_file]
|
48
|
+
copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml'
|
49
|
+
end
|
50
|
+
### DATABASE SEED ###
|
51
|
+
if prefs[:local_env_file]
|
52
|
+
append_file 'db/seeds.rb' do <<-FILE
|
53
|
+
# Environment variables (ENV['...']) can be set in the file config/application.yml.
|
54
|
+
# See http://railsapps.github.io/rails-environment-variables.html
|
55
|
+
FILE
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if (prefer :authorization, 'cancan')
|
59
|
+
unless prefer :orm, 'mongoid'
|
60
|
+
append_file 'db/seeds.rb' do <<-FILE
|
61
|
+
puts 'ROLES'
|
62
|
+
YAML.load(ENV['ROLES']).each do |role|
|
63
|
+
Role.find_or_create_by_name({ :name => role }, :without_protection => true)
|
64
|
+
puts 'role: ' << role
|
65
|
+
end
|
66
|
+
FILE
|
67
|
+
end
|
68
|
+
## Fix db seed for Rails 4.0
|
69
|
+
gsub_file 'db/seeds.rb', /{ :name => role }, :without_protection => true/, 'role' if rails_4?
|
70
|
+
else
|
71
|
+
append_file 'db/seeds.rb' do <<-FILE
|
72
|
+
puts 'ROLES'
|
73
|
+
YAML.load(ENV['ROLES']).each do |role|
|
74
|
+
Role.mongo_session['roles'].insert({ :name => role })
|
75
|
+
puts 'role: ' << role
|
76
|
+
end
|
77
|
+
FILE
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
## DEVISE-DEFAULT
|
82
|
+
if prefer :authentication, 'devise'
|
83
|
+
append_file 'db/seeds.rb' do <<-FILE
|
84
|
+
puts 'DEFAULT USERS'
|
85
|
+
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
|
86
|
+
puts 'user: ' << user.name
|
87
|
+
FILE
|
88
|
+
end
|
89
|
+
# Mongoid doesn't have a 'find_or_create_by' method
|
90
|
+
gsub_file 'db/seeds.rb', /find_or_create_by_email/, 'create!' if prefer :orm, 'mongoid'
|
91
|
+
end
|
92
|
+
## DEVISE-CONFIRMABLE
|
93
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
94
|
+
append_file 'db/seeds.rb', "user.confirm!\n"
|
95
|
+
end
|
96
|
+
if (prefer :authorization, 'cancan') && !(prefer :authentication, 'omniauth')
|
97
|
+
append_file 'db/seeds.rb', 'user.add_role :admin'
|
98
|
+
end
|
99
|
+
## DEVISE-INVITABLE
|
100
|
+
if prefer :devise_modules, 'invitable'
|
101
|
+
run 'bundle exec rake db:migrate'
|
102
|
+
generate 'devise_invitable user'
|
103
|
+
end
|
104
|
+
### APPLY DATABASE SEED ###
|
105
|
+
unless prefer :orm, 'mongoid'
|
106
|
+
unless prefer :database, 'default'
|
107
|
+
## ACTIVE_RECORD
|
108
|
+
say_wizard "applying migrations and seeding the database"
|
109
|
+
run 'bundle exec rake db:migrate'
|
110
|
+
run 'bundle exec rake db:test:prepare'
|
111
|
+
end
|
112
|
+
else
|
113
|
+
## MONGOID
|
114
|
+
say_wizard "dropping database, creating indexes and seeding the database"
|
115
|
+
run 'bundle exec rake db:drop'
|
116
|
+
run 'bundle exec rake db:mongoid:create_indexes'
|
117
|
+
end
|
118
|
+
unless prefs[:skip_seeds]
|
119
|
+
unless prefer :railsapps, 'rails-recurly-subscription-saas'
|
120
|
+
run 'bundle exec rake db:seed'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
### GIT ###
|
124
|
+
git :add => '-A' if prefer :git, true
|
125
|
+
git :commit => '-qm "rails_apps_composer: set up database"' if prefer :git, true
|
126
|
+
end # after_everything
|
127
|
+
|
128
|
+
__END__
|
129
|
+
|
130
|
+
name: init
|
131
|
+
description: "Set up and initialize database."
|
132
|
+
author: RailsApps
|
133
|
+
|
134
|
+
requires: [setup, gems, models]
|
135
|
+
run_after: [setup, gems, models]
|
136
|
+
category: initialize
|
data/recipes/models.rb
ADDED
@@ -0,0 +1,109 @@
|
|
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
|
+
# prevent logging of password_confirmation
|
9
|
+
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
10
|
+
generate 'devise:install'
|
11
|
+
generate 'devise_invitable:install' if prefer :devise_modules, 'invitable'
|
12
|
+
generate 'devise user' # create the User model
|
13
|
+
if prefer :orm, 'mongoid'
|
14
|
+
## DEVISE AND MONGOID
|
15
|
+
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-devise/master/'
|
16
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
17
|
+
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
|
18
|
+
gsub_file 'app/models/user.rb', /# field :confirmation_token/, "field :confirmation_token"
|
19
|
+
gsub_file 'app/models/user.rb', /# field :confirmed_at/, "field :confirmed_at"
|
20
|
+
gsub_file 'app/models/user.rb', /# field :confirmation_sent_at/, "field :confirmation_sent_at"
|
21
|
+
gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email"
|
22
|
+
end
|
23
|
+
if (prefer :devise_modules, 'invitable')
|
24
|
+
gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
|
25
|
+
<<-RUBY
|
26
|
+
#invitable
|
27
|
+
field :invitation_token, :type => String
|
28
|
+
field :invitation_sent_at, :type => Time
|
29
|
+
field :invitation_accepted_at, :type => Time
|
30
|
+
field :invitation_limit, :type => Integer
|
31
|
+
field :invited_by_id, :type => String
|
32
|
+
field :invited_by_type, :type => String
|
33
|
+
end
|
34
|
+
RUBY
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
## DEVISE AND ACTIVE RECORD
|
39
|
+
unless prefer :railsapps, 'rails-recurly-subscription-saas'
|
40
|
+
generate 'migration AddNameToUsers name:string'
|
41
|
+
end
|
42
|
+
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' unless rails_4?
|
43
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
44
|
+
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
|
45
|
+
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
## DEVISE AND CUCUMBER
|
49
|
+
if prefer :integration, 'cucumber'
|
50
|
+
# Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
|
51
|
+
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
|
52
|
+
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
### OMNIAUTH ###
|
56
|
+
if prefer :authentication, 'omniauth'
|
57
|
+
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
58
|
+
copy_from_repo 'config/initializers/omniauth.rb', :repo => repo
|
59
|
+
gsub_file 'config/initializers/omniauth.rb', /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
|
60
|
+
generate 'model User name:string email:string provider:string uid:string' unless prefer :orm, 'mongoid'
|
61
|
+
run 'bundle exec rake db:migrate' unless prefer :orm, 'mongoid'
|
62
|
+
copy_from_repo 'app/models/user.rb', :repo => repo # copy the User model (Mongoid version)
|
63
|
+
unless prefer :orm, 'mongoid'
|
64
|
+
## OMNIAUTH AND ACTIVE RECORD
|
65
|
+
gsub_file 'app/models/user.rb', /class User/, 'class User < ActiveRecord::Base'
|
66
|
+
gsub_file 'app/models/user.rb', /^\s*include Mongoid::Document\n/, ''
|
67
|
+
gsub_file 'app/models/user.rb', /^\s*field.*\n/, ''
|
68
|
+
gsub_file 'app/models/user.rb', /^\s*# run 'rake db:mongoid:create_indexes' to create indexes\n/, ''
|
69
|
+
gsub_file 'app/models/user.rb', /^\s*index\(\{ email: 1 \}, \{ unique: true, background: true \}\)\n/, ''
|
70
|
+
end
|
71
|
+
end
|
72
|
+
### SUBDOMAINS ###
|
73
|
+
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
|
74
|
+
### AUTHORIZATION ###
|
75
|
+
if prefer :authorization, 'cancan'
|
76
|
+
generate 'cancan:ability'
|
77
|
+
if prefer :starter_app, 'admin_app'
|
78
|
+
# Limit access to the users#index page
|
79
|
+
copy_from_repo 'app/models/ability.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
|
80
|
+
# allow an admin to update roles
|
81
|
+
insert_into_file 'app/models/user.rb', " attr_accessible :role_ids, :as => :admin\n", :before => " attr_accessible"
|
82
|
+
end
|
83
|
+
unless prefer :orm, 'mongoid'
|
84
|
+
generate 'rolify:role Role User'
|
85
|
+
else
|
86
|
+
generate 'rolify:role Role User mongoid'
|
87
|
+
# correct the generation of rolify 3.1 with mongoid
|
88
|
+
# the call to `rolify` should be *after* the inclusion of mongoid
|
89
|
+
# (see https://github.com/EppO/rolify/issues/61)
|
90
|
+
# This isn't needed for rolify>=3.2.0.beta4, but should cause no harm
|
91
|
+
gsub_file 'app/models/user.rb',
|
92
|
+
/^\s*(rolify.*?)$\s*(include Mongoid::Document.*?)$/,
|
93
|
+
" \\2\n extend Rolify\n \\1\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
### GIT ###
|
97
|
+
git :add => '-A' if prefer :git, true
|
98
|
+
git :commit => '-qm "rails_apps_composer: models"' if prefer :git, true
|
99
|
+
end # after_bundler
|
100
|
+
|
101
|
+
__END__
|
102
|
+
|
103
|
+
name: models
|
104
|
+
description: "Add models needed for starter apps."
|
105
|
+
author: RailsApps
|
106
|
+
|
107
|
+
requires: [setup, gems]
|
108
|
+
run_after: [setup, gems]
|
109
|
+
category: mvc
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/prelaunch.rb
|
3
|
+
|
4
|
+
if prefer :railsapps, 'rails-prelaunch-signup'
|
5
|
+
|
6
|
+
after_everything do
|
7
|
+
say_wizard "recipe running after 'bundle install'"
|
8
|
+
repo = 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/'
|
9
|
+
|
10
|
+
# >-------------------------------[ Clean up starter app ]--------------------------------<
|
11
|
+
|
12
|
+
%w{
|
13
|
+
public/index.html
|
14
|
+
app/assets/images/rails.png
|
15
|
+
}.each { |file| remove_file file }
|
16
|
+
# remove commented lines and multiple blank lines from Gemfile
|
17
|
+
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
|
18
|
+
gsub_file 'Gemfile', /#.*\n/, "\n"
|
19
|
+
gsub_file 'Gemfile', /\n^\s*\n/, "\n"
|
20
|
+
# remove commented lines and multiple blank lines from config/routes.rb
|
21
|
+
gsub_file 'config/routes.rb', / #.*\n/, "\n"
|
22
|
+
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
|
23
|
+
# GIT
|
24
|
+
git :add => '-A' if prefer :git, true
|
25
|
+
git :commit => '-qm "rails_apps_composer: clean up starter app"' if prefer :git, true
|
26
|
+
|
27
|
+
# >-------------------------------[ Create a git branch ]--------------------------------<
|
28
|
+
if prefer :git, true
|
29
|
+
if prefer :prelaunch_branch, 'master'
|
30
|
+
unless prefer :main_branch, 'none'
|
31
|
+
say_wizard "renaming git branch 'master' to '#{prefs[:main_branch]}' for starter app"
|
32
|
+
git :branch => "-m master #{prefs[:main_branch]}"
|
33
|
+
git :checkout => "-b master"
|
34
|
+
else
|
35
|
+
say_wizard "creating prelaunch app on git branch 'master'"
|
36
|
+
end
|
37
|
+
else
|
38
|
+
say_wizard "creating new git branch '#{prefs[:prelaunch_branch]}' for prelaunch app"
|
39
|
+
git :checkout => "-b #{prefs[:prelaunch_branch]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# >-------------------------------[ Models ]--------------------------------<
|
44
|
+
|
45
|
+
copy_from_repo 'app/models/user.rb', :repo => repo
|
46
|
+
|
47
|
+
# >-------------------------------[ Init ]--------------------------------<
|
48
|
+
copy_from_repo 'config/application.yml', :repo => repo
|
49
|
+
remove_file 'config/application.example.yml'
|
50
|
+
copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml'
|
51
|
+
copy_from_repo 'db/seeds.rb', :repo => repo
|
52
|
+
run 'bundle exec rake db:seed'
|
53
|
+
run 'bundle exec rake db:test:prepare'
|
54
|
+
|
55
|
+
# >-------------------------------[ Controllers ]--------------------------------<
|
56
|
+
|
57
|
+
copy_from_repo 'app/controllers/confirmations_controller.rb', :repo => repo
|
58
|
+
copy_from_repo 'app/controllers/home_controller.rb', :repo => repo
|
59
|
+
copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo
|
60
|
+
copy_from_repo 'app/controllers/users_controller.rb', :repo => repo
|
61
|
+
|
62
|
+
# >-------------------------------[ Mailers ]--------------------------------<
|
63
|
+
|
64
|
+
generate 'mailer UserMailer'
|
65
|
+
copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo
|
66
|
+
copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo
|
67
|
+
|
68
|
+
# >-------------------------------[ Views ]--------------------------------<
|
69
|
+
|
70
|
+
copy_from_repo 'app/views/devise/confirmations/show.html.erb', :repo => repo
|
71
|
+
copy_from_repo 'app/views/devise/mailer/confirmation_instructions.html.erb', :repo => repo
|
72
|
+
copy_from_repo 'app/views/devise/registrations/_thankyou.html.erb', :repo => repo
|
73
|
+
copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo
|
74
|
+
copy_from_repo 'app/views/devise/shared/_links.html.erb', :repo => repo
|
75
|
+
copy_from_repo 'app/views/home/index.html.erb', :repo => repo
|
76
|
+
copy_from_repo 'app/views/user_mailer/welcome_email.html.erb', :repo => repo
|
77
|
+
copy_from_repo 'app/views/user_mailer/welcome_email.text.erb', :repo => repo
|
78
|
+
copy_from_repo 'app/views/users/index.html.erb', :repo => repo
|
79
|
+
copy_from_repo 'public/thankyou.html', :repo => repo
|
80
|
+
|
81
|
+
# >-------------------------------[ Routes ]--------------------------------<
|
82
|
+
|
83
|
+
copy_from_repo 'config/routes.rb', :repo => repo
|
84
|
+
### CORRECT APPLICATION NAME ###
|
85
|
+
gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
|
86
|
+
|
87
|
+
# >-------------------------------[ Assets ]--------------------------------<
|
88
|
+
|
89
|
+
copy_from_repo 'app/assets/javascripts/application.js', :repo => repo
|
90
|
+
copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo
|
91
|
+
|
92
|
+
# >-------------------------------[ Cucumber ]--------------------------------<
|
93
|
+
say_wizard "copying Cucumber scenarios from the rails-prelaunch-signup examples"
|
94
|
+
copy_from_repo 'features/admin/send_invitations.feature', :repo => repo
|
95
|
+
copy_from_repo 'features/admin/view_progress.feature', :repo => repo
|
96
|
+
copy_from_repo 'features/visitors/request_invitation.feature', :repo => repo
|
97
|
+
copy_from_repo 'features/users/sign_in.feature', :repo => repo
|
98
|
+
copy_from_repo 'features/users/sign_up.feature', :repo => repo
|
99
|
+
copy_from_repo 'features/users/user_show.feature', :repo => repo
|
100
|
+
copy_from_repo 'features/step_definitions/admin_steps.rb', :repo => repo
|
101
|
+
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
|
102
|
+
copy_from_repo 'features/step_definitions/visitor_steps.rb', :repo => repo
|
103
|
+
copy_from_repo 'config/locales/devise.en.yml', :repo => repo
|
104
|
+
|
105
|
+
### GIT ###
|
106
|
+
git :add => '-A' if prefer :git, true
|
107
|
+
git :commit => '-qm "rails_apps_composer: prelaunch app"' if prefer :git, true
|
108
|
+
end # after_bundler
|
109
|
+
end # rails-prelaunch-signup
|
110
|
+
|
111
|
+
__END__
|
112
|
+
|
113
|
+
name: prelaunch
|
114
|
+
description: "Install a prelaunch-signup example application."
|
115
|
+
author: RailsApps
|
116
|
+
|
117
|
+
requires: [core]
|
118
|
+
run_after: [setup, gems, models, controllers, views, frontend, init]
|
119
|
+
category: apps
|