rails_apps_composer 1.0.26 → 1.1.0

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/mongoid.rb CHANGED
@@ -2,17 +2,10 @@
2
2
  # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/mongoid.rb
3
3
 
4
4
  if config['mongoid']
5
- if recipes.include? 'rails 3.0'
6
- # for Rails 3.0, use only gem versions we know that work
7
- say_wizard "REMINDER: When creating a Rails app using Mongoid..."
8
- say_wizard "you should add the '-O' flag to 'rails new'"
9
- gem 'bson_ext', '1.3.1'
10
- gem 'mongoid', '2.0.2'
11
- else
12
- # for Rails 3.1+, use optimistic versioning for gems
13
- gem 'bson_ext', '>= 1.3.1'
14
- gem 'mongoid', '>= 2.3.3'
15
- end
5
+ say_wizard "REMINDER: When creating a Rails app using Mongoid..."
6
+ say_wizard "you should add the '-O' flag to 'rails new'"
7
+ gem 'bson_ext', '>= 1.3.1'
8
+ gem 'mongoid', '>= 2.4.3'
16
9
  else
17
10
  recipes.delete('mongoid')
18
11
  end
@@ -0,0 +1,59 @@
1
+ if config['use_heroku']
2
+
3
+ header = <<-YAML
4
+ <% if ENV['MONGOLAB_URI'] %>
5
+ <% mongolab = URI.parse(ENV['MONGOLAB_URI']) %>
6
+ mongolab:
7
+ host: <%= mongolab.host %>
8
+ port: <%= mongolab.port %>
9
+ database: <%= mongolab.path.sub '/', '' %>
10
+ username: <%= mongolab.user %>
11
+ password: <%= mongolab.password %>
12
+ <% end %>
13
+ YAML
14
+
15
+ after_everything do
16
+ say_wizard 'Adding mongolab:starter addon (you can always upgrade later)'
17
+ system 'heroku addons:add mongolab:starter'
18
+ end
19
+ else
20
+ mongolab = URI.parse(config['uri'])
21
+
22
+ header = <<-YAML
23
+ mongolab:
24
+ host: #{mongolab.host}
25
+ port: #{mongolab.port}
26
+ database: #{mongolab.path.sub '/',''}
27
+ username: #{mongolab.user}
28
+ password: #{mongolab.password}
29
+ YAML
30
+ end
31
+
32
+ after_bundler do
33
+ mongo_yml = "config/mongo#{'id' if recipe?('mongoid')}.yml"
34
+
35
+ prepend_file mongo_yml, header
36
+ inject_into_file mongo_yml, " <<: *mongolab\n", :after => "production:\n <<: *defaults\n"
37
+ end
38
+
39
+ __END__
40
+
41
+ name: mongolab (based on mongohq recipe)
42
+ description: "Utilize mongolab as the production data host for your application."
43
+ author: l4u (based on mongohq recipe by mbleigh)
44
+
45
+ requires_any: [mongo_mapper, mongoid]
46
+ run_after: [mongo_mapper, mongoid, heroku]
47
+ exclusive: mongodb_host
48
+ category: services
49
+ tags: [mongodb]
50
+
51
+ config:
52
+ - use_heroku:
53
+ type: boolean
54
+ prompt: "Use the MongoLab Heroku addon?"
55
+ if_recipe: heroku
56
+ - uri:
57
+ type: string
58
+ prompt: "Enter your MongoLab URI:"
59
+ unless: use_heroku
data/recipes/omniauth.rb CHANGED
@@ -2,25 +2,17 @@
2
2
  # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/omniauth.rb
3
3
 
4
4
  if config['omniauth']
