roles_active_record 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem "require_all", '~> 1.2.0'
9
9
  gem "roles_generic", '~> 0.3.2'
10
10
 
11
11
  gem 'rails3_artifactor', '>= 0.3.1'
12
- gem 'logging_assist', '>= 0.1.6'
12
+ gem 'logging_assist', '>= 0.2.0'
13
13
 
14
14
  group :test do
15
15
  gem "rspec", ">= 2.0.1"
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ begin
20
20
  gem.add_dependency "roles_generic", '>= 0.3.2'
21
21
 
22
22
  gem.add_dependency 'rails3_artifactor', '>= 0.3.1'
23
- gem.add_dependency 'logging_assist', '>= 0.1.6'
23
+ gem.add_dependency 'logging_assist', '>= 0.2.0'
24
24
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
25
25
  end
26
26
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -26,25 +26,25 @@ module ActiveRecord
26
26
  logger.debug "apply_role_strategy for : #{strategy} in model #{user_class}"
27
27
 
28
28
  if !valid_strategy?
29
- say "Strategy '#{strategy}' is not valid, at least not for Active Record", :red
29
+ logger.error "Strategy '#{strategy}' is not valid, at least not for Active Record"
30
30
  return
31
31
  end
32
32
 
33
- if !has_model? user_class
34
- say "Could not apply roles strategy to #{user_class} model since the model file was not found", :red
33
+ if !has_model? user_file
34
+ logger.error "Could not apply roles strategy to #{user_class} model since the model file was not found"
35
35
  return
36
36
  end
37
37
 
38
38
  begin
39
39
  logger.debug "Trying to insert roles code into #{user_class}"
40
- insert_into_model name.as_filename do
40
+ insert_into_model user_file do
41
41
  insertion_text
42
42
  end
43
43
 
44
44
  copy_role_models if roles_model_strategy?
45
45
  rescue
46
46
  # logger.debug "Error applying roles strategy to #{name}"
47
- say "Error applying roles strategy to #{user_class}"
47
+ logger.error "Error applying roles strategy to #{user_class}"
48
48
  end
49
49
  end
50
50
 
@@ -56,6 +56,18 @@ module ActiveRecord
56
56
 
57
57
  include Rails3::Assist::BasicLogger
58
58
 
59
+ def user_file
60
+ user_class.as_filename
61
+ end
62
+
63
+ def role_file
64
+ role_class.as_filename
65
+ end
66
+
67
+ def user_role_file
68
+ role_class.as_filename
69
+ end
70
+
59
71
  def copy_role_models
60
72
  logger.debug 'copy_role_models'
61
73
  case strategy.to_sym
@@ -67,16 +79,15 @@ module ActiveRecord
67
79
  end
68
80
 
69
81
  def copy_one_role_model
70
- logger.debug "copy_one_role_model: #{role_class.underscore}"
71
-
72
- template 'one_role/role.rb', "app/models/#{role_class.underscore}.rb"
82
+ logger.debug "copying role model for one_role strategy: #{role_file}"
83
+ template 'one_role/role.rb', "app/models/#{role_file}.rb"
73
84
  end
74
85
 
75
86
  def copy_many_roles_models
76
- logger.debug "copy_many_roles_models: #{role_class.underscore} and #{user_role_class.underscore}"
87
+ logger.debug "copying role models for many_roles strategy: #{role_file} and #{user_file}"
77
88
 
78
- template 'many_roles/role.rb', "app/models/#{role_class.underscore}.rb"
79
- template 'many_roles/user_role.rb', "app/models/#{user_role_class.underscore}.rb"
89
+ template 'many_roles/role.rb', "app/models/#{role_file}.rb"
90
+ template 'many_roles/user_role.rb', "app/models/#{user_role_file}.rb"
80
91
  end
81
92
 
82
93
  def valid_strategy?
@@ -134,7 +145,7 @@ module ActiveRecord
134
145
 
135
146
  def strategy_options
136
147
  if role_class != 'Role' || user_role_class != 'UserRole' && role_ref_strategy?
137
- return ", :role_class => :#{options[:role_class] || 'role'}, :user_role_class => :#{options[:user_role_class] || 'user_role'}"
148
+ return ", :role_class => '#{role_class}', :user_role_class => '#{user_role_class}'"
138
149
  end
