rails_apps_composer 1.5.1 → 1.5.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.
data/recipes/add_user.rb CHANGED
@@ -29,6 +29,13 @@ RUBY
29
29
  # insert 'rolify' method in 'app/models/users.rb'
30
30
  if recipes.include? 'mongoid'
31
31
  generate 'rolify:role Role User mongoid'
32
+ # correct the generation of rolify 3.1 with mongoid
33
+ # the call to `rolify` should be *after* the inclusion of mongoid
34
+ # (see https://github.com/EppO/rolify/issues/61)
35
+ # This isn't needed for rolify>=3.2.0.beta4, but should cause no harm
36
+ gsub_file 'app/models/user.rb',
37
+ /^\s*(rolify.*?)$\s*(include Mongoid::Document.*?)$/,
38
+ " \\2\n extend Rolify\n \\1\n"
32
39
  else
33
40
  generate 'rolify:role Role User'
34
41
  end
data/recipes/devise.rb CHANGED
@@ -22,11 +22,7 @@ end
22
22
 
23
23
  if config['authorization']
24
24
  gem 'cancan', '>= 1.6.7'
25
- if recipes.include? 'mongoid'
26
- gem 'rolify', '>= 3.2.0.beta4'
27
- else
28
- gem 'rolify', '>= 3.1.0'
29
- end
25
+ gem 'rolify', '>= 3.1.0'
30
26
  recipes << 'authorization'
31
27
  end
32
28
 
