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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/README.textile +433 -0
  3. data/bin/intersect_rails_composer +7 -0
  4. data/lib/rails_wizard/command.rb +204 -0
  5. data/lib/rails_wizard/config.rb +88 -0
  6. data/lib/rails_wizard/diagnostics.rb +68 -0
  7. data/lib/rails_wizard/recipe.rb +114 -0
  8. data/lib/rails_wizard/recipes.rb +56 -0
  9. data/lib/rails_wizard/template.rb +111 -0
  10. data/lib/rails_wizard.rb +7 -0
  11. data/recipes/apps4.rb +150 -0
  12. data/recipes/controllers.rb +75 -0
  13. data/recipes/core.rb +14 -0
  14. data/recipes/email.rb +110 -0
  15. data/recipes/example.rb +70 -0
  16. data/recipes/extras.rb +187 -0
  17. data/recipes/frontend.rb +45 -0
  18. data/recipes/gems.rb +277 -0
  19. data/recipes/git.rb +20 -0
  20. data/recipes/init.rb +136 -0
  21. data/recipes/models.rb +109 -0
  22. data/recipes/prelaunch.rb +119 -0
  23. data/recipes/railsapps.rb +277 -0
  24. data/recipes/readme.rb +85 -0
  25. data/recipes/routes.rb +45 -0
  26. data/recipes/saas.rb +218 -0
  27. data/recipes/setup.rb +134 -0
  28. data/recipes/testing.rb +276 -0
  29. data/recipes/views.rb +57 -0
  30. data/spec/rails_wizard/config_spec.rb +108 -0
  31. data/spec/rails_wizard/recipe_spec.rb +115 -0
  32. data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
  33. data/spec/rails_wizard/recipes_spec.rb +41 -0
  34. data/spec/rails_wizard/template_spec.rb +92 -0
  35. data/spec/spec_helper.rb +11 -0
  36. data/spec/support/rails_directory.rb +17 -0
  37. data/spec/support/template_runner.rb +28 -0
  38. data/spec/test_recipes/test_recipe_in_file.rb +9 -0
  39. data/templates/helpers.erb +135 -0
  40. data/templates/layout.erb +232 -0
  41. data/templates/recipe.erb +13 -0
  42. data/version.rb +3 -0
  43. metadata +210 -0