5
- if recipes.include? 'rails 3.0'
6
- # for Rails 3.0, use only gem versions we know that work
7
- gem 'omniauth', '0.2.6'
8
- else
9
- # for Rails 3.1+, use optimistic versioning for gems
10
- gem 'omniauth', '>= 1.0.0'
11
- # for available gems, see https://github.com/intridea/omniauth/wiki/List-of-Strategies
12
- case config['provider']
13
- when 'twitter'
14
- gem 'omniauth-twitter'
15
- when 'facebook'
16
- gem 'omniauth-facebook'
17
- when 'github'
18
- gem 'omniauth-github'
19
- when 'linkedin'
20
- gem 'omniauth-linkedin'
21
- when 'provider'
22
- say_wizard "IMPORTANT: you'll have to add a gem to your Gemfile for the provider you want"
23
- end
5
+ gem 'omniauth', '>= 1.0.2'
6
+ # for available gems, see https://github.com/intridea/omniauth/wiki/List-of-Strategies
7
+ case config['provider']
8
+ when 'twitter'
9
+ gem 'omniauth-twitter'
10
+ when 'facebook'
11
+ gem 'omniauth-facebook'
12
+ when 'github'
13
+ gem 'omniauth-github'
14
+ when 'linkedin'
15
+ gem 'omniauth-linkedin'
24
16
  end
25
17
  else
26
18
  recipes.delete('omniauth')
@@ -160,4 +152,4 @@ config:
160
152
  - provider:
161
153
  type: multiple_choice
162
154
  prompt: "Which service provider will you use?"
163
- choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linkedin], ["Other", provider]]
155
+ choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linkedin]]
data/recipes/rspec.rb CHANGED
@@ -2,34 +2,18 @@
2
2
  # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rspec.rb
3
3
 
4
4
  if config['rspec']
5
- if recipes.include? 'rails 3.0'
6
- # for Rails 3.0, use only gem versions we know that work
7
- say_wizard "REMINDER: When creating a Rails app using RSpec..."
8
- say_wizard "you should add the '-T' flag to 'rails new'"
9
- gem 'rspec-rails', '2.6.1', :group => [:development, :test]
10
- if recipes.include? 'mongoid'
11
- # use the database_cleaner gem to reset the test database
12
- gem 'database_cleaner', '0.6.7', :group => :test
13
- # include RSpec matchers from the mongoid-rspec gem
14
- gem 'mongoid-rspec', '1.4.2', :group => :test
15
- end
16
- if config['factory_girl']
17
- # use the factory_girl gem for test fixtures
18
- gem 'factory_girl_rails', '1.1.beta1', :group => :test
19
- end
20
- else
21
- # for Rails 3.1+, use optimistic versioning for gems
22
- gem 'rspec-rails', '>= 2.8.0.rc1', :group => [:development, :test]
23
- if recipes.include? 'mongoid'
24
- # use the database_cleaner gem to reset the test database
25
- gem 'database_cleaner', '>= 0.7.0', :group => :test
26
- # include RSpec matchers from the mongoid-rspec gem
27
- gem 'mongoid-rspec', '>= 1.4.4', :group => :test
28
- end
29
- if config['factory_girl']
30
- # use the factory_girl gem for test fixtures
31
- gem 'factory_girl_rails', '>= 1.3.0', :group => :test
32
- end
5
+ gem 'rspec-rails', '>= 2.8.1', :group => [:development, :test]
6
+ if recipes.include? 'mongoid'
7
+ # use the database_cleaner gem to reset the test database
8
+ gem 'database_cleaner', '>= 0.7.1', :group => :test
9
+ # include RSpec matchers from the mongoid-rspec gem
10
+ gem 'mongoid-rspec', '>= 1.4.4', :group => :test
11
+ end
12
+ if config['machinist']
13
+ gem 'machinist', group: :test
14
+ end
15
+ if config['factory_girl']
16
+ gem 'factory_girl_rails', '>= 1.6.0', :group => :test
33
17
  end
34
18
  else
35
19
  recipes.delete('rspec')
@@ -51,6 +35,7 @@ if config['rspec']
51
35
  config.generators do |g|
