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/README.textile +13 -17
- data/recipes/activerecord.rb +0 -5
- data/recipes/application_layout.rb +2 -7
- data/recipes/backbone.rb +3 -11
- data/recipes/cleanup.rb +2 -11
- data/recipes/compass.rb +6 -15
- data/recipes/css_setup.rb +7 -8
- data/recipes/cucumber.rb +4 -13
- data/recipes/devise.rb +1 -8
- data/recipes/guard.rb +18 -10
- data/recipes/haml.rb +2 -9
- data/recipes/heroku.rb +6 -2
- data/recipes/html5.rb +47 -53
- data/recipes/mongoid.rb +4 -11
- data/recipes/mongolab.rb +59 -0
- data/recipes/omniauth.rb +12 -20
- data/recipes/rspec.rb +18 -30
- data/recipes/sass.rb +1 -3
- data/recipes/static_page.rb +43 -0
- data/recipes/subdomains.rb +38 -44
- data/templates/layout.erb +9 -31
- data/version.rb +1 -1
- metadata +24 -36
- data/recipes/draggable.rb +0 -39
- data/recipes/env_yaml.rb +0 -54
- data/recipes/jammit.rb +0 -43
- data/recipes/jquery.rb +0 -70
- data/recipes/mongo_mapper.rb +0 -18
- data/recipes/mootools.rb +0 -23
- data/recipes/pow.rb +0 -12
- data/recipes/prototype.rb +0 -11
- data/recipes/redis.rb +0 -17
- data/recipes/redistogo.rb +0 -40
- data/recipes/rightjs.rb +0 -17
- data/recipes/sequel.rb +0 -13
- data/recipes/slim.rb +0 -11
- data/recipes/test_unit.rb +0 -11
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
data/recipes/mongolab.rb
ADDED
@@ -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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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]
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
@@ -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]
|
data/recipes/subdomains.rb
CHANGED
@@ -4,25 +4,24 @@
|
|
4
4
|
|
5
5
|
if recipes.include? 'haml'
|
6
6
|
if recipes.include? 'mongoid'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
98
|
-
|
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
|
-
|
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}
|
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| %>
|