@@ -0,0 +1,581 @@
1
+ # Application template recipe for the rails_apps_composer. Check for a newer version here:
2
+ # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/prelaunch_signup.rb
3
+
4
+ @recipes = ["haml", "rspec", "cucumber", "action_mailer", "devise", "add_user",
5
+ "home_page", "seed_database", "users_page", "html5", "simple_form",
6
+ "cleanup", "extras", "git"]
7
+
8
+ # >-------------------------------[ Create an Initializer File ]--------------------------------<
9
+ create_file 'config/initializers/prelaunch-signup.rb' do <<-RUBY
10
+ # change to "true" (and restart) when you want visitors to sign up without an invitation
11
+ Rails.configuration.launched = false
12
+ RUBY
13
+ end
14
+
15
+ # >---------------------------------[ HAML ]----------------------------------<
16
+ gem 'haml', '>= 3.1.6'
17
+ gem 'haml-rails', '>= 0.3.4', :group => :development
18
+
19
+ # >---------------------------------[ RSpec ]---------------------------------<
20
+
21
+ gem 'rspec-rails', '>= 2.10.1', :group => [:development, :test]
22
+ gem 'factory_girl_rails', '>= 3.3.0', :group => [:development, :test]
23
+ # add a collection of RSpec matchers and Cucumber steps to make testing email easy
24
+ gem 'email_spec', '>= 1.2.1', :group => :test
25
+ create_file 'features/support/email_spec.rb' do <<-RUBY
26
+ require 'email_spec/cucumber'
27
+ RUBY
28
+ end
29
+
30
+ after_bundler do
31
+ say_wizard "RSpec recipe running 'after bundler'"
32
+ generate 'rspec:install'
33
+ generate 'email_spec:steps'
34
+ inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
35
+ inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
36
+ config.include(EmailSpec::Helpers)
37
+ config.include(EmailSpec::Matchers)
38
+ RUBY
39
+ end
40
+ say_wizard "Removing test folder (not needed for RSpec)"
41
+ run 'rm -rf test/'
42
+ inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
43
+
44
+ # don't generate RSpec tests for views and helpers
45
+ config.generators do |g|
46
+ g.view_specs false
47
+ g.helper_specs false
48
+ end
49
+
50
+ RUBY
51
+ end
52
+ if recipes.include? 'devise'
53
+ # add Devise test helpers
54
+ create_file 'spec/support/devise.rb' do
55
+ <<-RUBY
56
+ RSpec.configure do |config|
57
+ config.include Devise::TestHelpers, :type => :controller
58
+ end
59
+ RUBY
60
+ end
61
+ end
62
+ end
63
+ after_everything do
64
+ say_wizard "Copying RSpec files from the rails-prelaunch-signup example app"
65
+ begin
66
+ remove_file 'spec/factories/users.rb'
67
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/factories/users.rb', 'spec/factories/users.rb'
68
+ gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at"
69
+ remove_file 'spec/controllers/home_controller_spec.rb'
70
+ remove_file 'spec/controllers/users_controller_spec.rb'
71
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/controllers/home_controller_spec.rb', 'spec/controllers/home_controller_spec.rb'
72
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/controllers/users_controller_spec.rb', 'spec/controllers/users_controller_spec.rb'
73
+ remove_file 'spec/models/user_spec.rb'
74
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/models/user_spec.rb', 'spec/models/user_spec.rb'
75
+ rescue OpenURI::HTTPError
76
+ say_wizard "Unable to obtain RSpec example files from the repo"
77
+ end
78
+ remove_file 'spec/views/home/index.html.erb_spec.rb'
79
+ remove_file 'spec/views/home/index.html.haml_spec.rb'
80
+ remove_file 'spec/views/users/show.html.erb_spec.rb'
81
+ remove_file 'spec/views/users/show.html.haml_spec.rb'
82
+ remove_file 'spec/helpers/home_helper_spec.rb'
83
+ remove_file 'spec/helpers/users_helper_spec.rb'
84
+ end
85
+
86
+ # >-------------------------------[ Cucumber ]--------------------------------<
87
+ gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
88
+ gem 'capybara', '>= 1.1.2', :group => :test
89
+ gem 'database_cleaner', '>= 0.8.0', :group => :test
90
+ gem 'launchy', '>= 2.1.0', :group => :test
91
+
92
+ after_bundler do
93
+ say_wizard "Cucumber recipe running 'after bundler'"
94
+ generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' if recipes.include?('mongoid')}"
95
+ # make it easy to run Cucumber for single features without adding "--require features" to the command line
96
+ gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
97
+ end
98
+
99
+ after_bundler do
100
+ say_wizard "Copying Cucumber scenarios from the rails-prelaunch-signup example app"
101
+ begin
102
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/admin/send_invitations.feature', 'features/admin/send_invitations.feature'
103
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/admin/view_progress.feature', 'features/admin/view_progress.feature'
104
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/admin_steps.rb', 'features/step_definitions/admin_steps.rb'
105
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/email_steps.rb', 'features/step_definitions/email_steps.rb'
106
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/user_steps.rb', 'features/step_definitions/user_steps.rb'
107
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/visitor_steps.rb', 'features/step_definitions/visitor_steps.rb'
108
+ remove_file 'features/support/paths.rb'
109
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/support/paths.rb', 'features/support/paths.rb'
110
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_in.feature', 'features/users/sign_in.feature'
111
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_out.feature', 'features/users/sign_out.feature'
112
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_up.feature', 'features/users/sign_up.feature'
113
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/user_edit.feature', 'features/users/user_edit.feature'
114
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/user_show.feature', 'features/users/user_show.feature'
115
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/visitors/request_invitation.feature', 'features/visitors/request_invitation.feature'
116
+ # thank you page for testing registrations
117
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/public/thankyou.html', 'public/thankyou.html'
118
+ rescue OpenURI::HTTPError
119
+ say_wizard "Unable to obtain Cucumber example files from the repo"
120
+ end
121
+ end
122
+
123
+ # >-----------------------------[ ActionMailer ]------------------------------<
124
+ case config['mailer']
125
+ when 'smtp'
126
+ recipes << 'smtp'
127
+ when 'gmail'
128
+ recipes << 'gmail'
129
+ when 'sendgrid'
130
+ gem 'sendgrid'
131
+ recipes << 'sendgrid'
132
+ when 'mandrill'
133
+ gem 'hominid'
134
+ recipes << 'mandrill'
135
+ end
136
+
137
+ after_bundler do
138
+ ### modifying environment configuration files for ActionMailer
139
+ say_wizard "ActionMailer recipe running 'after bundler'"
140
+ ### development environment
141
+ gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
142
+ gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
143
+ <<-RUBY
144
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
145
+ config.action_mailer.delivery_method = :smtp
146
+ # change to true to allow email to be sent during development
147
+ config.action_mailer.perform_deliveries = false
148
+ config.action_mailer.raise_delivery_errors = true
149
+ config.action_mailer.default :charset => "utf-8"
150
+ RUBY
151
+ end
152
+ ### test environment
153
+ inject_into_file 'config/environments/test.rb', :before => "\nend" do
154
+ <<-RUBY
155
+ \n
156
+ # ActionMailer Config
157
+ config.action_mailer.default_url_options = { :host => 'example.com' }
158
+ RUBY
159
+ end
160
+ ### production environment
161
+ gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do
162
+ <<-RUBY
163
+ config.active_support.deprecation = :notify
164
+
165
+ config.action_mailer.default_url_options = { :host => 'example.com' }
166
+ # ActionMailer Config
167
+ # Setup for production - deliveries, no errors raised
168
+ config.action_mailer.delivery_method = :smtp
169
+ config.action_mailer.perform_deliveries = true
170
+ config.action_mailer.raise_delivery_errors = false
171
+ config.action_mailer.default :charset => "utf-8"
172
+ RUBY
173
+ end
174
+ ### modifying environment configuration files to send email using a GMail account
175
+ if recipes.include? 'gmail'
176
+ gmail_configuration_text = <<-TEXT
177
+ \n
178
+ config.action_mailer.smtp_settings = {
179
+ address: "smtp.gmail.com",
180
+ port: 587,
181
+ domain: "example.com",
182
+ authentication: "plain",
183
+ enable_starttls_auto: true,
184
+ user_name: ENV["GMAIL_USERNAME"],
185
+ password: ENV["GMAIL_PASSWORD"]
186
+ }
187
+ TEXT
188
+ say_wizard gmail_configuration_text
189
+ inject_into_file 'config/environments/development.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
190
+ inject_into_file 'config/environments/production.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
191
+ end
192
+ ### modifying environment configuration files to send email using a SendGrid account
193
+ if recipes.include? 'sendgrid'
194
+ sendgrid_configuration_text = <<-TEXT
195
+ \n
196
+ config.action_mailer.smtp_settings = {
197
+ address: "smtp.sendgrid.net",
198
+ port: 25,
199
+ domain: "example.com",
200
+ authentication: "plain",
201
+ user_name: ENV["SENDGRID_USERNAME"],
202
+ password: ENV["SENDGRID_PASSWORD"]
203
+ }
204
+ TEXT
205
+ say_wizard gmail_configuration_text
206
+ inject_into_file 'config/environments/development.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
207
+ inject_into_file 'config/environments/production.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
208
+ end
209
+ ### modifying environment configuration files to send email using a Mandrill account
210
+ if recipes.include? 'mandrill'
211
+ mandrill_configuration_text = <<-TEXT
212
+ \n
213
+ config.action_mailer.smtp_settings = {
214
+ :address => "smtp.mandrillapp.com",
215
+ :port => 25,
216
+ :user_name => ENV["MANDRILL_USERNAME"],
217
+ :password => ENV["MANDRILL_API_KEY"]
218
+ }
219
+ TEXT
220
+ say_wizard gmail_configuration_text
221
+ inject_into_file 'config/environments/development.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
222
+ inject_into_file 'config/environments/production.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
223
+ end
224
+ end
225
+
226
+ # >--------------------------------[ Devise ]---------------------------------<
227
+ gem 'devise', '>= 2.1.0'
228
+ gem 'devise_invitable', '>= 1.0.2'
229
+ recipes << 'devise-confirmable'
230
+ recipes << 'devise-invitable'
231
+ gem 'cancan', '>= 1.6.7'
232
+ gem 'rolify', '>= 3.1.0'
233
+ recipes << 'authorization'
234
+
235
+ after_bundler do
236
+ say_wizard "Devise recipe running 'after bundler'"
237
+ # Run the Devise generator
238
+ generate 'devise:install' unless recipes.include? 'datamapper'
239
+ generate 'devise_invitable:install' if recipes.include? 'devise-invitable'
240
+ # Prevent logging of password_confirmation
241
+ gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
242
+ if recipes.include? 'cucumber'
243
+ # Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
244
+ # (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
245
+ gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
246
+ end
247
+ if recipes.include? 'authorization'
248
+ inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
249
+ rescue_from CanCan::AccessDenied do |exception|
250
+ redirect_to root_path, :alert => exception.message
251
+ end
252
+ RUBY
253
+ end
254
+ end
255
+ end
256
+
257
+ # >--------------------------------[ AddUser ]--------------------------------<
258
+ after_bundler do
259
+ say_wizard "AddUser recipe running 'after bundler'"
260
+ if recipes.include? 'devise'
261
+ # Generate models and routes for a User
262
+ generate 'devise user'
263
+ if recipes.include? 'authorization'
264
+ # create'app/models/ability.rb'
265
+ generate 'cancan:ability'
266
+ # create 'app/models/role.rb'
267
+ # create 'config/initializers/rolify.rb'
268
+ # create 'db/migrate/...rolify_create_roles.rb'
269
+ # insert 'rolify' method in 'app/models/users.rb'
270
+ generate 'rolify:role Role User'
271
+ end
272
+ # Add a 'name' attribute to the User model
273
+ # Devise created a Users database, we'll modify it
274
+ generate 'migration AddNameToUsers name:string'
275
+ if recipes.include? 'devise-confirmable'
276
+ generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
277
+ end
278
+ # Devise created a Users model, we'll replace it
279
+ remove_file 'app/models/user.rb'
280
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/models/user.rb', 'app/models/user.rb'
281
+ # copy Haml versions of modified Devise views (plus a partial for the 'thank you' message)
282
+ remove_file 'app/views/devise/shared/_links.html.haml'
283
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/shared/_links.html.haml', 'app/views/devise/shared/_links.html.haml'
284
+ remove_file 'app/views/devise/registrations/edit.html.haml'
285
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/edit.html.haml', 'app/views/devise/registrations/edit.html.haml'
286
+ remove_file 'app/views/devise/registrations/new.html.haml'
287
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/new.html.haml', 'app/views/devise/registrations/new.html.haml'
288
+ remove_file 'app/views/devise/registrations/_thankyou.html.haml'
289
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/_thankyou.html.haml', 'app/views/devise/registrations/_thankyou.html.haml'
290
+ remove_file 'app/views/devise/confirmations/show.html.haml'
291
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/confirmations/show.html.haml', 'app/views/devise/confirmations/show.html.haml'
292
+ end
293
+ end
294
+
295
+ # >-------------------------------[ HomePage ]--------------------------------<
296
+ after_bundler do
297
+ say_wizard "HomePage recipe running 'after bundler'"
298
+ # remove the default home page
299
+ remove_file 'public/index.html'
300
+ # create a home controller and view
301
+ generate(:controller, "home index")
302
+ # set up a simple home page (with placeholder content)
303
+ if recipes.include? 'haml'
304
+ remove_file 'app/views/home/index.html.haml'
305
+ create_file 'app/views/home/index.html.haml' do
306
+ <<-'HAML'
307
+ %h3 Welcome
308
+ HAML
309
+ end
310
+ end
311
+ end
312
+
313
+ # >-----------------------------[ SeedDatabase ]------------------------------<
314
+ after_bundler do
315
+ say_wizard "SeedDatabase recipe running 'after bundler'"
316
+ if recipes.include? 'devise'
317
+ if recipes.include? 'devise-confirmable'
318
+ append_file 'db/seeds.rb' do <<-FILE
319
+ puts 'SETTING UP DEFAULT USER LOGIN'
320
+ user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
321
+ puts 'New user created: ' << user.name
322
+ user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
323
+ puts 'New user created: ' << user2.name
324
+ FILE
325
+ end
326
+ end
327
+ if recipes.include? 'authorization'
328
+ append_file 'db/seeds.rb' do <<-FILE
329
+ user.add_role :admin
330
+ FILE
331
+ end
332
+ end
333
+ end
334
+ end
335
+ after_everything do
336
+ say_wizard "applying migrations and seeding the database"
337
+ if recipes.include? 'devise-invitable'
338
+ run 'bundle exec rake db:migrate'
339
+ generate 'devise_invitable user'
340
+ end
341
+ run 'bundle exec rake db:migrate'
342
+ run 'bundle exec rake db:test:prepare'
343
+ run 'bundle exec rake db:seed'
344
+ end
345
+
346
+ # >-------------------------------[ UsersPage ]-------------------------------<
347
+ gem 'google_visualr', '>= 2.1.2'
348
+ gem 'jquery-datatables-rails', '>= 1.10.0'
349
+ after_bundler do
350
+ say_wizard "UsersPage recipe running 'after bundler'"
351
+ #----------------------------------------------------------------------------
352
+ # Create a users controller
353
+ #----------------------------------------------------------------------------
354
+ generate(:controller, "users show index")
355
+ remove_file 'app/controllers/users_controller.rb'
356
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/users_controller.rb', 'app/controllers/users_controller.rb'
357
+ #----------------------------------------------------------------------------
358
+ # Limit access to the users#index page
359
+ #----------------------------------------------------------------------------
360
+ inject_into_file 'app/models/ability.rb', :after => "def initialize(user)\n" do <<-RUBY
361
+ user ||= User.new # guest user (not logged in)
362
+ if user.has_role? :admin
363
+ can :manage, :all
364
+ end
365
+ RUBY
366
+ end
367
+ #----------------------------------------------------------------------------
368
+ # Create a users index page
369
+ #----------------------------------------------------------------------------
370
+ remove_file 'app/views/users/index.html.haml'
371
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/users/index.html.haml', 'app/views/users/index.html.haml'
372
+ #----------------------------------------------------------------------------
373
+ # Create a users show page
374
+ #----------------------------------------------------------------------------
375
+ remove_file 'app/views/users/show.html.haml'
376
+ create_file 'app/views/users/show.html.haml' do <<-'HAML'
377
+ %p
378
+ User: #{@user.name}
379
+ %p
380
+ Email: #{@user.email if @user.email}
381
+ HAML
382
+ end
383
+ #----------------------------------------------------------------------------
384
+ # Create a home page containing links to user show pages
385
+ # (clobbers code from the home_page_users recipe)
386
+ #----------------------------------------------------------------------------
387
+ # set up the controller
388
+ remove_file 'app/controllers/home_controller.rb'
389
+ create_file 'app/controllers/home_controller.rb' do
390
+ <<-RUBY
391
+ class HomeController < ApplicationController
392
+ end
393
+ RUBY
394
+ end
395
+ # modify the home page
396
+ remove_file 'app/views/home/index.html.haml'
397
+ create_file 'app/views/home/index.html.haml' do
398
+ <<-'HAML'
399
+ %h3 Welcome
400
+ HAML
401
+ end
402
+ end
403
+
404
+ # >---------------------------------[ html5 ]---------------------------------<
405
+ gem 'bootstrap-sass', '>= 2.0.3'
406
+ recipes << 'bootstrap'
407
+ after_bundler do
408
+ say_wizard "HTML5 recipe running 'after bundler'"
409
+ # add a humans.txt file
410
+ get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/humans.txt', 'public/humans.txt'
411
+ # install a front-end framework for HTML5 and CSS3
412
+ remove_file 'app/assets/stylesheets/application.css'
413
+ remove_file 'app/views/layouts/application.html.erb'
414
+ remove_file 'app/views/layouts/application.html.haml'
415
+ # Haml version of a complex application layout using Twitter Bootstrap
416
+ get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
417
+ get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
418
+ # complex css styles using Twitter Bootstrap
419
+ remove_file 'app/assets/stylesheets/application.css.scss'
420
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'
421
+ # get an appropriate navigation partial
422
+ get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
423
+ gsub_file 'app/views/layouts/application.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
424
+ gsub_file 'app/views/layouts/_navigation.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
425
+ create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY
426
+ // Set the correct sprite paths
427
+ $iconSpritePath: asset-url('glyphicons-halflings.png', image);
428
+ $iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
429
+ @import "bootstrap";
430
+ body { padding-top: 60px; }
431
+ @import "bootstrap-responsive";
432
+ RUBY
433
+ end
434
+
435
+ # >------------------------------[ SimpleForm ]-------------------------------<
436
+ gem 'simple_form'
437
+ recipes << 'simple_form'
438
+ recipes << 'simple_form_bootstrap'
439
+ after_bundler do
440
+ say_wizard "Simple form recipe running 'after bundler'"
441
+ generate 'simple_form:install --bootstrap'
442
+ end
443
+
444
+ # >------------------------------[ JavaScript ]-------------------------------<
445
+ after_bundler do
446
+ remove_file 'app/assets/javascripts/application.js'
447
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/javascripts/application.js', 'app/assets/javascripts/application.js'
448
+ remove_file 'app/assets/javascripts/users.js.coffee'
449
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/javascripts/users.js.coffee', 'app/assets/javascripts/users.js.coffee'
450
+ end
451
+
452
+ # >------------------------------[ MailChimp ]-------------------------------<
453
+ # the 'app/models/user.rb' file contains methods to support MailChimp; remove and replace them if we don't want MailChimp
454
+ if config['mailchimp']
455
+ gem 'hominid'
456
+ else
457
+ after_bundler do
458
+ # drop the MailChimp methods and add a UserMailer
459
+ gsub_file 'app/models/user.rb', /after_create :add_user_to_mailchimp unless Rails.env.test\?/, 'after_create :send_welcome_email'
460
+ gsub_file 'app/models/user.rb', /before_destroy :remove_user_from_mailchimp unless Rails.env.test\?\n/, ''
461
+ inject_into_file 'app/models/user.rb', :after => "private\n" do
462
+ <<-RUBY
463
+ \n
464
+ def send_welcome_email
465
+ unless self.email.include?('@example.com') && Rails.env != 'test'
466
+ UserMailer.welcome_email(self).deliver
467
+ end
468
+ end
469
+ RUBY
470
+ end
471
+ generate 'mailer UserMailer'
472
+ remove_file 'spec/mailers/user_mailer_spec.rb'
473
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/mailers/user_mailer_spec.rb', 'spec/mailers/user_mailer_spec.rb'
474
+ remove_file 'app/mailers/user_mailer.rb'
475
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/mailers/user_mailer.rb', 'app/mailers/user_mailer.rb'
476
+ if recipes.include? 'mandrill'
477
+ inject_into_file 'app/mailers/user_mailer.rb', :after => "mail(:to => user.email, :subject => \"Invitation Request Received\")\n" do <<-RUBY
478
+ headers['X-MC-Track'] = "opens, clicks"
479
+ headers['X-MC-GoogleAnalytics'] = "example.com"
480
+ headers['X-MC-Tags'] = "welcome"
481
+ RUBY
482
+ end
483
+ end
484
+ remove_file 'app/views/user_mailer/welcome_email.html.erb'
485
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/user_mailer/welcome_email.html.erb', 'app/views/user_mailer/welcome_email.html.erb'
486
+ remove_file 'app/views/user_mailer/welcome_email.text.erb'
487
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/user_mailer/welcome_email.text.erb', 'app/views/user_mailer/welcome_email.text.erb'
488
+ end
489
+ end
490
+
491
+ # >------------------------------[ Devise Email ]-------------------------------<
492
+ after_bundler do
493
+ remove_file 'app/views/devise/mailer/confirmation_instructions.html.erb'
494
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/mailer/confirmation_instructions.html.erb', 'app/views/devise/mailer/confirmation_instructions.html.erb'
495
+ end
496
+
497
+ # >------------------------------[ Controllers ]-------------------------------<
498
+ after_bundler do
499
+ remove_file 'app/controllers/registrations_controller.rb'
500
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/registrations_controller.rb', 'app/controllers/registrations_controller.rb'
501
+ remove_file 'app/controllers/confirmations_controller.rb'
502
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/confirmations_controller.rb', 'app/controllers/confirmations_controller.rb'
503
+ end
504
+
505
+ # >------------------------------[ Routes ]-------------------------------<
506
+ after_bundler do
507
+ remove_file 'config/routes.rb'
508
+ get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/config/routes.rb', 'config/routes.rb'
509
+ gsub_file 'config/routes.rb', /RailsPrelaunchSignup/, app_const_base
510
+ end
511
+
512
+ # >------------------------------[ Messages ]-------------------------------<
513
+ after_bundler do
514
+ gsub_file 'config/locales/devise.en.yml', /'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'/, "'Your invitation request has been received. You will receive an invitation when we launch.'"
515
+ gsub_file 'config/locales/devise.en.yml', /'You have to confirm your account before continuing.'/, "'Your account is not active.'"
516
+ end
517
+
518
+ # >--------------------------------[ Cleanup ]--------------------------------<
519
+ after_bundler do
520
+ say_wizard "Cleanup recipe running 'after bundler'"
521
+ # remove unnecessary files
522
+ %w{
523
+ README
524
+ doc/README_FOR_APP
525
+ public/index.html
526
+ app/assets/images/rails.png
527
+ }.each { |file| remove_file file }
528
+ # add placeholder READMEs
529
+ get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.txt", "README"
530
+ get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.textile", "README.textile"
531
+ gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
532
+ gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
533
+ # remove commented lines and multiple blank lines from Gemfile
534
+ # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
535
+ gsub_file 'Gemfile', /#.*\n/, "\n"
536
+ gsub_file 'Gemfile', /\n^\s*\n/, "\n"
537
+ # remove commented lines and multiple blank lines from config/routes.rb
538
+ gsub_file 'config/routes.rb', / #.*\n/, "\n"
539
+ gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
540
+ end
541
+
542
+ # >--------------------------------[ Extras ]---------------------------------<
543
+ if config['jsruntime']
544
+ say_wizard "Adding 'therubyracer' JavaScript runtime gem"
545
+ # maybe it was already added by the html5 recipe for bootstrap_less?
546
+ unless recipes.include? 'jsruntime'
547
+ gem 'therubyracer', :group => :assets, :platform => :ruby
548
+ end
549
+ end
550
+
551
+ # >----------------------------------[ Git ]----------------------------------<
552
+ after_everything do
553
+ say_wizard "Git recipe running 'after everything'"
554
+ # Git should ignore some files
555
+ remove_file '.gitignore'
556
+ get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/gitignore.txt", ".gitignore"
557
+ # Initialize new Git repo
558
+ git :init
559
+ git :add => '.'
560
+ git :commit => "-aqm 'new Rails app generated by Rails Apps Composer gem'"
561
+ end
562
+
563
+ __END__
564
+
565
+ name: PrelaunchSignup
566
+ description: "Generates a Prelaunch Signup App"
567
+ author: RailsApps
568
+
569
+ category: other
570
+
571
+ config:
572
+ - mailer:
573
+ type: multiple_choice
574
+ prompt: "How will you send email?"
575
+ choices: [["SMTP account", smtp], ["Gmail account", gmail], ["SendGrid account", sendgrid], ["Mandrill by MailChimp account", mandrill]]
576
+ - mailchimp:
577
+ type: boolean
578
+ prompt: Use MailChimp to send news and welcome messages?
579
+ - jsruntime:
580
+ type: boolean
581
+ prompt: Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?
@@ -1,23 +1,8 @@
1
1
  # Application template recipe for the rails_apps_composer. Check for a newer version here:
2
2
  # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/seed_database.rb
3
3
 
4
-
5
4
  after_bundler do
6
-
7
5
  say_wizard "SeedDatabase recipe running 'after bundler'"
8
-
9
- run 'bundle exec rake db:migrate' unless recipes.include? 'mongoid'
10
-
11
- if recipes.include? 'devise-invitable'
12
- generate 'devise_invitable user'
13
- unless recipes.include? 'mongoid'
14
- run 'bundle exec rake db:migrate'
15
- end
16
- end
17
-
18
- # clone the schema changes to the test database
19
- run 'bundle exec rake db:test:prepare' unless recipes.include? 'mongoid'
20
-
21
6
  if recipes.include? 'mongoid'
22
7
  append_file 'db/seeds.rb' do <<-FILE
23
8
  puts 'EMPTY THE MONGODB DATABASE'
@@ -25,7 +10,6 @@ Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
25
10
  FILE
26
11
  end
27
12
  end
28
-
29
13
  if recipes.include? 'devise'
30
14
  if recipes.include? 'devise-confirmable'
31
15
  append_file 'db/seeds.rb' do <<-FILE
@@ -53,17 +37,22 @@ FILE
53
37
  end
54
38
  end
55
39
  end
56
-
57
-
58
-
59
40
  end
60
41
 
