cream 0.8.9.2 → 0.8.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.textile +11 -6
- data/Rakefile +1 -1
- data/cream.gemspec +21 -73
- data/lib/cream/configure/rails.rb +1 -2
- data/lib/generators/cancan/config/config_generator.rb +6 -9
- data/lib/generators/cream/app/app_generator.rb +3 -3
- data/lib/generators/cream/full_config/full_config_generator.rb +22 -13
- data/lib/generators/cream/helpers/all.rb +15 -0
- data/lib/generators/cream/helpers/args_helper.rb +27 -12
- data/lib/generators/cream/helpers/execute_helper.rb +1 -1
- data/lib/generators/cream/helpers/gemfile_helper.rb +4 -4
- data/lib/generators/devise/config/app_helper.rb +4 -4
- data/lib/generators/devise/config/config_generator.rb +4 -4
- data/lib/generators/devise/customize/customize_generator.rb +3 -3
- data/lib/generators/devise/customize/helpers/username_helper.rb +4 -4
- data/lib/generators/devise/users/helper.rb +1 -1
- data/lib/generators/devise/users/routes_helper.rb +47 -42
- data/lib/generators/devise/users/users_generator.rb +30 -29
- data/lib/generators/permits/config/config_generator.rb +3 -3
- data/lib/generators/roles/config/config_generator.rb +10 -6
- metadata +107 -428
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -24,6 +24,10 @@ Cream comes with a suite of specialized generators that should let you configure
|
|
24
24
|
|
25
25
|
Note: Lately Cream also has options for some common customizations such as allowing login using either username or email.
|
26
26
|
|
27
|
+
h2. Status update (Feb 13)
|
28
|
+
|
29
|
+
Just added a @registrations_for@ option to the @devise:users@ generator. This allows you to specify for which user types to create individual registration controllers and pages (if needed). The routes_helper has been updated in order to be aligned with this approach. Please try out edge and let me know how well it works.
|
30
|
+
|
27
31
|
h2. Objectives
|
28
32
|
|
29
33
|
* Integrate a set of widely accepted sub-systems for a fully integrated solution
|
@@ -59,9 +63,10 @@ h3. Design ideas
|
|
59
63
|
|
60
64
|
Please see the "Design ideas":https://github.com/kristianmandrup/cream/wiki/Design-ideas section on the wiki for possible enhancements you might want to add and/or ideas for further improvments to the framework. Feel free to add your own suggestions and ideas!
|
61
65
|
|
62
|
-
|
66
|
+
Since version 0.8.9 I have added the concept of a Guest user and current_user using the session. Please also see "Cream Guest user":https://github.com/kristianmandrup/cream/wiki/Cream-Guest-user for more info on the current approach.
|
63
67
|
|
64
|
-
|
68
|
+
The latest design splits up the concepts of role and user_type. The _user_types_ are now the devise classes generated, and each such class can have a role strategy assigned.
|
69
|
+
Ther should be a simple way to define a default role, something like the following.
|
65
70
|
|
66
71
|
Example idea:
|
67
72
|
|
@@ -70,11 +75,11 @@ Example idea:
|
|
70
75
|
default_role :editor
|
71
76
|
|
72
77
|
valid_roles_are :publisher, blog_editor
|
73
|
-
roles_config :multi
|
74
78
|
end
|
75
79
|
</pre>
|
76
80
|
|
77
|
-
This way, any editor user created will always be given the :editor role on creation and he can later add the :publisher and/or :blog_editor roles
|
81
|
+
This way, any editor user created will always be given the :editor role on creation and he can later add the :publisher and/or :blog_editor roles.
|
82
|
+
Perhaps it could just use the class name somehow, fx using the @lowercase@ method (this way it would also work with more complex, namespaced classes).
|
78
83
|
|
79
84
|
*Ideas and suggestions are most welcome!*
|
80
85
|
|
@@ -82,7 +87,7 @@ h3. The path towards 1.0
|
|
82
87
|
|
83
88
|
I will continue the 0.8.9.x line only with bug fixes and other minor fixes or additions.
|
84
89
|
|
85
|
-
The 0.9 line will likely be a total redesign/refactoring using what I am learning from reading _Jose Valim's_ book *Crafting Rails Applications*. I will create a new project using _enginex_, complete with one or more dummy apllications and take it from there.
|
90
|
+
The 0.9 line will likely be a total redesign/refactoring using what I am learning from reading _Jose Valim's_ book *Crafting Rails Applications*. I will create a new project using _enginex_, complete with one or more dummy apllications and take it from there. Sadly I will likely not have time for this until April 2011, so if anyone has the time and energy, please help me in this effort!
|
86
91
|
|
87
92
|
h2. Cream edge, debugging and assisting developing the framework
|
88
93
|
|
@@ -266,7 +271,7 @@ A User subclass is now generated for each role by default in order to allow more
|
|
266
271
|
|
267
272
|
h2. Generators
|
268
273
|
|
269
|
-
Please see "Cream generators overview
|
274
|
+
Please see "Cream generators overview":https://github.com/kristianmandrup/cream/wiki/Cream-generators-overview for more details.
|
270
275
|
|
271
276
|
The following generators are currently available:
|
272
277
|
|
data/Rakefile
CHANGED
@@ -27,7 +27,7 @@ begin
|
|
27
27
|
gem.add_dependency "rails", ">= 3.0.1"
|
28
28
|
|
29
29
|
gem.add_dependency "rails3_artifactor", "~> 0.3.2"
|
30
|
-
gem.add_dependency 'logging_assist', ">= 0.2.0"
|
30
|
+
# gem.add_dependency 'logging_assist', ">= 0.2.0" # only required if logging is on
|
31
31
|
|
32
32
|
gem.add_dependency "r3_plugin_toolbox", ">= 0.4.0"
|
33
33
|
gem.add_dependency "sugar-high", ">= 0.3.1"
|
data/cream.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cream}
|
8
|
-
s.version = "0.8.9.
|
8
|
+
s.version = "0.8.9.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-04}
|
13
13
|
s.description = %q{An integrated Authentication, Authorization and Roles solution for your Rails 3 app with support for multiple ORMs}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -106,7 +106,7 @@ Gem::Specification.new do |s|
|
|
106
106
|
]
|
107
107
|
s.homepage = %q{http://github.com/kristianmandrup/cream}
|
108
108
|
s.require_paths = ["lib"]
|
109
|
-
s.rubygems_version = %q{1.
|
109
|
+
s.rubygems_version = %q{1.6.1}
|
110
110
|
s.summary = %q{Integrates Devise, CanCan with permits and Roles generic for multiple ORMs}
|
111
111
|
s.test_files = [
|
112
112
|
"spec/configure_helper.rb",
|
@@ -130,103 +130,51 @@ Gem::Specification.new do |s|
|
|
130
130
|
]
|
131
131
|
|
132
132
|
if s.respond_to? :specification_version then
|
133
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
134
133
|
s.specification_version = 3
|
135
134
|
|
136
135
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
137
|
-
s.
|
138
|
-
s.add_runtime_dependency(%q<cancan-rest-links>, [">= 0.2.0"])
|
139
|
-
s.add_runtime_dependency(%q<cancan-permits>, [">= 0.3.4"])
|
140
|
-
s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
|
141
|
-
s.add_runtime_dependency(%q<colorize>, [">= 0.5.8"])
|
142
|
-
s.add_runtime_dependency(%q<devise>, [">= 1.1.5"])
|
143
|
-
s.add_runtime_dependency(%q<cancan>, [">= 1.4.0"])
|
144
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.0.1"])
|
145
|
-
s.add_runtime_dependency(%q<rails3_artifactor>, [">= 0.3.2"])
|
146
|
-
s.add_runtime_dependency(%q<logging_assist>, [">= 0.2.0"])
|
147
|
-
s.add_runtime_dependency(%q<r3_plugin_toolbox>, [">= 0.4.0"])
|
148
|
-
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.1"])
|
149
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0.1"])
|
150
|
-
s.add_development_dependency(%q<generator-spec>, [">= 0.7.0"])
|
151
|
-
s.add_development_dependency(%q<rspec-action_view>, [">= 0.3.1"])
|
152
|
-
s.add_development_dependency(%q<rails-app-spec>, [">= 0.3.0"])
|
136
|
+
s.add_development_dependency(%q<rspec>, [">= 2.4.1"])
|
153
137
|
s.add_development_dependency(%q<devise-spec>, [">= 0.1.3"])
|
154
138
|
s.add_development_dependency(%q<roles-spec>, [">= 0.1.3"])
|
155
139
|
s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
|
156
140
|
s.add_runtime_dependency(%q<colorize>, [">= 0.5.8"])
|
157
|
-
s.add_runtime_dependency(%q<devise-links>, [">= 0.2.
|
158
|
-
s.add_runtime_dependency(%q<cancan-rest-links>, [">= 0.2.
|
159
|
-
s.add_runtime_dependency(%q<cancan-permits>, [">= 0.3.10"])
|
141
|
+
s.add_runtime_dependency(%q<devise-links>, [">= 0.2.3"])
|
142
|
+
s.add_runtime_dependency(%q<cancan-rest-links>, [">= 0.2.3"])
|
160
143
|
s.add_runtime_dependency(%q<devise>, [">= 1.1.5"])
|
161
144
|
s.add_runtime_dependency(%q<cancan>, [">= 1.4.1"])
|
162
145
|
s.add_runtime_dependency(%q<rails>, [">= 3.0.1"])
|
163
|
-
s.add_runtime_dependency(%q<
|
164
|
-
s.add_runtime_dependency(%q<
|
165
|
-
s.add_runtime_dependency(%q<
|
166
|
-
s.add_runtime_dependency(%q<sugar-high>, [">= 0.3.1"])
|
146
|
+
s.add_runtime_dependency(%q<rails_artifactor>, ["~> 0.3.3"])
|
147
|
+
s.add_runtime_dependency(%q<r3_plugin_toolbox>, [">= 0.4.1"])
|
148
|
+
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
167
149
|
else
|
168
|
-
s.add_dependency(%q<
|
169
|
-
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.0"])
|
170
|
-
s.add_dependency(%q<cancan-permits>, [">= 0.3.4"])
|
171
|
-
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
172
|
-
s.add_dependency(%q<colorize>, [">= 0.5.8"])
|
173
|
-
s.add_dependency(%q<devise>, [">= 1.1.5"])
|
174
|
-
s.add_dependency(%q<cancan>, [">= 1.4.0"])
|
175
|
-
s.add_dependency(%q<rails>, [">= 3.0.1"])
|
176
|
-
s.add_dependency(%q<rails3_artifactor>, [">= 0.3.2"])
|
177
|
-
s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
|
178
|
-
s.add_dependency(%q<r3_plugin_toolbox>, [">= 0.4.0"])
|
179
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.3.1"])
|
180
|
-
s.add_dependency(%q<rspec>, [">= 2.0.1"])
|
181
|
-
s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
|
182
|
-
s.add_dependency(%q<rspec-action_view>, [">= 0.3.1"])
|
183
|
-
s.add_dependency(%q<rails-app-spec>, [">= 0.3.0"])
|
150
|
+
s.add_dependency(%q<rspec>, [">= 2.4.1"])
|
184
151
|
s.add_dependency(%q<devise-spec>, [">= 0.1.3"])
|
185
152
|
s.add_dependency(%q<roles-spec>, [">= 0.1.3"])
|
186
153
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
187
154
|
s.add_dependency(%q<colorize>, [">= 0.5.8"])
|
188
|
-
s.add_dependency(%q<devise-links>, [">= 0.2.
|
189
|
-
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.
|
190
|
-
s.add_dependency(%q<cancan-permits>, [">= 0.3.10"])
|
155
|
+
s.add_dependency(%q<devise-links>, [">= 0.2.3"])
|
156
|
+
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.3"])
|
191
157
|
s.add_dependency(%q<devise>, [">= 1.1.5"])
|
192
158
|
s.add_dependency(%q<cancan>, [">= 1.4.1"])
|
193
159
|
s.add_dependency(%q<rails>, [">= 3.0.1"])
|
194
|
-
s.add_dependency(%q<
|
195
|
-
s.add_dependency(%q<
|
196
|
-
s.add_dependency(%q<
|
197
|
-
s.add_dependency(%q<sugar-high>, [">= 0.3.1"])
|
160
|
+
s.add_dependency(%q<rails_artifactor>, ["~> 0.3.3"])
|
161
|
+
s.add_dependency(%q<r3_plugin_toolbox>, [">= 0.4.1"])
|
162
|
+
s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
198
163
|
end
|
199
164
|
else
|
200
|
-
s.add_dependency(%q<
|
201
|
-
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.0"])
|
202
|
-
s.add_dependency(%q<cancan-permits>, [">= 0.3.4"])
|
203
|
-
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
204
|
-
s.add_dependency(%q<colorize>, [">= 0.5.8"])
|
205
|
-
s.add_dependency(%q<devise>, [">= 1.1.5"])
|
206
|
-
s.add_dependency(%q<cancan>, [">= 1.4.0"])
|
207
|
-
s.add_dependency(%q<rails>, [">= 3.0.1"])
|
208
|
-
s.add_dependency(%q<rails3_artifactor>, [">= 0.3.2"])
|
209
|
-
s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
|
210
|
-
s.add_dependency(%q<r3_plugin_toolbox>, [">= 0.4.0"])
|
211
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.3.1"])
|
212
|
-
s.add_dependency(%q<rspec>, [">= 2.0.1"])
|
213
|
-
s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
|
214
|
-
s.add_dependency(%q<rspec-action_view>, [">= 0.3.1"])
|
215
|
-
s.add_dependency(%q<rails-app-spec>, [">= 0.3.0"])
|
165
|
+
s.add_dependency(%q<rspec>, [">= 2.4.1"])
|
216
166
|
s.add_dependency(%q<devise-spec>, [">= 0.1.3"])
|
217
167
|
s.add_dependency(%q<roles-spec>, [">= 0.1.3"])
|
218
168
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
219
169
|
s.add_dependency(%q<colorize>, [">= 0.5.8"])
|
220
|
-
s.add_dependency(%q<devise-links>, [">= 0.2.
|
221
|
-
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.
|
222
|
-
s.add_dependency(%q<cancan-permits>, [">= 0.3.10"])
|
170
|
+
s.add_dependency(%q<devise-links>, [">= 0.2.3"])
|
171
|
+
s.add_dependency(%q<cancan-rest-links>, [">= 0.2.3"])
|
223
172
|
s.add_dependency(%q<devise>, [">= 1.1.5"])
|
224
173
|
s.add_dependency(%q<cancan>, [">= 1.4.1"])
|
225
174
|
s.add_dependency(%q<rails>, [">= 3.0.1"])
|
226
|
-
s.add_dependency(%q<
|
227
|
-
s.add_dependency(%q<
|
228
|
-
s.add_dependency(%q<
|
229
|
-
s.add_dependency(%q<sugar-high>, [">= 0.3.1"])
|
175
|
+
s.add_dependency(%q<rails_artifactor>, ["~> 0.3.3"])
|
176
|
+
s.add_dependency(%q<r3_plugin_toolbox>, [">= 0.4.1"])
|
177
|
+
s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
230
178
|
end
|
231
179
|
end
|
232
180
|
|
@@ -22,8 +22,7 @@ Rails3::Plugin::Extender.new do
|
|
22
22
|
load File.dirname(__FILE__) + '/after_init/role_config.rb'
|
23
23
|
|
24
24
|
if defined? Cream::UserControl
|
25
|
-
|
26
|
-
ApplicationController.class_eval "include Cream::UserControl"
|
25
|
+
ApplicationController.send :include, Cream::UserControl
|
27
26
|
else
|
28
27
|
puts "Cream::UserControl not defined!"
|
29
28
|
end
|
@@ -2,7 +2,7 @@ require 'sugar-high/file'
|
|
2
2
|
require 'sugar-high/module'
|
3
3
|
require 'cream'
|
4
4
|
require 'rails3_artifactor'
|
5
|
-
require '
|
5
|
+
require 'generators/cream/helpers/all'
|
6
6
|
|
7
7
|
module Cancan
|
8
8
|
module Generators
|
@@ -13,7 +13,7 @@ module Cancan
|
|
13
13
|
class_option :gems, :type => :boolean, :default => false, :desc => "Add gems to gemfile?"
|
14
14
|
|
15
15
|
def cancan_configure
|
16
|
-
|
16
|
+
logit!
|
17
17
|
cancan_gems if gems?
|
18
18
|
cancan_exception_handling
|
19
19
|
end
|
@@ -21,7 +21,8 @@ module Cancan
|
|
21
21
|
protected
|
22
22
|
|
23
23
|
include Rails3::Assist::BasicLogger
|
24
|
-
extend Rails3::Assist::UseMacro
|
24
|
+
extend Rails3::Assist::UseMacro
|
25
|
+
include Cream::GeneratorHelper
|
25
26
|
|
26
27
|
use_helpers :controller, :app
|
27
28
|
|
@@ -29,10 +30,6 @@ module Cancan
|
|
29
30
|
options[:gems]
|
30
31
|
end
|
31
32
|
|
32
|
-
def logfile
|
33
|
-
options[:logfile]
|
34
|
-
end
|
35
|
-
|
36
33
|
def cancan_gems
|
37
34
|
gem 'cancan'
|
38
35
|
gem 'cancan-rest-links'
|
@@ -46,11 +43,11 @@ module Cancan
|
|
46
43
|
# CanCan access denied exception handling
|
47
44
|
def cancan_exception_handling
|
48
45
|
if rescue_exists?
|
49
|
-
|
46
|
+
debug! "CanCan rescue statement already exists"
|
50
47
|
return
|
51
48
|
end
|
52
49
|
|
53
|
-
|
50
|
+
debug! "Insert cancan rescue statement into application controller"
|
54
51
|
insert_into_controller :application, :after => "ActionController::Base\n" do
|
55
52
|
%{
|
56
53
|
rescue_from CanCan::AccessDenied do |exception|
|
@@ -2,7 +2,6 @@ require 'sugar-high/file'
|
|
2
2
|
require 'sugar-high/module'
|
3
3
|
require 'cream'
|
4
4
|
require 'rails3_artifactor'
|
5
|
-
require 'logging_assist'
|
6
5
|
require 'generators/cream/helpers/all'
|
7
6
|
|
8
7
|
module Cream
|
@@ -13,10 +12,11 @@ module Cream
|
|
13
12
|
# ORM to use
|
14
13
|
class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use"
|
15
14
|
class_option :logfile, :type => :string, :default => nil, :desc => "Logfile location"
|
15
|
+
class_option :logging, :type => :boolean, :default => false, :desc => "Logging on?"
|
16
16
|
class_option :guest_user, :type => :boolean, :default => true, :desc => "Create guest user"
|
17
17
|
|
18
18
|
def configure_application
|
19
|
-
|
19
|
+
logit!
|
20
20
|
|
21
21
|
app_orm unless active_record?
|
22
22
|
|
@@ -65,7 +65,7 @@ require "rails/test_unit/railtie"
|
|
65
65
|
|
66
66
|
def insert_flash_displayer name, layout_content
|
67
67
|
return if layout_content =~ /<%=\s+#{name}\s+%>/
|
68
|
-
|
68
|
+
debug! "insert_flash_displayer: #{name}"
|
69
69
|
insert_into_view :layouts => :application, :after => '<body>' do
|
70
70
|
%Q{<p class="#{name}"><%= #{name} %></p>}
|
71
71
|
end
|
@@ -2,7 +2,6 @@ require 'sugar-high/file'
|
|
2
2
|
require 'sugar-high/module'
|
3
3
|
require 'cream'
|
4
4
|
require 'rails3_artifactor'
|
5
|
-
require 'logging_assist'
|
6
5
|
require 'active_support'
|
7
6
|
require 'generators/cream/helpers/all'
|
8
7
|
|
@@ -22,15 +21,18 @@ module Cream
|
|
22
21
|
class_option :guest_user, :type => :boolean, :default => true, :desc => "Create guest user", :aliases => '-guest'
|
23
22
|
|
24
23
|
# Roles
|
25
|
-
class_option :default_roles, :type => :boolean, :default => true, :desc => "Create default roles :admin and :guest", :aliases => '-dr'
|
26
24
|
class_option :roles, :type => :array, :default => [], :desc => "Roles to create", :aliases => '-r'
|
27
25
|
|
28
|
-
class_option :
|
26
|
+
# class_option :default_user_types, :type => :boolean, :default => true, :desc => "Create default user types (:admin)", :aliases => '-dut'
|
27
|
+
class_option :user_types, :type => :array, :default => ['Admin'], :desc => "Devise Users to create that override the generic base User", :aliases => '-ut'
|
28
|
+
class_option :registrations_for, :type => :array, :default => [], :desc => "User types to have individual registration"
|
29
29
|
|
30
30
|
# ORM to use
|
31
31
|
class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use", :aliases => '-o'
|
32
32
|
|
33
33
|
class_option :locales, :type => :array, :default => ['all'], :desc => "List of locales - 'all' means ALL locales", :aliases => '-l'
|
34
|
+
|
35
|
+
class_option :logging, :type => :boolean, :default => false, :desc => "Logging on?"
|
34
36
|
class_option :logfile, :type => :string, :default => nil, :desc => "Logfile location", :aliases => '-lf'
|
35
37
|
|
36
38
|
class_option :configure, :type => :array, :default => [], :desc => "Finetune which generators to run: app, permits, roles, devise, cancan", :aliases => '-c'
|
@@ -43,7 +45,8 @@ module Cream
|
|
43
45
|
class_option :user_name, :type => :boolean, :default => true, :desc => "Add username as login option", :aliases => '-un'
|
44
46
|
class_option :login_type, :type => :string, :default => 'generic', :desc => "How to login: 'email', 'username', 'generic' (i.e 'username' or 'email')", :aliases => '-lt'
|
45
47
|
|
46
|
-
def main
|
48
|
+
def main
|
49
|
+
logit!
|
47
50
|
execute_generator if validate_orm && validate_strategy
|
48
51
|
end
|
49
52
|
|
@@ -86,7 +89,7 @@ module Cream
|
|
86
89
|
|
87
90
|
def run_migrations
|
88
91
|
return if orm != :active_record
|
89
|
-
|
92
|
+
debug! "Running DB migrations"
|
90
93
|
execute "rake db:migrate"
|
91
94
|
end
|
92
95
|
|
@@ -95,24 +98,24 @@ module Cream
|
|
95
98
|
end
|
96
99
|
|
97
100
|
def run_devise
|
98
|
-
rgen "devise:config #{user_class} --orm #{orm}" # --user-types #{user_types}
|
99
|
-
rgen "devise:users --orm #{orm} --roles #{roles_list} --user-types #{user_types_list} --no-gems"
|
101
|
+
rgen "devise:config #{user_class} --orm #{orm} --logging #{logging?}" # --user-types #{user_types}
|
102
|
+
rgen "devise:users --orm #{orm} --roles #{roles_list} --user-types #{user_types_list} #{registrations_for} --logging #{logging?} --no-gems"
|
100
103
|
|
101
104
|
say("Devise credentials not customized since --customize option was not used to say so!", :green) if !customize_credentials?
|
102
105
|
|
103
|
-
rgen "devise:customize #{user_class} --orm #{orm} --login-type #{login_type} #{user_name_option}" if customize_credentials?
|
106
|
+
rgen "devise:customize #{user_class} --orm #{orm} --login-type #{login_type} #{user_name_option} --logging #{logging?}" if customize_credentials?
|
104
107
|
end
|
105
108
|
|
106
109
|
def run_cancan
|
107
|
-
rgen "cancan:config --orm #{orm} --no-gems"
|
110
|
+
rgen "cancan:config --orm #{orm} --no-gems --logging #{logging?}"
|
108
111
|
end
|
109
112
|
|
110
113
|
def run_roles
|
111
|
-
rgen "roles:config #{user_class} --orm #{orm} --roles #{roles_list} --strategy #{strategy}"
|
114
|
+
rgen "roles:config #{user_class} --orm #{orm} --roles #{roles_list} --strategy #{strategy} --logging #{logging?}"
|
112
115
|
end
|
113
116
|
|
114
117
|
def run_permits
|
115
|
-
rgen "permits:config --orm #{orm} --roles #{roles_list} --no-gems"
|
118
|
+
rgen "permits:config --orm #{orm} --roles #{roles_list} --no-gems --logging #{logging?}"
|
116
119
|
end
|
117
120
|
|
118
121
|
def cream_initializer
|
@@ -127,8 +130,14 @@ require 'cream/configure/rails'
|
|
127
130
|
end
|
128
131
|
end
|
129
132
|
|
133
|
+
def registrations_for
|
134
|
+
list = options[:registrations_for].join(' ')
|
135
|
+
return "--registrations-for #{list}" if !list.blank?
|
136
|
+
end
|
137
|
+
|
130
138
|
def guest_user_option
|
131
|
-
"--guest-user" if guest_user?
|
139
|
+
return "--guest-user" if guest_user?
|
140
|
+
"--no-guest-user"
|
132
141
|
end
|
133
142
|
|
134
143
|
def customize_credentials?
|
@@ -165,7 +174,7 @@ require 'cream/configure/rails'
|
|
165
174
|
|
166
175
|
def cream_locales
|
167
176
|
return if locales_to_generate.empty?
|
168
|
-
|
177
|
+
debug! "Generate Cream locale files"
|
169
178
|
locales_to_generate.each do |locale|
|
170
179
|
src = File.expand_path "config/locales/cream.#{locale}.yml".path.up(5), __FILE__
|
171
180
|
copy_file src, "config/locales/cream.#{locale}.yml"
|
@@ -3,6 +3,21 @@ require_all File.dirname(__FILE__)
|
|
3
3
|
|
4
4
|
module Cream
|
5
5
|
module GeneratorHelper
|
6
|
+
def logit!
|
7
|
+
if logging?
|
8
|
+
require 'logging_assist'
|
9
|
+
logger.add_logfile :logfile => logfile
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def debug! msg
|
14
|
+
logger.debug msg if logging?
|
15
|
+
end
|
16
|
+
|
17
|
+
def info! msg
|
18
|
+
logger.info msg if logging?
|
19
|
+
end
|
20
|
+
|
6
21
|
def self.included(base)
|
7
22
|
base.class_eval do
|
8
23
|
include Orm
|
@@ -5,13 +5,14 @@ module Cream
|
|
5
5
|
options[:logfile]
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
end
|
8
|
+
# def default_user_types?
|
9
|
+
# options[:default_user_types]
|
10
|
+
# end
|
11
11
|
|
12
12
|
def roles
|
13
|
-
defaults = default_roles? ? ['guest', 'admin'] : []
|
14
|
-
(options[:roles] + defaults).flat_uniq
|
13
|
+
# defaults = default_roles? ? ['guest', 'admin'] : []
|
14
|
+
# (options[:roles] + defaults).flat_uniq
|
15
|
+
options[:roles]
|
15
16
|
end
|
16
17
|
|
17
18
|
def has_user_model?
|
@@ -22,9 +23,9 @@ module Cream
|
|
22
23
|
self.class.use_orm :"#{orm}"
|
23
24
|
end
|
24
25
|
|
25
|
-
def admin_user_option
|
26
|
-
|
27
|
-
end
|
26
|
+
# def admin_user_option
|
27
|
+
# admin_user? ? "--admin-user #{admin_user}" : ''
|
28
|
+
# end
|
28
29
|
|
29
30
|
def roles_list
|
30
31
|
roles.join(' ')
|
@@ -34,6 +35,18 @@ module Cream
|
|
34
35
|
options[:gems]
|
35
36
|
end
|
36
37
|
|
38
|
+
def logfile
|
39
|
+
options[:logfile]
|
40
|
+
end
|
41
|
+
|
42
|
+
def logging?
|
43
|
+
options[:logging]
|
44
|
+
end
|
45
|
+
|
46
|
+
def logging_on?
|
47
|
+
logfile && logging?
|
48
|
+
end
|
49
|
+
|
37
50
|
def document_store?
|
38
51
|
[:mongoid, :mongo_mapper, :couch_db].include? orm
|
39
52
|
end
|
@@ -50,13 +63,15 @@ module Cream
|
|
50
63
|
options[:strategy]
|
51
64
|
end
|
52
65
|
|
53
|
-
def user_types
|
66
|
+
def user_types
|
67
|
+
# defaults = default_user_types? ? ['admin'] : []
|
68
|
+
# (options[:user_types] + defaults).flat_uniq
|
54
69
|
options[:user_types]
|
55
70
|
end
|
56
71
|
|
57
|
-
def admin_user?
|
58
|
-
|
59
|
-
end
|
72
|
+
# def admin_user?
|
73
|
+
# options[:admin_user]
|
74
|
+
# end
|
60
75
|
|
61
76
|
def sym_roles
|
62
77
|
roles.map(&:to_sym)
|