rails_apps_composer 1.0.24 → 1.0.25
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/cucumber.rb +1 -1
- data/recipes/devise.rb +1 -1
- data/recipes/navigation.rb +26 -0
- data/recipes/rspec.rb +1 -1
- data/recipes/subdomains.rb +113 -0
- data/templates/layout.erb +7 -0
- data/version.rb +1 -1
- metadata +19 -18
data/recipes/cucumber.rb
CHANGED
@@ -12,7 +12,7 @@ if config['cucumber']
|
|
12
12
|
# for Rails 3.1+, use optimistic versioning for gems
|
13
13
|
gem 'cucumber-rails', '>= 1.2.0', :group => :test
|
14
14
|
gem 'capybara', '>= 1.1.1', :group => :test
|
15
|
-
gem 'database_cleaner', '>= 0.
|
15
|
+
gem 'database_cleaner', '>= 0.7.0', :group => :test
|
16
16
|
gem 'launchy', '>= 2.0.5', :group => :test
|
17
17
|
end
|
18
18
|
else
|
data/recipes/devise.rb
CHANGED
data/recipes/navigation.rb
CHANGED
@@ -123,6 +123,32 @@ ERB
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
# Throw it all away and create new navigation if we're enabling subdomains
|
127
|
+
if recipes.include? 'subdomains'
|
128
|
+
remove_file 'app/views/shared/_navigation.html.haml'
|
129
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
130
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
131
|
+
create_file 'app/views/shared/_navigation.html.haml' do <<-'HAML'
|
132
|
+
%li
|
133
|
+
= link_to 'Main', root_url(:host => request.domain)
|
134
|
+
- unless request.subdomain.present? && request.subdomain != "www"
|
135
|
+
- if user_signed_in?
|
136
|
+
%li
|
137
|
+
= link_to('Edit account', edit_user_registration_path)
|
138
|
+
- else
|
139
|
+
%li
|
140
|
+
= link_to('Sign up', new_user_registration_path)
|
141
|
+
- else
|
142
|
+
- if user_signed_in?
|
143
|
+
%li
|
144
|
+
= link_to('Logout', destroy_user_session_path, :method=>'delete')
|
145
|
+
- else
|
146
|
+
%li
|
147
|
+
= link_to('Login', new_user_session_path)
|
148
|
+
HAML
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
126
152
|
end
|
127
153
|
|
128
154
|
__END__
|
data/recipes/rspec.rb
CHANGED
@@ -22,7 +22,7 @@ if config['rspec']
|
|
22
22
|
gem 'rspec-rails', '>= 2.8.0.rc1', :group => [:development, :test]
|
23
23
|
if recipes.include? 'mongoid'
|
24
24
|
# use the database_cleaner gem to reset the test database
|
25
|
-
gem 'database_cleaner', '>= 0.
|
25
|
+
gem 'database_cleaner', '>= 0.7.0', :group => :test
|
26
26
|
# include RSpec matchers from the mongoid-rspec gem
|
27
27
|
gem 'mongoid-rspec', '>= 1.4.4', :group => :test
|
28
28
|
end
|
@@ -0,0 +1,113 @@
|
|
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/subdomains.rb
|
3
|
+
# this recipe requires Mongoid and Haml (ActiveRecord and ERB verions are not implemented)
|
4
|
+
|
5
|
+
if recipes.include? 'haml'
|
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
|
16
|
+
validates_format_of :name, with: /^[a-z0-9_]+$/, message: 'must be lowercase alphanumerics only'
|
17
|
+
validates_length_of :name, maximum: 32, message: 'exceeds maximum of 32 characters'
|
18
|
+
validates_exclusion_of :name, in: ['www', 'mail', 'ftp'], message: 'is not available'
|
19
|
+
|
20
|
+
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
|
26
|
+
<<-RUBY
|
27
|
+
class ProfilesController < ApplicationController
|
28
|
+
def show
|
29
|
+
@user = User.first(conditions: { name: request.subdomain }) || not_found
|
30
|
+
end
|
31
|
+
|
32
|
+
def not_found
|
33
|
+
raise ActionController::RoutingError.new('User Not Found')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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
|
41
|
+
<<-'HAML'
|
42
|
+
%h1 Profile
|
43
|
+
%h3= @user.name
|
44
|
+
%h3= @user.email
|
45
|
+
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
|
51
|
+
<<-RUBY
|
52
|
+
class Subdomain
|
53
|
+
def self.matches?(request)
|
54
|
+
case request.subdomain
|
55
|
+
when 'www', '', nil
|
56
|
+
false
|
57
|
+
else
|
58
|
+
true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
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
|
67
|
+
constraints(Subdomain) do
|
68
|
+
match '/' => 'profiles#show'
|
69
|
+
end
|
70
|
+
root :to => "home#index"
|
71
|
+
RUBY
|
72
|
+
end
|
73
|
+
|
74
|
+
remove_file 'app/views/home/index.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/home/index.html.haml' do
|
78
|
+
<<-'HAML'
|
79
|
+
%h3 Home
|
80
|
+
- @users.each do |user|
|
81
|
+
%br/
|
82
|
+
User: #{link_to user.name, user}
|
83
|
+
Profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)}
|
84
|
+
HAML
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
elsif recipes.include? 'rails 3.0'
|
89
|
+
say_wizard "Not supported for Rails version #{Rails::VERSION::STRING}. Subdomains recipe skipped."
|
90
|
+
else
|
91
|
+
say_wizard "Don't know what to do for Rails version #{Rails::VERSION::STRING}. Subdomains recipe skipped."
|
92
|
+
end
|
93
|
+
else
|
94
|
+
say_wizard "The subdomains recipe is only implememted for Mongoid (no support for ActiveRecord)."
|
95
|
+
end
|
96
|
+
else
|
97
|
+
say_wizard "The subdomains recipe is only implememted for Haml (no support for ERB)."
|
98
|
+
end
|
99
|
+
|
100
|
+
__END__
|
101
|
+
|
102
|
+
name: subdomains
|
103
|
+
description: "Allow use of subdomains."
|
104
|
+
author: RailsApps
|
105
|
+
|
106
|
+
category: other
|
107
|
+
tags: [utilities, configuration]
|
108
|
+
|
109
|
+
config:
|
110
|
+
- subdomain_option:
|
111
|
+
type: multiple_choice
|
112
|
+
prompt: "Would you like to add support for subdomains?"
|
113
|
+
choices: [["No", no], ["One subdomain per user (like Basecamp)", one-per-user]]
|
data/templates/layout.erb
CHANGED
@@ -47,6 +47,13 @@ say_wizard "You are using #{gemfile_rake_ver.strip}"
|
|
47
47
|
|
48
48
|
say_wizard "Checking configuration. Please confirm your preferences."
|
49
49
|
|
50
|
+
# >---------------------------[ Autoload Modules/Classes ]-----------------------------<
|
51
|
+
|
52
|
+
inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY'
|
53
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
54
|
+
RUBY
|
55
|
+
end
|
56
|
+
|
50
57
|
# >---------------------------[ Javascript Runtime ]-----------------------------<
|
51
58
|
|
52
59
|
prepend_file 'Gemfile' do <<-RUBY
|
data/version.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.25
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153235160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153235160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153234660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153234660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: thor
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153234160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153234160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153233600 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.5.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153233600
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mg
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153232980 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153232980
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153232320 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 3.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153232320
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: i18n
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153231640 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153231640
|
91
91
|
description: A gem with recipes to create Rails application templates you can use
|
92
92
|
to generate Rails starter apps.
|
93
93
|
email:
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- recipes/sequel.rb
|
150
150
|
- recipes/settingslogic.rb
|
151
151
|
- recipes/slim.rb
|
152
|
+
- recipes/subdomains.rb
|
152
153
|
- recipes/test_unit.rb
|
153
154
|
- recipes/users_page.rb
|
154
155
|
- README.textile
|
@@ -179,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
180
|
version: '0'
|
180
181
|
segments:
|
181
182
|
- 0
|
182
|
-
hash:
|
183
|
+
hash: -3880893974405196726
|
183
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
185
|
none: false
|
185
186
|
requirements:
|
@@ -188,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
189
|
version: '0'
|
189
190
|
segments:
|
190
191
|
- 0
|
191
|
-
hash:
|
192
|
+
hash: -3880893974405196726
|
192
193
|
requirements: []
|
193
194
|
rubyforge_project: rails_apps_composer
|
194
195
|
rubygems_version: 1.8.11
|