cream 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.2
1
+ 0.8.3
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.2"
8
+ s.version = "0.8.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{2010-12-18}
12
+ s.date = %q{2010-12-20}
13
13
  s.description = %q{Provides assistance for setting up Session, Role and Permission systems for a Rails 3 app. Support for multiple ORMs}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -86,7 +86,7 @@ module Cream
86
86
 
87
87
  def run_devise
88
88
  # rgen "devise:config --orm #{orm} --no-gems"
89
- rgen "devise:config --orm #{orm}"
89
+ rgen "devise:config --orm #{orm} #{admin_user_option}"
90
90
  rgen "devise:users --orm #{orm} #{admin_user_option} --no-gems"
91
91
  end
92
92
 
@@ -95,11 +95,11 @@ module Cream
95
95
  end
96
96
 
97
97
  def run_roles
98
- rgen "roles:config --orm #{orm} --roles #{roles.join(' ')} --strategy #{strategy}"
98
+ rgen "roles:config --orm #{orm} --roles #{roles_list} --strategy #{strategy}"
99
99
  end
100
100
 
101
101
  def run_permits
102
- rgen "permits:config --orm #{orm} --roles #{roles.join(' ')} --no-gems"
102
+ rgen "permits:config --orm #{orm} --roles #{roles_list} --no-gems"
103
103
  end
104
104
 
105
105
  def admin_user_option
@@ -115,7 +115,7 @@ module Cream
115
115
  end
116
116
 
117
117
  def orm
118
- @orm ||= get_orm options[:orm].underscore.to_sym
118
+ @orm ||= get_orm options[:orm].to_s.underscore.to_sym
119
119
  end
120
120
 
121
121
  def valid_orms
@@ -146,6 +146,10 @@ module Cream
146
146
  options[:default_roles]
147
147
  end
148
148
 
149
+ def roles_list
150
+ roles.join(' ')
151
+ end
152
+
149
153
  def roles
150
154
  defaults = default_roles? ? ['guest', 'admin'] : []
151
155
  options[:roles] + defaults
@@ -10,9 +10,10 @@ module Devise
10
10
  desc "Configure Devise"
11
11
 
12
12
  # ORM to use
13
- class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use"
14
- class_option :logfile, :type => :string, :default => nil, :desc => "Logfile location"
15
- class_option :gems, :type => :boolean, :default => true, :desc => "Add gems to gemfile?"
13
+ class_option :orm, :type => :string, :default => 'active_record', :desc => "ORM to use"
14
+ class_option :logfile, :type => :string, :default => nil, :desc => "Logfile location"
15
+ class_option :gems, :type => :boolean, :default => true, :desc => "Add gems to gemfile?"
16
+ class_option :admin_user, :type => :boolean, :default => false, :desc => "Setup for admin user"
16
17
 
17
18
  def configure_devise
18
19
  logger.add_logfile :logfile => logfile if logfile
@@ -23,7 +24,7 @@ module Devise
23
24
  end
24
25
 
25
26
  devise_install
26
- [:orm, :mailer, :protection].each{|m| send(:"#{m}_configure!", orm) }
27
+ [:orm, :mailer, :protection, :routes].each{|m| send(:"#{m}_configure!", orm) }
27
28
  end
28
29
 
29
30
  protected
@@ -120,6 +121,22 @@ module Devise
120
121
  end
121
122
  end
122
123
 
124
+ def routes_configure!
125
+ insert_into_routes do
126
+ "devise_for #{model_routes}"
127
+ end
128
+ end
129
+
130
+ def admin_user?
131
+ options[:admin_user]
132
+ end
133
+
134
+ def model_routes
135
+ return ':users, :admins' if admin_user?
136
+ ':users'
137
+ end
138
+
139
+
123
140
  def protection_configure! orm
124
141
  logger.debug "Configuring: devise authentication filter"
125
142
  ## Add Devise protection to Application controller:
@@ -22,7 +22,7 @@ module Permits
22
22
  permits_gems if gems?
23
23
 
24
24
  # Run permits generator to generate permit for each role
25
- rgen "cancan:permits --roles #{roles} --orm #{orm}"
25
+ rgen "cancan:permits --roles #{roles_list} --orm #{orm}"
26
26
  rgen "cancan:licenses"
27
27
  end
28
28
 
@@ -55,6 +55,10 @@ module Permits
55
55
  options[:roles]
56
56
  end
57
57
 
58
+ def roles_list
59
+ roles.join(' ')
60
+ end
61
+
58
62
  def orm
59
63
  options[:orm]
60
64
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 2
9
- version: 0.8.2
8
+ - 3
9
+ version: 0.8.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-18 00:00:00 +01:00
17
+ date: 2010-12-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency