roles_generic 0.2.2 → 0.2.3
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/.document +0 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/LICENSE +0 -0
- data/README.markdown +8 -7
- data/Rakefile +0 -0
- data/VERSION +1 -1
- data/lib/generators/roles_model/roles/roles_generator.rb +0 -0
- data/lib/roles_generic/admin.rb +13 -0
- data/lib/roles_generic/base.rb +3 -2
- data/lib/roles_generic/generic/role.rb +0 -0
- data/lib/roles_generic/generic/user/class_methods.rb +0 -0
- data/lib/roles_generic/generic/user/configuration.rb +4 -1
- data/lib/roles_generic/generic/user/implementation.rb +0 -0
- data/lib/roles_generic/generic/user.rb +0 -0
- data/lib/roles_generic/generic.rb +0 -0
- data/lib/roles_generic/namespaces.rb +0 -0
- data/lib/roles_generic/role.rb +0 -0
- data/lib/roles_generic/strategy/multi/many_roles.rb +0 -0
- data/lib/roles_generic/strategy/multi/role_strings.rb +0 -0
- data/lib/roles_generic/strategy/multi/roles_mask.rb +0 -0
- data/lib/roles_generic/strategy/multi/roles_string.rb +0 -0
- data/lib/roles_generic/strategy/single/admin_flag.rb +0 -13
- data/lib/roles_generic/strategy/single/one_role.rb +0 -0
- data/lib/roles_generic/strategy/single/role_string.rb +0 -0
- data/lib/roles_generic/strategy.rb +14 -6
- data/lib/roles_generic.rb +0 -0
- data/roles_generic.gemspec +3 -2
- data/spec/generator_spec_helper.rb +0 -0
- data/spec/generators/admin_flag_generator_spec.rb +0 -0
- data/spec/generators/many_roles_generator_spec.rb +0 -0
- data/spec/generators/one_role_generator_spec.rb +0 -0
- data/spec/generators/role_string_generator_spec.rb +0 -0
- data/spec/generators/role_strings_generator_spec.rb +0 -0
- data/spec/generators/roles_mask_generator_spec.rb +0 -0
- data/spec/generators/roles_string_generator_spec.rb +0 -0
- data/spec/roles_generic/admin_flag_spec.rb +0 -0
- data/spec/roles_generic/many_roles_spec.rb +0 -0
- data/spec/roles_generic/one_role_spec.rb +0 -0
- data/spec/roles_generic/role_string_spec.rb +0 -0
- data/spec/roles_generic/role_strings_spec.rb +0 -0
- data/spec/roles_generic/roles_mask_spec.rb +0 -0
- data/spec/roles_generic/roles_string_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- data/wiki/strategies/admin_flag.textile +0 -0
- data/wiki/strategies/many_roles.textile +0 -0
- data/wiki/strategies/one_role.textile +0 -0
- data/wiki/strategies/role_string.textile +0 -0
- data/wiki/strategies/role_strings.textile +0 -0
- data/wiki/strategies/roles_mask.textile +0 -0
- data/wiki/strategies/roles_string.textile +0 -0
- metadata +4 -3
data/.document
CHANGED
|
File without changes
|
data/.gitignore
CHANGED
|
File without changes
|
data/.rspec
CHANGED
|
File without changes
|
data/LICENSE
CHANGED
|
File without changes
|
data/README.markdown
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Generic role strategies that share the same API and are easy to insert in any existing User model.
|
|
4
4
|
Comes with a Rails 3 generator to instantly configure your Rails 3 app with a Role strategy of choice.
|
|
5
5
|
|
|
6
|
-
I
|
|
6
|
+
I have developed the following *roles* gems for popular ORMs that all support the same roles generic API.
|
|
7
7
|
|
|
8
|
-
* Active Record (
|
|
9
|
-
* DataMapper (
|
|
10
|
-
* Mongoid (roles_mongoid)
|
|
11
|
-
* MongoMapper (
|
|
8
|
+
* Active Record - [roles_active_record](http://github.com/kristianmandrup/roles_active_record)
|
|
9
|
+
* DataMapper - [roles_data_mapper](http://github.com/kristianmandrup/roles_data_mapper)
|
|
10
|
+
* Mongoid - [roles_mongoid](http://github.com/kristianmandrup/roles_mongoid)
|
|
11
|
+
* MongoMapper - [roles_mongo_mapper](http://github.com/kristianmandrup/roles_mongo_mapper))
|
|
12
12
|
|
|
13
13
|
Feel free to roll your own ORM extension for your favorite ORM!
|
|
14
14
|
|
|
@@ -16,8 +16,9 @@ Feel free to roll your own ORM extension for your favorite ORM!
|
|
|
16
16
|
|
|
17
17
|
Roles generic has now been refactored in order to tidy up the code base and make it even more generic, flexible and easy to extend.
|
|
18
18
|
|
|
19
|
-
Currently I'm not sure if the generator fully works. It has a dependency on
|
|
20
|
-
However my gem to test generators (called
|
|
19
|
+
Currently I'm not sure if the generator fully works. It has a dependency on [rails3_artifator](http://github.com/kristianmandrup/rails3_artifator), which should work.
|
|
20
|
+
However my gem to test generators (called [generator-spec](http://github.com/kristianmandrup/generator-spec), is currently not functioning as it has dependencies to other gems that have undergone major
|
|
21
|
+
|
|
21
22
|
refactorings lately. Let me know if the generator works or if not, see if you can make it work using *rails3_artifactor* and let me know the fix ;)
|
|
22
23
|
|
|
23
24
|
## Install
|
data/Rakefile
CHANGED
|
File without changes
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.3
|
|
File without changes
|
data/lib/roles_generic/base.rb
CHANGED
|
@@ -20,7 +20,8 @@ module Roles
|
|
|
20
20
|
|
|
21
21
|
def include_strategy orm, strategy_name, options=nil
|
|
22
22
|
begin
|
|
23
|
-
|
|
23
|
+
module_name = "RoleStrategy::#{orm_name.to_s.camelize}::#{strategy_name.to_s.camelize}"
|
|
24
|
+
constant = module_name.constantize
|
|
24
25
|
|
|
25
26
|
strategy_class_method = %Q{
|
|
26
27
|
def strategy_class
|
|
@@ -37,7 +38,7 @@ module Roles
|
|
|
37
38
|
include constant
|
|
38
39
|
end
|
|
39
40
|
rescue
|
|
40
|
-
raise "No Role strategy module for ORM #{orm}
|
|
41
|
+
raise "No Role strategy module for ORM #{orm.to_s.camelize} for the strategy #{strategy_name}. Module #{module_name} has not been registered"
|
|
41
42
|
end
|
|
42
43
|
constant.apply_options(options) if constant.respond_to? :apply_options
|
|
43
44
|
end
|
|
File without changes
|
|
File without changes
|
|
@@ -7,7 +7,10 @@ module Roles::Generic::User
|
|
|
7
7
|
class_eval do
|
|
8
8
|
include Roles::Generic::User
|
|
9
9
|
include Roles::Generic::User::SingleRole if numericality == :single
|
|
10
|
-
|
|
10
|
+
if type == :role_class
|
|
11
|
+
include Roles::Generic::Role::InstanceMethods
|
|
12
|
+
end
|
|
13
|
+
|
|
11
14
|
include self::Implementation
|
|
12
15
|
|
|
13
16
|
alias_method :role_symbols, :roles
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/roles_generic/role.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,9 +4,17 @@ require 'sugar-high/array'
|
|
|
4
4
|
module Roles::Strategy
|
|
5
5
|
class << self
|
|
6
6
|
NON_INLINE_STRATEGIES = [:one_role, :many_roles]
|
|
7
|
+
|
|
8
|
+
def role_dir
|
|
9
|
+
File.dirname(__FILE__)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def gem_name
|
|
13
|
+
:roles_generic
|
|
14
|
+
end
|
|
7
15
|
|
|
8
16
|
def role_strategies cardinality
|
|
9
|
-
pattern =
|
|
17
|
+
pattern = role_dir + "/strategy/#{cardinality}/*.rb"
|
|
10
18
|
Dir.glob(pattern).file_names(:rb).to_symbols
|
|
11
19
|
end
|
|
12
20
|
|
|
@@ -30,9 +38,9 @@ end
|
|
|
30
38
|
def use_roles_strategy strategy
|
|
31
39
|
cardinality = Roles::Strategy.cardinality(strategy)
|
|
32
40
|
require "roles_generic/strategy/#{cardinality}/#{strategy}"
|
|
33
|
-
|
|
34
|
-
require 'roles_generic/role' if !Roles::Strategy.inline_strategy? strategy
|
|
35
|
-
require "roles_generic/strategy/#{cardinality}/#{strategy}"
|
|
36
|
-
end
|
|
37
|
-
|
|
41
|
+
require "roles_generic/admin" if strategy =~ /admin/
|
|
38
42
|
|
|
43
|
+
gem_name = Roles::Strategy.gem_name
|
|
44
|
+
require "#{gem_name}/role" if !Roles::Strategy.inline_strategy? strategy
|
|
45
|
+
require "#{gem_name}/strategy/#{cardinality}/#{strategy}"
|
|
46
|
+
end
|
data/lib/roles_generic.rb
CHANGED
|
File without changes
|
data/roles_generic.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{roles_generic}
|
|
8
|
-
s.version = "0.2.
|
|
8
|
+
s.version = "0.2.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-09-
|
|
12
|
+
s.date = %q{2010-09-11}
|
|
13
13
|
s.description = %q{Generic role strategies sharing the same API. Easy to insert in any model}
|
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
"VERSION",
|
|
27
27
|
"lib/generators/roles_model/roles/roles_generator.rb",
|
|
28
28
|
"lib/roles_generic.rb",
|
|
29
|
+
"lib/roles_generic/admin.rb",
|
|
29
30
|
"lib/roles_generic/base.rb",
|
|
30
31
|
"lib/roles_generic/generic.rb",
|
|
31
32
|
"lib/roles_generic/generic/role.rb",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 2
|
|
8
|
-
-
|
|
9
|
-
version: 0.2.
|
|
8
|
+
- 3
|
|
9
|
+
version: 0.2.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-09-
|
|
17
|
+
date: 2010-09-11 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -128,6 +128,7 @@ files:
|
|
|
128
128
|
- VERSION
|
|
129
129
|
- lib/generators/roles_model/roles/roles_generator.rb
|
|
130
130
|
- lib/roles_generic.rb
|
|
131
|
+
- lib/roles_generic/admin.rb
|
|
131
132
|
- lib/roles_generic/base.rb
|
|
132
133
|
- lib/roles_generic/generic.rb
|
|
133
134
|
- lib/roles_generic/generic/role.rb
|