rails_apps_composer 1.4.5 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rails_apps_composer +0 -0
- data/recipes/add_user.rb +14 -7
- data/recipes/devise.rb +16 -6
- data/recipes/extras.rb +11 -6
- data/recipes/html5.rb +10 -2
- data/recipes/mongoid.rb +1 -1
- data/recipes/seed_database.rb +14 -3
- data/recipes/users_page.rb +66 -5
- data/version.rb +2 -2
- metadata +20 -20
data/bin/rails_apps_composer
CHANGED
File without changes
|
data/recipes/add_user.rb
CHANGED
@@ -19,6 +19,20 @@ RUBY
|
|
19
19
|
|
20
20
|
# Generate models and routes for a User
|
21
21
|
generate 'devise user'
|
22
|
+
|
23
|
+
if recipes.include? 'authorization'
|
24
|
+
# create'app/models/ability.rb'
|
25
|
+
generate 'cancan:ability'
|
26
|
+
# create 'app/models/role.rb'
|
27
|
+
# create 'config/initializers/rolify.rb'
|
28
|
+
# create 'db/migrate/...rolify_create_roles.rb'
|
29
|
+
# insert 'rolify' method in 'app/models/users.rb'
|
30
|
+
if recipes.include? 'mongoid'
|
31
|
+
generate 'rolify:role Role User mongoid'
|
32
|
+
else
|
33
|
+
generate 'rolify:role Role User'
|
34
|
+
end
|
35
|
+
end
|
22
36
|
|
23
37
|
# Add a 'name' attribute to the User model
|
24
38
|
if recipes.include? 'mongoid'
|
@@ -58,13 +72,6 @@ RUBY
|
|
58
72
|
gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email"
|
59
73
|
end
|
60
74
|
end
|
61
|
-
|
62
|
-
if recipes.include? 'canard'
|
63
|
-
say_wizard "modifying User class to add an admin role"
|
64
|
-
inject_into_file 'app/models/user.rb', :after => 'ActiveRecord::Base' do
|
65
|
-
"\n acts_as_user :roles => :admin\n"
|
66
|
-
end
|
67
|
-
end
|
68
75
|
|
69
76
|
unless recipes.include? 'haml'
|
70
77
|
|
data/recipes/devise.rb
CHANGED
@@ -20,9 +20,10 @@ case config['devise']
|
|
20
20
|
say_wizard "Devise recipe skipped."
|
21
21
|
end
|
22
22
|
|
23
|
-
if config['
|
24
|
-
gem 'cancan', '>=
|
25
|
-
|
23
|
+
if config['authorization']
|
24
|
+
gem 'cancan', '>= 1.6.7'
|
25
|
+
gem 'rolify', '>= 3.1.0'
|
26
|
+
recipes << 'authorization'
|
26
27
|
end
|
27
28
|
|
28
29
|
if recipes.include? 'devise'
|
@@ -51,7 +52,16 @@ if recipes.include? 'devise'
|
|
51
52
|
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
|
52
53
|
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
|
53
54
|
end
|
54
|
-
|
55
|
+
|
56
|
+
if config['authorization']
|
57
|
+
inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
|
58
|
+
rescue_from CanCan::AccessDenied do |exception|
|
59
|
+
redirect_to root_path, :error => exception.message
|
60
|
+
end
|
61
|
+
RUBY
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
end
|
56
66
|
|
57
67
|
after_everything do
|
@@ -99,6 +109,6 @@ config:
|
|
99
109
|
type: multiple_choice
|
100
110
|
prompt: Would you like to use Devise for authentication?
|
101
111
|
choices: [["No", no], ["Devise with default modules", standard], ["Devise with Confirmable module", confirmable], ["Devise with Confirmable and Invitable modules", invitable]]
|
102
|
-
-
|
112
|
+
- authorization:
|
103
113
|
type: boolean
|
104
|
-
prompt: Would you like to manage authorization with CanCan
|
114
|
+
prompt: Would you like to manage authorization with CanCan & Rolify?
|
data/recipes/extras.rb
CHANGED
@@ -2,24 +2,26 @@
|
|
2
2
|
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb
|
3
3
|
|
4
4
|
if config['footnotes']
|
5
|
-
say_wizard "
|
5
|
+
say_wizard "Adding 'rails-footnotes'"
|
6
6
|
gem 'rails-footnotes', '>= 3.7', :group => :development
|
7
7
|
after_bundler do
|
8
8
|
generate 'rails_footnotes:install'
|
9
9
|
end
|
10
|
-
else
|
11
|
-
recipes.delete('footnotes')
|
12
10
|
end
|
13
11
|
|
14
12
|
if config['ban_spiders']
|
15
|
-
say_wizard "
|
13
|
+
say_wizard "Banning spiders by modifying 'public/robots.txt'"
|
16
14
|
after_bundler do
|
17
15
|
# ban spiders from your site by changing robots.txt
|
18
16
|
gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
|
19
17
|
gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
|
20
18
|
end
|
21
|
-
|
22
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
if config['paginate']
|
22
|
+
say_wizard "Adding 'will_paginate'"
|
23
|
+
gem 'will_paginate', '>= 3.0.3'
|
24
|
+
recipes << 'paginate'
|
23
25
|
end
|
24
26
|
|
25
27
|
__END__
|
@@ -38,3 +40,6 @@ config:
|
|
38
40
|
- ban_spiders:
|
39
41
|
type: boolean
|
40
42
|
prompt: Would you like to set a robots.txt file to ban spiders?
|
43
|
+
- paginate:
|
44
|
+
type: boolean
|
45
|
+
prompt: Would you like to add 'will_paginate' for pagination?
|
data/recipes/html5.rb
CHANGED
@@ -52,7 +52,11 @@ after_bundler do
|
|
52
52
|
# get an appropriate navigation partial
|
53
53
|
if recipes.include? 'haml'
|
54
54
|
if recipes.include? 'devise'
|
55
|
-
|
55
|
+
if recipes.include? 'authorization'
|
56
|
+
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
57
|
+
else
|
58
|
+
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
59
|
+
end
|
56
60
|
elsif recipes.include? 'omniauth'
|
57
61
|
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
58
62
|
elsif recipes.include? 'subdomains'
|
@@ -62,7 +66,11 @@ after_bundler do
|
|
62
66
|
end
|
63
67
|
else
|
64
68
|
if recipes.include? 'devise'
|
65
|
-
|
69
|
+
if recipes.include? 'authorization'
|
70
|
+
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
71
|
+
else
|
72
|
+
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
73
|
+
end
|
66
74
|
elsif recipes.include? 'omniauth'
|
67
75
|
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
68
76
|
elsif recipes.include? 'subdomains'
|
data/recipes/mongoid.rb
CHANGED
@@ -5,7 +5,7 @@ if config['mongoid']
|
|
5
5
|
say_wizard "REMINDER: When creating a Rails app using Mongoid..."
|
6
6
|
say_wizard "you should add the '-O' flag to 'rails new'"
|
7
7
|
gem 'bson_ext', '>= 1.6.2'
|
8
|
-
gem 'mongoid', '>= 2.4.
|
8
|
+
gem 'mongoid', '>= 2.4.8'
|
9
9
|
else
|
10
10
|
recipes.delete('mongoid')
|
11
11
|
end
|
data/recipes/seed_database.rb
CHANGED
@@ -32,6 +32,8 @@ FILE
|
|
32
32
|
puts 'SETTING UP DEFAULT USER LOGIN'
|
33
33
|
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
34
34
|
puts 'New user created: ' << user.name
|
35
|
+
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
36
|
+
puts 'New user created: ' << user2.name
|
35
37
|
FILE
|
36
38
|
end
|
37
39
|
else
|
@@ -39,19 +41,28 @@ FILE
|
|
39
41
|
puts 'SETTING UP DEFAULT USER LOGIN'
|
40
42
|
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please'
|
41
43
|
puts 'New user created: ' << user.name
|
44
|
+
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please'
|
45
|
+
puts 'New user created: ' << user2.name
|
42
46
|
FILE
|
43
47
|
end
|
44
48
|
end
|
45
|
-
if recipes.include? '
|
49
|
+
if recipes.include? 'authorization'
|
46
50
|
append_file 'db/seeds.rb' do <<-FILE
|
47
|
-
user.
|
51
|
+
user.add_role :admin
|
48
52
|
FILE
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
|
-
|
57
|
+
|
54
58
|
|
59
|
+
end
|
60
|
+
|
61
|
+
after_everything do
|
62
|
+
|
63
|
+
say_wizard "seeding the database"
|
64
|
+
run 'bundle exec rake db:seed'
|
65
|
+
|
55
66
|
end
|
56
67
|
|
57
68
|
__END__
|
data/recipes/users_page.rb
CHANGED
@@ -8,14 +8,41 @@ after_bundler do
|
|
8
8
|
#----------------------------------------------------------------------------
|
9
9
|
# Create a users controller
|
10
10
|
#----------------------------------------------------------------------------
|
11
|
-
generate(:controller, "users show")
|
12
|
-
|
13
|
-
<<-RUBY
|
14
|
-
|
11
|
+
generate(:controller, "users show index")
|
12
|
+
remove_file 'app/controllers/users_controller.rb'
|
13
|
+
create_file 'app/controllers/users_controller.rb' do <<-RUBY
|
14
|
+
class UsersController < ApplicationController
|
15
|
+
before_filter :authenticate_user!
|
16
|
+
|
17
|
+
def index
|
18
|
+
@users = User.all
|
19
|
+
end
|
15
20
|
|
16
21
|
def show
|
17
22
|
@user = User.find(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
RUBY
|
27
|
+
end
|
28
|
+
if recipes.include? 'authorization'
|
29
|
+
inject_into_file 'app/controllers/users_controller.rb', " authorize! :index, @user, :message => 'Not authorized as an administrator.'\n", :after => "def index\n"
|
30
|
+
end
|
31
|
+
if recipes.include? 'paginate'
|
32
|
+
gsub_file 'app/controllers/users_controller.rb', /@users = User.all/, '@users = User.paginate(:page => params[:page])'
|
33
|
+
end
|
34
|
+
|
35
|
+
#----------------------------------------------------------------------------
|
36
|
+
# Limit access to the users#index page
|
37
|
+
#----------------------------------------------------------------------------
|
38
|
+
if recipes.include? 'authorization'
|
39
|
+
inject_into_file 'app/models/ability.rb', :after => "def initialize(user)\n" do <<-RUBY
|
40
|
+
user ||= User.new # guest user (not logged in)
|
41
|
+
if user.has_role? :admin
|
42
|
+
can :manage, :all
|
43
|
+
end
|
18
44
|
RUBY
|
45
|
+
end
|
19
46
|
end
|
20
47
|
|
21
48
|
#----------------------------------------------------------------------------
|
@@ -23,13 +50,47 @@ RUBY
|
|
23
50
|
#----------------------------------------------------------------------------
|
24
51
|
# @devise_for :users@ route must be placed above @resources :users, :only => :show@.
|
25
52
|
gsub_file 'config/routes.rb', /get \"users\/show\"/, ''
|
53
|
+
gsub_file 'config/routes.rb', /get \"users\/index\"/, ''
|
26
54
|
gsub_file 'config/routes.rb', /devise_for :users/ do
|
27
55
|
<<-RUBY
|
28
56
|
devise_for :users
|
29
|
-
resources :users, :only => :show
|
57
|
+
resources :users, :only => [:show, :index]
|
30
58
|
RUBY
|
31
59
|
end
|
32
60
|
|
61
|
+
#----------------------------------------------------------------------------
|
62
|
+
# Create a users index page
|
63
|
+
#----------------------------------------------------------------------------
|
64
|
+
if recipes.include? 'haml'
|
65
|
+
remove_file 'app/views/users/index.html.haml'
|
66
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
67
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
68
|
+
create_file 'app/views/users/index.html.haml' do <<-'HAML'
|
69
|
+
%h2 Users
|
70
|
+
- @users.each do |user|
|
71
|
+
%br/
|
72
|
+
#{link_to user.email, user} signed up #{user.created_at.to_date}
|
73
|
+
HAML
|
74
|
+
end
|
75
|
+
if recipes.include? 'paginate'
|
76
|
+
append_file 'app/views/users/index.html.haml', "\n= will_paginate\n"
|
77
|
+
end
|
78
|
+
else
|
79
|
+
append_file 'app/views/users/index.html.erb' do <<-ERB
|
80
|
+
<ul class="users">
|
81
|
+
<% @users.each do |user| %>
|
82
|
+
<li>
|
83
|
+
<%= link_to user.name, user %> signed up <%= user.created_at.to_date %>
|
84
|
+
</li>
|
85
|
+
<% end %>
|
86
|
+
</ul>
|
87
|
+
ERB
|
88
|
+
end
|
89
|
+
if recipes.include? 'paginate'
|
90
|
+
append_file 'app/views/users/index.html.erb', "\n<%= will_paginate %>\n"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
33
94
|
#----------------------------------------------------------------------------
|
34
95
|
# Create a users show page
|
35
96
|
#----------------------------------------------------------------------------
|
data/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module RailsWizard
|
2
|
-
VERSION = "1.4.
|
3
|
-
end
|
2
|
+
VERSION = "1.4.6"
|
3
|
+
end
|
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.4.
|
4
|
+
version: 1.4.6
|
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: 2012-04-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153133360 !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: *2153133360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153132800 !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: *2153132800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: thor
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153132340 !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: *2153132340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153131860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153131860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153131120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.5.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153131120
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mg
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153130600 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153130600
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activesupport
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153129680 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 3.0.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153129680
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: i18n
|
93
|
-
requirement: &
|
93
|
+
requirement: &2153129020 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2153129020
|
102
102
|
description: A gem with recipes to create Rails application templates you can use
|
103
103
|
to generate Rails starter apps.
|
104
104
|
email:
|
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
segments:
|
184
184
|
- 0
|
185
|
-
hash:
|
185
|
+
hash: -1960849393898634811
|
186
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
187
|
none: false
|
188
188
|
requirements:
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
segments:
|
193
193
|
- 0
|
194
|
-
hash:
|
194
|
+
hash: -1960849393898634811
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project: rails_apps_composer
|
197
197
|
rubygems_version: 1.8.16
|