61
42
  after_everything do
62
-
63
- say_wizard "seeding the database"
43
+ if recipes.include? 'devise-invitable'
44
+ run 'bundle exec rake db:migrate'
45
+ generate 'devise_invitable user'
46
+ end
47
+ unless recipes.include? 'mongoid'
48
+ say_wizard "applying migrations and seeding the database"
49
+ run 'bundle exec rake db:migrate'
50
+ run 'bundle exec rake db:test:prepare'
51
+ else
52
+ say_wizard "creating indexes and seeding the database"
53
+ run 'rake db:mongoid:create_indexes'
54
+ end
64
55
  run 'bundle exec rake db:seed'
65
- run 'rake db:mongoid:create_indexes' if recipes.include? 'mongoid'
66
-
67
56
  end
68
57
 
69
58
  __END__
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RailsWizard
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_apps_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -184,6 +184,7 @@ files:
184
184
  - recipes/omniauth.rb
185
185
  - recipes/omniauth_email.rb
186
186
  - recipes/paperclip.rb
187
+ - recipes/prelaunch_signup.rb
187
188
  - recipes/rails_admin.rb
188
189
  - recipes/redis.rb
189
190
  - recipes/responders.rb
@@ -225,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
226
  version: '0'
226
227
  segments:
227
228
  - 0
228
- hash: 4139162252636043341
229
+ hash: -3880127851018975913
229
230
  required_rubygems_version: !ruby/object:Gem::Requirement
230
231
  none: false
231
232
  requirements:
@@ -234,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
235
  version: '0'
235
236
  segments:
236
237
  - 0
237
- hash: 4139162252636043341
238
+ hash: -3880127851018975913
238
239
  requirements: []
239
240
  rubyforge_project: rails_apps_composer
240
241
  rubygems_version: 1.8.24