139
150
  ''
140
151
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{roles_active_record}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
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-01-09}
12
+ s.date = %q{2011-01-10}
13
13
  s.description = %q{Makes it easy to set a role strategy on your User model in Active Record}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -142,7 +142,7 @@ Gem::Specification.new do |s|
142
142
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
143
143
  s.add_runtime_dependency(%q<roles_generic>, ["~> 0.3.2"])
144
144
  s.add_runtime_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
145
- s.add_runtime_dependency(%q<logging_assist>, [">= 0.1.6"])
145
+ s.add_runtime_dependency(%q<logging_assist>, [">= 0.2.0"])
146
146
  s.add_development_dependency(%q<rspec>, [">= 2.0.1"])
147
147
  s.add_development_dependency(%q<database_cleaner>, [">= 0.5"])
148
148
  s.add_development_dependency(%q<generator-spec>, [">= 0.7.0"])
@@ -154,7 +154,7 @@ Gem::Specification.new do |s|
154
154
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
155
155
  s.add_runtime_dependency(%q<roles_generic>, [">= 0.3.2"])
156
156
  s.add_runtime_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
157
- s.add_runtime_dependency(%q<logging_assist>, [">= 0.1.6"])
157
+ s.add_runtime_dependency(%q<logging_assist>, [">= 0.2.0"])
158
158
  else
159
159
  s.add_dependency(%q<activerecord>, [">= 3.0.1"])
160
160
  s.add_dependency(%q<activesupport>, [">= 3.0.1"])
@@ -164,7 +164,7 @@ Gem::Specification.new do |s|
164
164
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
165
165
  s.add_dependency(%q<roles_generic>, ["~> 0.3.2"])
166
166
  s.add_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
167
- s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
167
+ s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
168
168
  s.add_dependency(%q<rspec>, [">= 2.0.1"])
169
169
  s.add_dependency(%q<database_cleaner>, [">= 0.5"])
170
170
  s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
@@ -176,7 +176,7 @@ Gem::Specification.new do |s|
176
176
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
177
177
  s.add_dependency(%q<roles_generic>, [">= 0.3.2"])
178
178
  s.add_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
179
- s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
179
+ s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
180
180
  end
181
181
  else
182
182
  s.add_dependency(%q<activerecord>, [">= 3.0.1"])
@@ -187,7 +187,7 @@ Gem::Specification.new do |s|
187
187
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
188
188
  s.add_dependency(%q<roles_generic>, ["~> 0.3.2"])
189
189
  s.add_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
190
- s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
190
+ s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
191
191
  s.add_dependency(%q<rspec>, [">= 2.0.1"])
192
192
  s.add_dependency(%q<database_cleaner>, [">= 0.5"])
193
193
  s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
@@ -199,7 +199,7 @@ Gem::Specification.new do |s|
199
199
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
200
200
  s.add_dependency(%q<roles_generic>, [">= 0.3.2"])
201
201
  s.add_dependency(%q<rails3_artifactor>, [">= 0.3.1"])
202
- s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
202
+ s.add_dependency(%q<logging_assist>, [">= 0.2.0"])
203
203
  end
204
204
  end
205
205
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 5
9
- version: 0.4.5
8
+ - 6
9
+ version: 0.4.6
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: 2011-01-09 00:00:00 +01:00
17
+ date: 2011-01-10 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -145,9 +145,9 @@ dependencies:
145
145
  - !ruby/object:Gem::Version
146
146
  segments:
147
147
  - 0
148
- - 1
149
- - 6
150
- version: 0.1.6
148
+ - 2
149
+ - 0
150
+ version: 0.2.0
151
151
  type: :runtime
152
152
  prerelease: false
153
153
  version_requirements: *id009
@@ -323,9 +323,9 @@ dependencies:
323
323
  - !ruby/object:Gem::Version
324
324
  segments:
325
325
  - 0
326
- - 1
327
- - 6
328
- version: 0.1.6
326
+ - 2
327
+ - 0
328
+ version: 0.2.0
329
329
  type: :runtime
330
330
  prerelease: false
331
331
  version_requirements: *id021