Skip to content

Commit dc40276

Browse files
committed
build using rails_apps_composer 2.1.3
1 parent 7a26a67 commit dc40276

File tree

1 file changed

+89
-21
lines changed

1 file changed

+89
-21
lines changed

composer.rb

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
end
2323
RUBY
2424

25-
@recipes = ["git", "railsapps", "setup", "readme", "gems", "testing", "auth", "email", "models", "controllers", "views", "routes", "frontend", "database", "extras"]
25+
@recipes = ["all", "git", "railsapps", "setup", "readme", "gems", "testing", "auth", "email", "models", "controllers", "views", "routes", "frontend", "init", "extras"]
2626
@prefs = {}
2727
@gems = []
28-
@diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["auth", "controllers", "database", "email", "extras", "frontend", "gems", "git", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["auth", "controllers", "database", "email", "example", "extras", "frontend", "gems", "git", "models", "railsapps", "readme", "routes", "setup", "testing", "views"]]
28+
@diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["auth", "controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["all", "auth", "controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["all", "auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"]]
2929
@diagnostics_prefs = [{:railsapps=>"rails3-bootstrap-devise-cancan", :database=>"sqlite", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"none"}, {:railsapps=>"rails3-devise-rspec-cucumber", :database=>"sqlite", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-devise", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-omniauth", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-subdomains", :database=>"mongodb", :orm=>"mongoid", :templates=>"haml", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"subdomains_app", :form_builder=>"none"}]
3030
diagnostics = {}
3131

@@ -80,6 +80,15 @@ def after_everything(&block); @after_everything_blocks << [@current_recipe, bloc
8080
@before_configs = {}
8181
def before_config(&block); @before_configs[@current_recipe] = block; end
8282

83+
def copy_from(source, destination)
84+
begin
85+
remove_file destination
86+
get source, destination
87+
rescue OpenURI::HTTPError
88+
say_wizard "Unable to obtain #{source}"
89+
end
90+
end
91+
8392
def copy_from_repo(filename, opts = {})
8493
repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/'
8594
repo = opts[:repo] unless opts[:repo].nil?
@@ -165,6 +174,22 @@ def html_to_slim(source)
165174
# >---------------------------------[ Recipes ]----------------------------------<
166175

167176

177+
# >----------------------------------[ all ]----------------------------------<
178+
179+
@current_recipe = "all"
180+
@before_configs["all"].call if @before_configs["all"]
181+
say_recipe 'all'
182+
183+
184+
@configs[@current_recipe] = config
185+
186+
# Application template recipe for the rails_apps_composer. Change the recipe here:
187+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/all.rb
188+
189+
## Git
190+
say_wizard "selected all recipes"
191+
192+
168193
# >----------------------------------[ git ]----------------------------------<
169194

170195
@current_recipe = "git"
@@ -181,12 +206,7 @@ def html_to_slim(source)
181206
say_wizard "initialize git"
182207
prefs[:git] = true unless prefs.has_key? :git
183208
if prefer :git, true
184-
begin
185-
remove_file '.gitignore'
186-
get 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
187-
rescue OpenURI::HTTPError
188-
say_wizard "Unable to obtain gitignore file from the repo"
189-
end
209+
copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
190210
git :init
191211
git :add => '.'
192212
git :commit => "-aqm 'rails_apps_composer: initial commit'"
@@ -215,6 +235,7 @@ def html_to_slim(source)
215235

216236
case prefs[:railsapps]
217237
when 'rails3-bootstrap-devise-cancan'
238+
prefs[:git] = true
218239
prefs[:database] = 'sqlite'
219240
prefs[:templates] = 'erb'
220241
prefs[:unit_test] = 'rspec'
@@ -229,6 +250,7 @@ def html_to_slim(source)
229250
prefs[:starter_app] = 'admin_app'
230251
prefs[:form_builder] = 'none'
231252
when 'rails3-devise-rspec-cucumber'
253+
prefs[:git] = true
232254
prefs[:database] = 'sqlite'
233255
prefs[:templates] = 'erb'
234256
prefs[:unit_test] = 'rspec'
@@ -242,6 +264,7 @@ def html_to_slim(source)
242264
prefs[:starter_app] = 'users_app'
243265
prefs[:form_builder] = 'none'
244266
when 'rails3-mongoid-devise'
267+
prefs[:git] = true
245268
prefs[:database] = 'mongodb'
246269
prefs[:orm] = 'mongoid'
247270
prefs[:templates] = 'erb'
@@ -256,6 +279,7 @@ def html_to_slim(source)
256279
prefs[:starter_app] = 'users_app'
257280
prefs[:form_builder] = 'none'
258281
when 'rails3-mongoid-omniauth'
282+
prefs[:git] = true
259283
prefs[:database] = 'mongodb'
260284
prefs[:orm] = 'mongoid'
261285
prefs[:templates] = 'erb'
@@ -270,6 +294,7 @@ def html_to_slim(source)
270294
prefs[:starter_app] = 'users_app'
271295
prefs[:form_builder] = 'none'
272296
when 'rails3-subdomains'
297+
prefs[:git] = true
273298
prefs[:database] = 'mongodb'
274299
prefs[:orm] = 'mongoid'
275300
prefs[:templates] = 'haml'
@@ -465,8 +490,10 @@ def html_to_slim(source)
465490
# Ruby on Rails
466491
gsub_file "README.textile", /\* Ruby/, "* Ruby version #{RUBY_VERSION}"
467492
gsub_file "README.textile", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}"
468-
493+
469494
# Database
495+
gsub_file "README.textile", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql'
496+
gsub_file "README.textile", /SQLite/, "MySQL" if prefer :database, 'mysql'
470497
gsub_file "README.textile", /SQLite/, "MongoDB" if prefer :database, 'mongodb'
471498
gsub_file "README.textile", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid'
472499

@@ -537,6 +564,7 @@ def html_to_slim(source)
537564
gem 'puma', '>= 1.6.1', :group => :production if prefer :prod_webserver, 'puma'
538565

539566
## Database Adapter
567+
gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
540568
gem 'mongoid', '>= 3.0.3' if prefer :orm, 'mongoid'
541569
gem 'pg', '>= 0.14.0' if prefer :database, 'postgresql'
542570
gem 'mysql2', '>= 0.3.11' if prefer :database, 'mysql'
@@ -778,6 +806,21 @@ def html_to_slim(source)
778806
remove_file 'spec/helpers/home_helper_spec.rb'
779807
remove_file 'spec/helpers/users_helper_spec.rb'
780808
end
809+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
810+
say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples"
811+
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
812+
copy_from_repo 'spec/factories/users.rb', :repo => repo
813+
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
814+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
815+
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
816+
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
817+
remove_file 'spec/views/home/index.html.erb_spec.rb'
818+
remove_file 'spec/views/home/index.html.haml_spec.rb'
819+
remove_file 'spec/views/users/show.html.erb_spec.rb'
820+
remove_file 'spec/views/users/show.html.haml_spec.rb'
821+
remove_file 'spec/helpers/home_helper_spec.rb'
822+
remove_file 'spec/helpers/users_helper_spec.rb'
823+
end
781824
## RSPEC AND OMNIAUTH
782825
if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app')
783826
say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
@@ -817,6 +860,31 @@ def html_to_slim(source)
817860
When I sign in with valid credentials
818861
Then I see an unconfirmed account message
819862
And I should be signed out
863+
RUBY
864+
end
865+
end
866+
end
867+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
868+
say_wizard "copying Cucumber scenarios from the rails3-bootstrap-devise-cancan examples"
869+
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
870+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
871+
copy_from_repo 'features/users/sign_in.feature', :repo => repo
872+
copy_from_repo 'features/users/sign_out.feature', :repo => repo
873+
copy_from_repo 'features/users/sign_up.feature', :repo => repo
874+
copy_from_repo 'features/users/user_edit.feature', :repo => repo
875+
copy_from_repo 'features/users/user_show.feature', :repo => repo
876+
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
877+
copy_from_repo 'features/support/paths.rb', :repo => repo
878+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
879+
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
880+
inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do
881+
<<-RUBY
882+
Scenario: User has not confirmed account
883+
Given I exist as an unconfirmed user
884+
And I am not logged in
885+
When I sign in with valid credentials
886+
Then I see an unconfirmed account message
887+
And I should be signed out
820888
RUBY
821889
end
822890
end
@@ -1263,30 +1331,30 @@ def html_to_slim(source)
12631331
insert_into_file 'app/assets/javascripts/application.js', "//= require foundation\n", :after => "jquery_ujs\n"
12641332
insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation\n", :after => "require_self\n"
12651333
elsif prefer :frontend, 'skeleton'
1266-
copy_from_repo 'app/assets/stylesheets/normalize.css.scss', :repo => 'https://raw.github.com/necolas/normalize.css/master/normalize.css'
1267-
copy_from_repo 'app/assets/stylesheets/base.css.scss', :repo => 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css'
1268-
copy_from_repo 'app/assets/stylesheets/layout.css.scss', :repo => 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css'
1269-
copy_from_repo 'app/assets/stylesheets/skeleton.css.scss', :repo => 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css'
1334+
copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
1335+
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css'
1336+
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css'
1337+
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css'
12701338
elsif prefer :frontend, 'normalize'
1271-
copy_from_repo 'app/assets/stylesheets/normalize.css.scss', :repo => 'https://raw.github.com/necolas/normalize.css/master/normalize.css'
1339+
copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
12721340
end
12731341
### GIT ###
12741342
git :add => '.' if prefer :git, true
12751343
git :commit => "-aqm 'rails_apps_composer: front-end framework'" if prefer :git, true
12761344
end # after_bundler
12771345

12781346

1279-
# >-------------------------------[ database ]--------------------------------<
1347+
# >---------------------------------[ init ]----------------------------------<
12801348

1281-
@current_recipe = "database"
1282-
@before_configs["database"].call if @before_configs["database"]
1283-
say_recipe 'database'
1349+
@current_recipe = "init"
1350+
@before_configs["init"].call if @before_configs["init"]
1351+
say_recipe 'init'
12841352

12851353

12861354
@configs[@current_recipe] = config
12871355

12881356
# Application template recipe for the rails_apps_composer. Change the recipe here:
1289-
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/database.rb
1357+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb
12901358

12911359
after_everything do
12921360
say_wizard "recipe running after everything"
@@ -1432,7 +1500,7 @@ def html_to_slim(source)
14321500
begin
14331501
RVM.gemset_use! app_name
14341502
rescue StandardError
1435-
raise "Use rvm gem 1.11.3.5 or newer."
1503+
raise "rvm failure: unable to use gemset #{app_name}"
14361504
end
14371505
run "rvm gemset list"
14381506
copy_from_repo '.rvmrc'
@@ -1455,7 +1523,7 @@ def html_to_slim(source)
14551523
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
14561524
# GIT
14571525
git :add => '.' if prefer :git, true
1458-
git :commit => "-aqm 'rails_apps_composer: starter app complete'" if prefer :git, true
1526+
git :commit => "-aqm 'rails_apps_composer: extras'" if prefer :git, true
14591527
end
14601528

14611529

0 commit comments

Comments
 (0)