52
36
  g.view_specs false
53
37
  g.helper_specs false
38
+ #{"g.fixture_replacement :machinist" if config['machinist']}
54
39
  end
55
40
 
56
41
  RUBY
@@ -85,7 +70,7 @@ RUBY
85
70
  gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
86
71
 
87
72
  # configure RSpec to use matchers from the mongoid-rspec gem
88
- create_file 'spec/support/mongoid.rb' do
73
+ create_file 'spec/support/mongoid.rb' do
89
74
  <<-RUBY
90
75
  RSpec.configure do |config|
91
76
  config.include Mongoid::Matchers
@@ -96,7 +81,7 @@ RUBY
96
81
 
97
82
  if recipes.include? 'devise'
98
83
  # add Devise test helpers
99
- create_file 'spec/support/devise.rb' do
84
+ create_file 'spec/support/devise.rb' do
100
85
  <<-RUBY
101
86
  RSpec.configure do |config|
102
87
  config.include Devise::TestHelpers, :type => :controller
@@ -126,3 +111,6 @@ config:
126
111
  - factory_girl:
127
112
  type: boolean
128
113
  prompt: Would you like to use factory_girl for test fixtures with RSpec?
114
+ - machinist:
115
+ type: boolean
116
+ prompt: Would you like to use machinist for test fixtures with RSpec?
data/recipes/sass.rb CHANGED
@@ -1,8 +1,6 @@
1
- if recipes.include? 'rails 3.0'
2
- gem 'sass', '>= 3.1.6'
3
- end
4
1
 
5
2
  if config['sass']
3
+ gem 'sass', '>= 3.1.12'
6
4
  after_bundler do
7
5
  create_file 'config/initializers/sass.rb' do <<-RUBY
8
6
  Rails.application.config.generators.stylesheet_engine = :sass
@@ -0,0 +1,43 @@
1
+
2
+ after_bundler do
3
+
4
+ say_wizard "HomePage recipe running 'after bundler'"
5
+
6
+ # remove the default home page
7
+ remove_file 'public/index.html'
8
+
9
+ # create a home controller and view
10
+ generate(:controller, "static home")
11
+
12
+ # set up a simple home page (with placeholder content)
13
+ if recipes.include? 'haml'
14
+ remove_file 'app/views/static/home.html.haml'
15
+ # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
16
+ # We have to use single-quote-style-heredoc to avoid interpolation.
17
+ create_file 'app/views/static/home.html.haml' do
18
+ <<-'HAML'
19
+ %h3 Home
20
+ HAML
21
+ end
22
+ else
23
+ remove_file 'app/views/static/home.html.erb'
24
+ create_file 'app/views/static/home.html.erb' do
25
+ <<-ERB
26
+ <h3>Home</h3>
27
+ ERB
28
+ end
29
+ end
30
+
31
+ # set routes
32
+ gsub_file 'config/routes.rb', /get \"static\/home\"/, 'root to: "static#home"'
33
+
34
+ end
35
+
36
+ __END__
37
+
38
+ name: StaticPage
39
+ description: "Create a simple home page (creates a static controller and view)."
40
+ author: RailsApps
41
+
42
+ category: other
43
+ tags: [utilities, configuration]
@@ -4,25 +4,24 @@
4
4
 
5
5
  if recipes.include? 'haml'
6
6
  if recipes.include? 'mongoid'
7
- if recipes.include? 'rails 3.1'
8
- after_bundler do
9
- say_wizard "Subdomains recipe running 'after bundler'"
10
- case config['subdomain_option']
11
- when 'no'
12
- say_wizard "Subdomains recipe skipped."
13
- when 'one-per-user'
14
- # user name as a subdomain
15
- inject_into_file 'app/models/user.rb', :before => 'validates_uniqueness_of' do <<-RUBY
7
+ after_bundler do
8
+ say_wizard "Subdomains recipe running 'after bundler'"
9
+ case config['subdomain_option']
10
+ when 'no'
11
+ say_wizard "Subdomains recipe skipped."
12
+ when 'one-per-user'
13
+ # user name as a subdomain
14
+ inject_into_file 'app/models/user.rb', :before => 'validates_uniqueness_of' do <<-RUBY
16
15
  validates_format_of :name, with: /^[a-z0-9_]+$/, message: 'must be lowercase alphanumerics only'
