roles_generic 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.document +0 -0
  2. data/.gitignore +0 -0
  3. data/.rspec +0 -0
  4. data/LICENSE +0 -0
  5. data/README.markdown +8 -7
  6. data/Rakefile +0 -0
  7. data/VERSION +1 -1
  8. data/lib/generators/roles_model/roles/roles_generator.rb +0 -0
  9. data/lib/roles_generic/admin.rb +13 -0
  10. data/lib/roles_generic/base.rb +3 -2
  11. data/lib/roles_generic/generic/role.rb +0 -0
  12. data/lib/roles_generic/generic/user/class_methods.rb +0 -0
  13. data/lib/roles_generic/generic/user/configuration.rb +4 -1
  14. data/lib/roles_generic/generic/user/implementation.rb +0 -0
  15. data/lib/roles_generic/generic/user.rb +0 -0
  16. data/lib/roles_generic/generic.rb +0 -0
  17. data/lib/roles_generic/namespaces.rb +0 -0
  18. data/lib/roles_generic/role.rb +0 -0
  19. data/lib/roles_generic/strategy/multi/many_roles.rb +0 -0
  20. data/lib/roles_generic/strategy/multi/role_strings.rb +0 -0
  21. data/lib/roles_generic/strategy/multi/roles_mask.rb +0 -0
  22. data/lib/roles_generic/strategy/multi/roles_string.rb +0 -0
  23. data/lib/roles_generic/strategy/single/admin_flag.rb +0 -13
  24. data/lib/roles_generic/strategy/single/one_role.rb +0 -0
  25. data/lib/roles_generic/strategy/single/role_string.rb +0 -0
  26. data/lib/roles_generic/strategy.rb +14 -6
  27. data/lib/roles_generic.rb +0 -0
  28. data/roles_generic.gemspec +3 -2
  29. data/spec/generator_spec_helper.rb +0 -0
  30. data/spec/generators/admin_flag_generator_spec.rb +0 -0
  31. data/spec/generators/many_roles_generator_spec.rb +0 -0
  32. data/spec/generators/one_role_generator_spec.rb +0 -0
  33. data/spec/generators/role_string_generator_spec.rb +0 -0
  34. data/spec/generators/role_strings_generator_spec.rb +0 -0
  35. data/spec/generators/roles_mask_generator_spec.rb +0 -0
  36. data/spec/generators/roles_string_generator_spec.rb +0 -0
  37. data/spec/roles_generic/admin_flag_spec.rb +0 -0
  38. data/spec/roles_generic/many_roles_spec.rb +0 -0
  39. data/spec/roles_generic/one_role_spec.rb +0 -0
  40. data/spec/roles_generic/role_string_spec.rb +0 -0
  41. data/spec/roles_generic/role_strings_spec.rb +0 -0
  42. data/spec/roles_generic/roles_mask_spec.rb +0 -0
  43. data/spec/roles_generic/roles_string_spec.rb +0 -0
  44. data/spec/spec_helper.rb +0 -0
  45. data/wiki/strategies/admin_flag.textile +0 -0
  46. data/wiki/strategies/many_roles.textile +0 -0
  47. data/wiki/strategies/one_role.textile +0 -0
  48. data/wiki/strategies/role_string.textile +0 -0
  49. data/wiki/strategies/role_strings.textile +0 -0
  50. data/wiki/strategies/roles_mask.textile +0 -0
  51. data/wiki/strategies/roles_string.textile +0 -0
  52. 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 am in the process of developing multiple *roles_xxx* gems in order to support this generic API for various popular ORMs, such as:
6
+ I have developed the following *roles* gems for popular ORMs that all support the same roles generic API.
7
7
 
8
- * Active Record (roles_ar)
9
- * DataMapper (roles_dm_)
10
- * Mongoid (roles_mongoid)
11
- * MongoMapper (roles_mm)
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 *rails3_artifactor*, which should work.
20
- However my gem to test generators (called *generator-spec*), is currently not functioning as it has dependencies to other gems that have undergone major
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.2
1
+ 0.2.3
File without changes
@@ -0,0 +1,13 @@
1
+ module AdminRoleCheck
2
+ def admin?
3
+ self.to_s.downcase.to_sym == :admin
4
+ end
5
+ end
6
+
7
+ class String
8
+ include AdminRoleCheck
9
+ end
10
+
11
+ class Symbol
12
+ include AdminRoleCheck
13
+ end
@@ -20,7 +20,8 @@ module Roles
20
20
 
21
21
  def include_strategy orm, strategy_name, options=nil
22
22
  begin
23
- constant = "RoleStrategy::#{orm_name.to_s.camelize}::#{strategy_name.to_s.camelize}".constantize
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} found for strategy #{strategy_name}"
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
- include Roles::Generic::Role::InstanceMethods if type == :role_class
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
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -25,16 +25,3 @@ module RoleStrategy::Generic
25
25
  end
26
26
  end
27
27
 
28
- module AdminRoleCheck
29
- def admin?
30
- self.to_s.downcase.to_sym == :admin
31
- end
32
- end
33
-
34
- class String
35
- include AdminRoleCheck
36
- end
37
-
38
- class Symbol
39
- include AdminRoleCheck
40
- end
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 = File.dirname(__FILE__) + "/strategy/#{cardinality}/*.rb"
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
@@ -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.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-06}
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
- - 2
9
- version: 0.2.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-06 00:00:00 +02:00
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