@@ -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/railsapps.rb
3
+
4
+ raise if (defined? defaults) || (defined? preferences) # Shouldn't happen.
5
+ if options[:verbose]
6
+ print "\nrecipes: ";p recipes
7
+ print "\ngems: " ;p gems
8
+ print "\nprefs: " ;p prefs
9
+ print "\nconfig: " ;p config
10
+ end
11
+
12
+ case Rails::VERSION::MAJOR.to_s
13
+ when "3"
14
+ prefs[:railsapps] = multiple_choice "Install an example application for Rails 3.2?",
15
+ [["I want to build my own application", "none"],
16
+ ["membership/subscription/saas", "saas"],
17
+ ["rails-prelaunch-signup", "rails-prelaunch-signup"],
18
+ ["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"],
19
+ ["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"],
20
+ ["rails3-mongoid-devise", "rails3-mongoid-devise"],
21
+ ["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
22
+ ["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps
23
+ when "4"
24
+ prefs[:apps4] = multiple_choice "Install an example application for Rails 4.0?",
25
+ [["Build a RailsApps starter application", "railsapps"],
26
+ ["Build a contributed application", "contributed_app"],
27
+ ["I want to build my own application", "none"]] unless prefs.has_key? :apps4
28
+ case prefs[:apps4]
29
+ when 'railsapps'
30
+ prefs[:apps4] = multiple_choice "Starter apps for Rails 4.0. More to come.",
31
+ [["learn-rails", "learn-rails"],
32
+ ["rails-bootstrap", "rails-bootstrap"]]
33
+ when 'contributed_app'
34
+ prefs[:apps4] = multiple_choice "No contributed applications are available.",
35
+ [["continue", "none"]]
36
+ end
37
+ end
38
+
39
+ case prefs[:apps4]
40
+ when 'simple-test'
41
+ prefs[:dev_webserver] = 'webrick'
42
+ prefs[:prod_webserver] = 'same'
43
+ prefs[:templates] = 'erb'
44
+ prefs[:git] = false
45
+ prefs[:github] = false
46
+ prefs[:database] = 'sqlite'
47
+ prefs[:unit_test] = false
48
+ prefs[:integration] = false
49
+ prefs[:fixtures] = false
50
+ prefs[:frontend] = false
51
+ prefs[:email] = false
52
+ prefs[:authentication] = false
53
+ prefs[:devise_modules] = false
54
+ prefs[:authorization] = false
55
+ prefs[:starter_app] = false
56
+ prefs[:form_builder] = false
57
+ prefs[:quiet_assets] = false
58
+ prefs[:local_env_file] = false
59
+ prefs[:better_errors] = false
60
+ prefs[:ban_spiders] = false
61
+ prefs[:continuous_testing] = false
62
+ when 'learn-rails'
63
+ prefs[:git] = true
64
+ prefs[:database] = 'default'
65
+ prefs[:unit_test] = false
66
+ prefs[:integration] = false
67
+ prefs[:fixtures] = false
68
+ prefs[:frontend] = 'foundation4'
69
+ prefs[:email] = 'gmail'
70
+ prefs[:authentication] = false
71
+ prefs[:devise_modules] = false
72
+ prefs[:authorization] = false
73
+ prefs[:starter_app] = false
74
+ prefs[:form_builder] = 'simple_form'
75
+ prefs[:quiet_assets] = true
76
+ prefs[:local_env_file] = true
77
+ prefs[:better_errors] = true
78
+ when 'rails-bootstrap'
79
+ prefs[:git] = true
80
+ prefs[:database] = 'default'
81
+ prefs[:unit_test] = false
82
+ prefs[:integration] = false
83
+ prefs[:fixtures] = false
84
+ prefs[:frontend] = 'bootstrap2'
85
+ prefs[:email] = 'none'
86
+ prefs[:authentication] = false
87
+ prefs[:devise_modules] = false
88
+ prefs[:authorization] = false
89
+ prefs[:starter_app] = false
90
+ prefs[:form_builder] = 'simple_form'
91
+ prefs[:quiet_assets] = true
92
+ prefs[:local_env_file] = true
93
+ prefs[:better_errors] = true
94
+ end
95
+
96
+ case prefs[:railsapps]
97
+ when 'saas'
98
+ prefs[:railsapps] = multiple_choice "Billing with Stripe or Recurly?",
99
+ [["Stripe", "rails-stripe-membership-saas"],
100
+ ["Recurly", "rails-recurly-subscription-saas"]]
101
+ end
102
+
103
+ case prefs[:railsapps]
104
+ when 'rails-stripe-membership-saas'
105
+ prefs[:git] = true
106
+ prefs[:database] = 'sqlite'
107
+ prefs[:unit_test] = 'rspec'
108
+ prefs[:integration] = 'cucumber'
109
+ prefs[:fixtures] = 'factory_girl'
110
+ prefs[:frontend] = 'bootstrap2'
111
+ prefs[:email] = 'gmail'
112
+ prefs[:authentication] = 'devise'
113
+ prefs[:devise_modules] = 'default'
114
+ prefs[:authorization] = 'cancan'
115
+ prefs[:starter_app] = 'admin_app'
116
+ prefs[:form_builder] = 'simple_form'
117
+ prefs[:quiet_assets] = true
118
+ prefs[:local_env_file] = true
119
+ prefs[:better_errors] = true
120
+ when 'rails-recurly-subscription-saas'
121
+ prefs[:git] = true
122
+ prefs[:database] = 'sqlite'
123
+ prefs[:unit_test] = 'rspec'
124
+ prefs[:integration] = 'cucumber'
125
+ prefs[:fixtures] = 'factory_girl'
126
+ prefs[:frontend] = 'bootstrap2'
127
+ prefs[:email] = 'gmail'
128
+ prefs[:authentication] = 'devise'
129
+ prefs[:devise_modules] = 'default'
130
+ prefs[:authorization] = 'cancan'
131
+ prefs[:starter_app] = 'admin_app'
132
+ prefs[:form_builder] = 'simple_form'
133
+ prefs[:quiet_assets] = true
134
+ prefs[:local_env_file] = true
135
+ prefs[:better_errors] = true
136
+ when 'rails-prelaunch-signup'
137
+ prefs[:git] = true
138
+ prefs[:database] = 'sqlite'
139
+ prefs[:unit_test] = 'rspec'
140
+ prefs[:integration] = 'cucumber'
141
+ prefs[:fixtures] = 'factory_girl'
142
+ prefs[:frontend] = 'bootstrap2'
143
+ prefs[:email] = 'mandrill'
144
+ prefs[:authentication] = 'devise'
145
+ prefs[:devise_modules] = 'confirmable'
146
+ prefs[:authorization] = 'cancan'
147
+ prefs[:starter_app] = 'admin_app'
148
+ prefs[:form_builder] = 'simple_form'
149
+ prefs[:quiet_assets] = true
150
+ prefs[:local_env_file] = true
151
+ prefs[:better_errors] = true
152
+ if prefer :git, true
153
+ prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?",
154
+ [["wip (work-in-progress)", "wip"],
155
+ ["master", "master"],
156
+ ["prelaunch", "prelaunch"],
157
+ ["staging", "staging"]] unless prefs.has_key? :prelaunch_branch
158
+
159
+ prefs[:main_branch] = unless 'master' == prefs[:prelaunch_branch]
160
+ 'master'
161
+ else
162
+ multiple_choice "Git branch for the main app?",
163
+ [["None", "none"],
164
+ ["wip (work-in-progress)", "wip"],
165
+ ["edge", "edge"]]
166
+ end unless prefs.has_key? :main_branch
167
+ end
168
+ when 'rails3-bootstrap-devise-cancan'
169
+ prefs[:git] = true
170
+ prefs[:database] = 'sqlite'
171
+ prefs[:unit_test] = 'rspec'
172
+ prefs[:integration] = 'cucumber'
173
+ prefs[:fixtures] = 'factory_girl'
174
+ prefs[:frontend] = 'bootstrap2'
175
+ prefs[:email] = 'gmail'
176
+ prefs[:authentication] = 'devise'
177
+ prefs[:devise_modules] = 'default'
178
+ prefs[:authorization] = 'cancan'
179
+ prefs[:starter_app] = 'admin_app'
180
+ prefs[:form_builder] = 'simple_form'
181
+ prefs[:quiet_assets] = true
182
+ prefs[:local_env_file] = true
183
+ prefs[:better_errors] = true
184
+ when 'rails3-devise-rspec-cucumber'
185
+ prefs[:git] = true
186
+ prefs[:database] = 'sqlite'
187
+ prefs[:unit_test] = 'rspec'
188
+ prefs[:integration] = 'cucumber'
189
+ prefs[:fixtures] = 'factory_girl'
190
+ prefs[:frontend] = 'none'
191
+ prefs[:email] = 'gmail'
192
+ prefs[:authentication] = 'devise'
193
+ prefs[:devise_modules] = 'default'
194
+ prefs[:authorization] = 'none'
195
+ prefs[:starter_app] = 'users_app'
196
+ prefs[:form_builder] = 'none'
197
+ prefs[:quiet_assets] = true
198
+ prefs[:local_env_file] = true
199
+ prefs[:better_errors] = true
200
+ when 'rails3-devise-rspec-cucumber-fabrication'
201
+ prefs[:git] = true
202
+ prefs[:database] = 'sqlite'
203
+ prefs[:unit_test] = 'rspec'
204
+ prefs[:integration] = 'cucumber'
205
+ prefs[:fixtures] = 'fabrication'
206
+ prefs[:frontend] = 'none'
207
+ prefs[:email] = 'gmail'
208
+ prefs[:authentication] = 'devise'
209
+ prefs[:devise_modules] = 'default'
210
+ prefs[:authorization] = 'none'
211
+ prefs[:starter_app] = 'users_app'
212
+ prefs[:form_builder] = 'none'
213
+ prefs[:quiet_assets] = true
214
+ prefs[:local_env_file] = true
215
+ prefs[:better_errors] = true
216
+ when 'rails3-mongoid-devise'
217
+ prefs[:git] = true
218
+ prefs[:database] = 'mongodb'
219
+ prefs[:orm] = 'mongoid'
220
+ prefs[:unit_test] = 'rspec'
221
+ prefs[:integration] = 'cucumber'
222
+ prefs[:fixtures] = 'factory_girl'
223
+ prefs[:frontend] = 'none'
224
+ prefs[:email] = 'gmail'
225
+ prefs[:authentication] = 'devise'
226
+ prefs[:devise_modules] = 'default'
227
+ prefs[:authorization] = 'none'
228
+ prefs[:starter_app] = 'users_app'
229
+ prefs[:form_builder] = 'none'
230
+ prefs[:quiet_assets] = true
231
+ prefs[:local_env_file] = true
232
+ prefs[:better_errors] = true
233
+ when 'rails3-mongoid-omniauth'
234
+ prefs[:git] = true
235
+ prefs[:database] = 'mongodb'
236
+ prefs[:orm] = 'mongoid'
237
+ prefs[:unit_test] = 'rspec'
238
+ prefs[:integration] = 'cucumber'
239
+ prefs[:fixtures] = 'factory_girl'
240
+ prefs[:frontend] = 'none'
241
+ prefs[:email] = 'none'
242
+ prefs[:authentication] = 'omniauth'
243
+ prefs[:omniauth_provider] = 'twitter'
244
+ prefs[:authorization] = 'none'
245
+ prefs[:starter_app] = 'users_app'
246
+ prefs[:form_builder] = 'none'
247
+ prefs[:quiet_assets] = true
248
+ prefs[:local_env_file] = true
249
+ prefs[:better_errors] = true
250
+ when 'rails3-subdomains'
251
+ prefs[:git] = true
252
+ prefs[:database] = 'mongodb'
253
+ prefs[:orm] = 'mongoid'
254
+ prefs[:unit_test] = 'rspec'
255
+ prefs[:integration] = 'cucumber'
256
+ prefs[:fixtures] = 'factory_girl'
257
+ prefs[:frontend] = 'none'
258
+ prefs[:email] = 'gmail'
259
+ prefs[:authentication] = 'devise'
260
+ prefs[:devise_modules] = 'default'
261
+ prefs[:authorization] = 'none'
262
+ prefs[:starter_app] = 'subdomains_app'
263
+ prefs[:form_builder] = 'none'
264
+ prefs[:quiet_assets] = true
265
+ prefs[:local_env_file] = true
266
+ prefs[:better_errors] = true
267
+ end
268
+
269
+ __END__
270
+
271
+ name: railsapps
272
+ description: "Install RailsApps example applications."
273
+ author: RailsApps
274
+
275
+ requires: [core]
276
+ run_after: [git]
277
+ category: configuration
data/recipes/readme.rb ADDED
@@ -0,0 +1,85 @@
1
+ # Application template recipe for the rails_apps_composer. Change the recipe here:
2
+ # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb
3
+
4
+ after_everything do
5
+ say_wizard "recipe running after everything"
6
+
7
+ # remove default READMEs
8
+ %w{
9
+ README
10
+ README.rdoc
11
+ doc/README_FOR_APP
12
+ }.each { |file| remove_file file }
13
+
14
+ # add placeholder READMEs and humans.txt file
15
+ copy_from_repo 'public/humans.txt'
16
+ copy_from_repo 'README'
17
+ copy_from_repo 'README.textile'
18
+ gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
19
+ gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
20
+
21
+ # Diagnostics
22
+ gsub_file "README.textile", /recipes that are known/, "recipes that are NOT known" if diagnostics[:recipes] == 'fail'
23
+ gsub_file "README.textile", /preferences that are known/, "preferences that are NOT known" if diagnostics[:prefs] == 'fail'
24
+ gsub_file "README.textile", /RECIPES/, recipes.sort.inspect
25
+ gsub_file "README.textile", /PREFERENCES/, prefs.inspect
26
+ gsub_file "README", /RECIPES/, recipes.sort.inspect
27
+ gsub_file "README", /PREFERENCES/, prefs.inspect
28
+
29
+ # Ruby on Rails
30
+ gsub_file "README.textile", /\* Ruby/, "* Ruby version #{RUBY_VERSION}"
31
+ gsub_file "README.textile", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}"
32
+
33
+ # Database
34
+ gsub_file "README.textile", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql'
35
+ gsub_file "README.textile", /SQLite/, "MySQL" if prefer :database, 'mysql'
36
+ gsub_file "README.textile", /SQLite/, "MongoDB" if prefer :database, 'mongodb'
37
+ gsub_file "README.textile", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid'
38
+
39
+ # Template Engine
40
+ gsub_file "README.textile", /ERB/, "Haml" if prefer :templates, 'haml'
41
+ gsub_file "README.textile", /ERB/, "Slim" if prefer :templates, 'slim'
42
+
43
+ # Testing Framework
44
+ gsub_file "README.textile", /Test::Unit/, "RSpec" if prefer :unit_test, 'rspec'
45
+ gsub_file "README.textile", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber'
46
+ gsub_file "README.textile", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl'
47
+ gsub_file "README.textile", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist'
48
+
49
+ # Front-end Framework
50
+ gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap 2.3 (Sass)" if prefer :frontend, 'bootstrap2'
51
+ gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap 3.0 (Sass)" if prefer :frontend, 'bootstrap3'
52
+ gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Zurb Foundation" if prefer :frontend, 'foundation4'
53
+
54
+ # Form Builder
55
+ gsub_file "README.textile", /Form Builder: None/, "Form Builder: SimpleForm" if prefer :form_builder, 'simple_form'
56
+
57
+ # Email
58
+ unless prefer :email, 'none'
59
+ gsub_file "README.textile", /Gmail/, "SMTP" if prefer :email, 'smtp'
60
+ gsub_file "README.textile", /Gmail/, "SendGrid" if prefer :email, 'sendgrid'
61
+ gsub_file "README.textile", /Gmail/, "Mandrill" if prefer :email, 'mandrill'
62
+ else
63
+ gsub_file "README.textile", /h2. Email/, ""
64
+ gsub_file "README.textile", /The application is configured to send email using a Gmail account./, ""
65
+ end
66
+
67
+ # Authentication and Authorization
68
+ gsub_file "README.textile", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise'
69
+ gsub_file "README.textile", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth'
70
+ gsub_file "README.textile", /Authorization: None/, "Authorization: CanCan" if prefer :authorization, 'cancan'
71
+
72
+ git :add => '-A' if prefer :git, true
73
+ git :commit => '-qm "rails_apps_composer: add README files"' if prefer :git, true
74
+
75
+ end # after_everything
76
+
77
+ __END__
78
+
79
+ name: readme
80
+ description: "Build a README file for your application."
81
+ author: RailsApps
82
+
83
+ requires: [setup]
84
+ run_after: [setup]
85
+ category: configuration
data/recipes/routes.rb ADDED
@@ -0,0 +1,45 @@
1
+ # Application template recipe for the rails_apps_composer. Change the recipe here:
2
+ # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/routes.rb
3
+
4
+ after_bundler do
5
+ say_wizard "recipe running after 'bundle install'"
6
+ ### HOME ###
7
+ if prefer :starter_app, 'home_app'
8
+ remove_file 'public/index.html'
9
+ gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
10
+ end
11
+ ### USER_ACCOUNTS ###
12
+ if ['users_app','admin_app'].include? prefs[:starter_app]
13
+ ## DEVISE
14
+ if prefer :authentication, 'devise'
15
+ copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
16
+ ## Rails 4.0 doesn't allow two 'root' routes
17
+ gsub_file 'config/routes.rb', /authenticated :user do\n.*\n.*\n /, '' if rails_4?
18
+ ## accommodate strong parameters in Rails 4
19
+ gsub_file 'config/routes.rb', /devise_for :users/, 'devise_for :users, :controllers => {:registrations => "registrations"}' if rails_4?
20
+ end
21
+ ## OMNIAUTH
22
+ if prefer :authentication, 'omniauth'
23
+ copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
24
+ gsub_file 'config/routes.rb', /match/, 'get' if rails_4?
25
+ end
26
+ end
27
+ ### SUBDOMAINS ###
28
+ copy_from_repo 'lib/subdomain.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
29
+ copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
30
+ ### CORRECT APPLICATION NAME ###
31
+ gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
32
+ ### GIT ###
33
+ git :add => '-A' if prefer :git, true
34
+ git :commit => '-qm "rails_apps_composer: routes"' if prefer :git, true
35
+ end # after_bundler
36
+
37
+ __END__
38
+
39
+ name: routes
40
+ description: "Add routes needed for starter apps."
41
+ author: RailsApps
42
+
43
+ requires: [setup, gems, models, controllers, views]
44
+ run_after: [setup, gems, models, controllers, views]
45
+ category: mvc
data/recipes/saas.rb ADDED
@@ -0,0 +1,218 @@
1
+ # Application template recipe for the rails_apps_composer. Change the recipe here:
2
+ # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/saas.rb
3
+
4
+ if prefer :railsapps, 'rails-stripe-membership-saas'
5
+
6
+ after_everything do
7
+ say_wizard "recipe running after 'bundle install'"
8
+ repo = 'https://raw.github.com/RailsApps/rails-stripe-membership-saas/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
+ # >-------------------------------[ Migrations ]--------------------------------<
28
+ generate 'migration AddStripeToUsers customer_id:string last_4_digits:string'
29
+ run 'bundle exec rake db:drop'
30
+ run 'bundle exec rake db:migrate'
31
+
32
+ # >-------------------------------[ Models ]--------------------------------<
33
+ copy_from_repo 'app/models/ability.rb', :repo => repo
34
+ copy_from_repo 'app/models/user.rb', :repo => repo
35
+
36
+ # >-------------------------------[ Init ]--------------------------------<
37
+ copy_from_repo 'config/application.yml', :repo => repo
38
+ remove_file 'config/application.example.yml'
39
+ copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml'
40
+ copy_from_repo 'db/seeds.rb', :repo => repo
41
+ copy_from_repo 'config/initializers/stripe.rb', :repo => repo
42
+ run 'bundle exec rake db:seed'
43
+ run 'bundle exec rake db:test:prepare'
44
+
45
+ # >-------------------------------[ Controllers ]--------------------------------<
46
+ copy_from_repo 'app/controllers/home_controller.rb', :repo => repo
47
+ generate 'controller content silver gold platinum --skip-stylesheets --skip-javascripts'
48
+ copy_from_repo 'app/controllers/content_controller.rb', :repo => repo
49
+ copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo
50
+ copy_from_repo 'app/controllers/application_controller.rb', :repo => repo
51
+ copy_from_repo 'app/controllers/users_controller.rb', :repo => repo
52
+
53
+ # >-------------------------------[ Mailers ]--------------------------------<
54
+ generate 'mailer UserMailer'
55
+ copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo
56
+
57
+ # >-------------------------------[ Views ]--------------------------------<
58
+ copy_from_repo 'app/views/home/index.html.erb', :repo => repo
59
+ copy_from_repo 'app/views/layouts/_navigation.html.erb', :repo => repo
60
+ copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo
61
+ copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo
62
+ copy_from_repo 'app/views/user_mailer/expire_email.html.erb', :repo => repo
63
+ copy_from_repo 'app/views/user_mailer/expire_email.text.erb', :repo => repo
64
+
65
+ # >-------------------------------[ Routes ]--------------------------------<
66
+ copy_from_repo 'config/routes.rb', :repo => repo
67
+ ### CORRECT APPLICATION NAME ###
68
+ gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
69
+
70
+ # >-------------------------------[ Assets ]--------------------------------<
71
+ copy_from_repo 'app/assets/javascripts/application.js', :repo => repo
72
+ copy_from_repo 'app/assets/javascripts/jquery.readyselector.js', :repo => repo
73
+ copy_from_repo 'app/assets/javascripts/jquery.externalscript.js', :repo => repo
74
+ copy_from_repo 'app/assets/javascripts/registrations.js', :repo => repo
75
+ copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo
76
+ copy_from_repo 'app/assets/stylesheets/pricing.css.scss', :repo => repo
77
+
78
+ # >-------------------------------[ RSpec ]--------------------------------<
79
+ say_wizard "copying RSpec tests from the rails-stripe-membership-saas examples"
80
+ copy_from_repo 'spec/factories/roles.rb', :repo => repo
81
+ copy_from_repo 'spec/models/user_spec.rb', :repo => repo
82
+ copy_from_repo 'spec/controllers/content_controller_spec.rb', :repo => repo
83
+ copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo
84
+ copy_from_repo 'spec/stripe/stripe_config_spec.rb', :repo => repo
85
+ copy_from_repo 'spec/support/stripe_helper.rb', :repo => repo
86
+ copy_from_repo 'spec/support/fixtures/success.json', :repo => repo
87
+
88
+ # >-------------------------------[ Cucumber ]--------------------------------<
89
+ say_wizard "copying Cucumber scenarios from the rails-stripe-membership-saas examples"
90
+ remove_file 'features/users/user_show.feature'
91
+ copy_from_repo 'features/support/paths.rb', :repo => repo
92
+ copy_from_repo 'features/users/sign_in.feature', :repo => repo
93
+ copy_from_repo 'features/users/sign_up.feature', :repo => repo
94
+ copy_from_repo 'features/users/sign_up_with_stripe.feature', :repo => repo
95
+ copy_from_repo 'features/users/user_edit.feature', :repo => repo
96
+ copy_from_repo 'features/users/user_delete.feature', :repo => repo
97
+ copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
98
+ copy_from_repo 'features/step_definitions/form_helper_steps.rb', :repo => repo
99
+ copy_from_repo 'config/locales/devise.en.yml', :repo => repo
100
+
101
+ ### GIT ###
102
+ git :add => '-A' if prefer :git, true
103
+ git :commit => '-qm "rails_apps_composer: membership app"' if prefer :git, true
104
+ end # after_bundler
105
+ end # rails-stripe-membership-saas
106
+
107
+ if prefer :railsapps, 'rails-recurly-subscription-saas'
108
+
109
+ after_everything do
110
+ say_wizard "recipe running after 'bundle install'"
111
+ repo = 'https://raw.github.com/RailsApps/rails-recurly-subscription-saas/master/'
112
+
113
+ # >-------------------------------[ Clean up starter app ]--------------------------------<
114
+
115
+ %w{
116
+ public/index.html
117
+ app/assets/images/rails.png
118
+ }.each { |file| remove_file file }
119
+ # remove commented lines and multiple blank lines from Gemfile
120
+ # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
121
+ gsub_file 'Gemfile', /#.*\n/, "\n"
122
+ gsub_file 'Gemfile', /\n^\s*\n/, "\n"
123
+ # remove commented lines and multiple blank lines from config/routes.rb
124
+ gsub_file 'config/routes.rb', / #.*\n/, "\n"
125
+ gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
126
+ # GIT
127
+ git :add => '-A' if prefer :git, true
128
+ git :commit => '-qm "rails_apps_composer: clean up starter app"' if prefer :git, true
129
+
130
+ # >-------------------------------[ Migrations ]--------------------------------<
131
+ generate 'migration AddRecurlyToUsers first_name:string last_name:string customer_id:string'
132
+ run 'bundle exec rake db:drop'
133
+ run 'bundle exec rake db:migrate'
134
+
135
+ # >-------------------------------[ Models ]--------------------------------<
136
+ copy_from_repo 'app/models/ability.rb', :repo => repo
137
+ copy_from_repo 'app/models/user.rb', :repo => repo
138
+
139
+ # >-------------------------------[ Init ]--------------------------------<
140
+ copy_from_repo 'config/application.yml', :repo => repo
141
+ remove_file 'config/application.example.yml'
142
+ copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml'
143
+ copy_from_repo 'db/seeds.rb', :repo => repo
144
+ copy_from_repo 'config/initializers/recurly.rb', :repo => repo
145
+ run 'bundle exec rake db:seed'
146
+ run 'bundle exec rake db:test:prepare'
147
+
148
+ # >-------------------------------[ Controllers ]--------------------------------<
149
+ copy_from_repo 'app/controllers/home_controller.rb', :repo => repo
150
+ generate 'controller content silver gold platinum --skip-stylesheets --skip-javascripts'
151
+ copy_from_repo 'app/controllers/content_controller.rb', :repo => repo
152
+ copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo
153
+ copy_from_repo 'app/controllers/application_controller.rb', :repo => repo
154
+ copy_from_repo 'app/controllers/users_controller.rb', :repo => repo
155
+ copy_from_repo 'app/controllers/recurly_controller.rb', :repo => repo
156
+
157
+ # >-------------------------------[ Mailers ]--------------------------------<
158
+ generate 'mailer UserMailer'
159
+ copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo
160
+
161
+ # >-------------------------------[ Views ]--------------------------------<
162
+ copy_from_repo 'app/views/home/index.html.erb', :repo => repo
163
+ copy_from_repo 'app/views/layouts/_navigation.html.erb', :repo => repo
164
+ copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo
165
+ copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo
166
+ copy_from_repo 'app/views/user_mailer/expire_email.html.erb', :repo => repo
167
+ copy_from_repo 'app/views/user_mailer/expire_email.text.erb', :repo => repo
168
+
169
+ # >-------------------------------[ Routes ]--------------------------------<
170
+ copy_from_repo 'config/routes.rb', :repo => repo
171
+ ### CORRECT APPLICATION NAME ###
172
+ gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
173
+
174
+ # >-------------------------------[ Assets ]--------------------------------<
175
+ copy_from_repo 'app/assets/javascripts/application.js', :repo => repo
176
+ copy_from_repo 'app/assets/javascripts/jquery.readyselector.js', :repo => repo
177
+ copy_from_repo 'app/assets/javascripts/recurly.js', :repo => repo
178
+ copy_from_repo 'app/assets/javascripts/registrations.js', :repo => repo
179
+ copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo
180
+ copy_from_repo 'app/assets/stylesheets/pricing.css.scss', :repo => repo
181
+
182
+ # >-------------------------------[ RSpec ]--------------------------------<
183
+ say_wizard "copying RSpec tests from the rails-recurly-subscription-saas examples"
184
+ copy_from_repo 'spec/factories/roles.rb', :repo => repo
185
+ copy_from_repo 'spec/factories/users.rb', :repo => repo
186
+ copy_from_repo 'spec/models/user_spec.rb', :repo => repo
187
+ copy_from_repo 'spec/controllers/content_controller_spec.rb', :repo => repo
188
+ copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo
189
+ copy_from_repo 'spec/recurly/recurly_config_spec.rb', :repo => repo
190
+
191
+ # >-------------------------------[ Cucumber ]--------------------------------<
192
+ say_wizard "copying Cucumber scenarios from the rails-recurly-subscription-saas examples"
193
+ remove_file 'features/users/user_show.feature'
194
+ copy_from_repo 'features/support/paths.rb', :repo => repo
195
+ copy_from_repo 'features/users/sign_in.feature', :repo => repo
196
+ copy_from_repo 'features/users/sign_up.feature', :repo => repo
197
+ copy_from_repo 'features/users/sign_up_with_recurly.feature', :repo => repo
198
+ copy_from_repo 'features/users/user_edit.feature', :repo => repo
199
+ copy_from_repo 'features/users/user_delete.feature', :repo => repo
200
+ copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
201
+ copy_from_repo 'features/step_definitions/form_helper_steps.rb', :repo => repo
202
+ copy_from_repo 'config/locales/devise.en.yml', :repo => repo
203
+
204
+ ### GIT ###
205
+ git :add => '-A' if prefer :git, true
206
+ git :commit => '-qm "rails_apps_composer: membership app"' if prefer :git, true
207
+ end # after_bundler
208
+ end # rails-recurly-subscription-saas
209
+
210
+ __END__
211
+
212
+ name: prelaunch
213
+ description: "Install an example application for a membership site."
214
+ author: RailsApps
215
+
216
+ requires: [core]
217
+ run_after: [setup, gems, models, controllers, views, frontend, init]
218
+ category: apps