17
16
  validates_length_of :name, maximum: 32, message: 'exceeds maximum of 32 characters'
18
17
  validates_exclusion_of :name, in: ['www', 'mail', 'ftp'], message: 'is not available'
19
18
 
20
19
  RUBY
21
- end
22
- # modify db/seeds.rb
23
- gsub_file 'db/seeds.rb', /First User/, 'myname'
24
- # controller and views for the profile page
25
- create_file 'app/controllers/profiles_controller.rb' do
20
+ end
21
+ # modify db/seeds.rb
22
+ gsub_file 'db/seeds.rb', /First User/, 'myname'
23
+ # controller and views for the profile page
24
+ create_file 'app/controllers/profiles_controller.rb' do
26
25
  <<-RUBY
27
26
  class ProfilesController < ApplicationController
28
27
  def show
@@ -34,20 +33,20 @@ class ProfilesController < ApplicationController
34
33
  end
35
34
  end
36
35
  RUBY
37
- end
38
- # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
39
- # We have to use single-quote-style-heredoc to avoid interpolation.
40
- create_file 'app/views/profiles/show.html.haml' do
36
+ end
37
+ # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
38
+ # We have to use single-quote-style-heredoc to avoid interpolation.
39
+ create_file 'app/views/profiles/show.html.haml' do
41
40
  <<-'HAML'
42
41
  %h1 Profile
43
42
  %h3= @user.name
44
43
  %h3= @user.email
45
44
  HAML
46
- end
47
- # implement routing constraint for subdomains
48
- # be sure to autoload (set config.autoload_paths in config/application.rb)
49
- # or require this class in the config/routes.rb file
50
- create_file 'lib/subdomain.rb' do
45
+ end
46
+ # implement routing constraint for subdomains
47
+ # be sure to autoload (set config.autoload_paths in config/application.rb)
48
+ # or require this class in the config/routes.rb file
49
+ create_file 'lib/subdomain.rb' do
51
50
  <<-RUBY
52
51
  class Subdomain
53
52
  def self.matches?(request)
@@ -60,21 +59,21 @@ class Subdomain
60
59
  end
61
60
  end
62
61
  RUBY
63
- end
64
- # create routes for subdomains
65
- gsub_file 'config/routes.rb', /root :to => "home#index"/, ''
66
- inject_into_file 'config/routes.rb', :after => 'resources :users, :only => :show' do <<-RUBY
62
+ end
63
+ # create routes for subdomains
64
+ gsub_file 'config/routes.rb', /root :to => "home#index"/, ''
65
+ inject_into_file 'config/routes.rb', :after => 'resources :users, :only => :show' do <<-RUBY
67
66
 
68
67
  constraints(Subdomain) do
69
68
  match '/' => 'profiles#show'
70
69
  end
71
70
  root :to => "home#index"
72
71
  RUBY
73
- end
74
- remove_file 'app/views/users/show.html.haml'
75
- # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
76
- # We have to use single-quote-style-heredoc to avoid interpolation.
77
- create_file 'app/views/users/show.html.haml' do
72
+ end
73
+ remove_file 'app/views/users/show.html.haml'
74
+ # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
75
+ # We have to use single-quote-style-heredoc to avoid interpolation.
76
+ create_file 'app/views/users/show.html.haml' do
78
77
  <<-'HAML'
79
78
  %p
80
79
  User: #{@user.name}
@@ -83,25 +82,20 @@ RUBY
83
82
  %p
84
83
  Profile: #{link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name)}
85
84
  HAML
86
- end
87
- remove_file 'app/views/home/index.html.haml'
88
- # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
89
- # We have to use single-quote-style-heredoc to avoid interpolation.
90
- create_file 'app/views/home/index.html.haml' do
85
+ end
86
+ remove_file 'app/views/home/index.html.haml'
87
+ # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
88
+ # We have to use single-quote-style-heredoc to avoid interpolation.
89
+ create_file 'app/views/home/index.html.haml' do
91
90
  <<-'HAML'
92
91
  %h3 Home
93
92
  - @users.each do |user|
94
93
  %br/
95
94
  #{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)}
96
95
  HAML
97
- end
98
- gsub_file 'app/controllers/users_controller.rb', /before_filter :authenticate_user!/, ''
99
- end
96
+ end
97
+ gsub_file 'app/controllers/users_controller.rb', /before_filter :authenticate_user!/, ''
100
98
  end
101
- elsif recipes.include? 'rails 3.0'
102
- say_wizard "Not supported for Rails version #{Rails::VERSION::STRING}. Subdomains recipe skipped."
103
- else
104
- say_wizard "Don't know what to do for Rails version #{Rails::VERSION::STRING}. Subdomains recipe skipped."
105
99
  end
106
100
  else
107
101
  say_wizard "The subdomains recipe is only implememted for Mongoid (no support for ActiveRecord)."
data/templates/layout.erb CHANGED
@@ -1,6 +1,6 @@
1
1
  # >---------------------------------------------------------------------------<
2
2
  #
3
- # _____ _ _ __ ___ _
3
+ # _____ _ _ __ ___ _
4
4
  # | __ \ (_) | \ \ / (_) | |
5
5
  # | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
6
6
  # | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
@@ -24,27 +24,25 @@ RUBY
24
24
 
25
25
  <%= render "helpers" %>
26
26
 
27
+ # this application template only supports Rails version 3.1 and newer
27
28
  case Rails::VERSION::MAJOR.to_s
28
29
  when "3"
29
30
  case Rails::VERSION::MINOR.to_s
31
+ when "2"
32
+ say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
30
33
  when "1"
31
34
  say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
32
- @recipes << 'rails 3.1'
33
35
  when "0"
34
- say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
35
- @recipes << 'rails 3.0'
36
+ say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
37
+ raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
36
38
  else
37
- say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported."
39
+ say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
38
40
  end
39
41
  else
40
- say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported."
42
+ say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
43
+ raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
41
44
  end
42
45
 
43
- # show which version of rake is running
44
- # with the added benefit of ensuring that the Gemfile's version of rake is activated
45
- gemfile_rake_ver = run 'bundle exec rake --version', :capture => true, :verbose => false
46
- say_wizard "You are using #{gemfile_rake_ver.strip}"
47
-
48
46
  say_wizard "Checking configuration. Please confirm your preferences."
49
47
 
50
48
  # >---------------------------[ Autoload Modules/Classes ]-----------------------------<
@@ -55,26 +53,6 @@ inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W
55
53
  RUBY
56
54
  end
57
55
 
58
- # >---------------------------[ Javascript Runtime ]-----------------------------<
59
-
60
- prepend_file 'Gemfile' do <<-RUBY
61
- require 'rbconfig'
62
- HOST_OS = RbConfig::CONFIG['host_os']
63
-
64
- RUBY
65
- end
66
-
67
- if recipes.include? 'rails 3.1'
68
- append_file 'Gemfile' do <<-RUBY
69
- # install a Javascript runtime for linux
70
- if HOST_OS =~ /linux/i
71
- gem 'therubyracer', '>= 0.9.8'
72
- end
73
-
74
- RUBY
75
- end
76
- end
77
-
78
56
  # >---------------------------------[ Recipes ]----------------------------------<
79
57
 
80
58
  <% resolve_recipes.each do |recipe| %>