cantango 0.9.4.6 → 0.9.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,9 +36,32 @@ Run bundler in a terminal/console from the folder of your Gemfile (root folder o
36
36
 
37
37
  @$ bundle@
38
38
 
39
- h2. Update Nov 21, 2011
39
+ h2. Update Nov 24, 2011
40
40
 
41
- Version 0.9.4.6 has been released. Fixes bug in configuration/permit_registry.
41
+ Version 0.9.4.7 has been released.
42
+
43
+ * Now enables configuration of role and role group systems directly:
44
+
45
+ Defaults:
46
+
47
+ * Role system - "simple_roles":https://github.com/stanislaw/simple_roles
48
+ * Role group system - "troles":https://github.com/kristianmandrup/troles
49
+
50
+ You can override the defaults like this:
51
+
52
+ <pre>
53
+ CanTango.config do |c|
54
+ c.roles.role_system = :troles
55
+ end
56
+ </pre>
57
+
58
+ Then CanTango should auto-configure to use the correct list methods of that system. You can even add your own role system with custom mappings. Here I tell CanTango that I'm using a system I call _MyRoles_ and that the method added to role candidates (fx User) to return the list of roles, will be @#list_of_roles@ and the method to check if he is in (or has) a specific role will be @is_in_role?@. Same goes for role groups, using @role_groups.add_role_group_system@.
59
+
60
+ <pre>
61
+ CanTango.config do |c|
62
+ c.roles.add_role_system :my_roles => {:list => :list_of_roles, :has => :is_in_role?}
63
+ end
64
+ </pre>
42
65
 
43
66
  The "wiki":https://github.com/kristianmandrup/cantango/wiki has been rewritten and updated to reflect all latest design changes and feature additions.
44
67
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4.6
1
+ 0.9.4.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cantango"
8
- s.version = "0.9.4.6"
8
+ s.version = "0.9.4.7"
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", "Stanislaw Pankevich"]
@@ -3,23 +3,40 @@ module CanTango
3
3
  class RoleGroups < RoleRegistry
4
4
  include Singleton
5
5
 
6
- attr_writer :role_groups_system
6
+ def role_group_system= name
7
+ raise ArgumentError, "Must be a label" if !name.kind_of_label?
8
+ @role_group_system = name.to_sym
9
+ end
10
+
11
+ def role_groups_list_map= role_systems_hash
12
+ raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_systems_hash}" if !role_systems_hash.kind_of?(Hash)
13
+ @role_groups_list_map = role_systems_hash
14
+ end
7
15
 
8
- def role_groups_system
9
- @role_groups_system ||= :troles
16
+ def role_group_system
17
+ @role_group_system ||= :troles
18
+ end
19
+
20
+ def add_role_group_system role_system_hash
21
+ raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_system_hash}" if !role_system_hash.kind_of?(Hash)
22
+ role_groups_list_map.merge! role_system
10
23
  end
11
24
 
12
25
  def default_has_method
13
- :in_role_group?
26
+ role_group_methods[:has] || :in_role_group?
14
27
  end
15
28
 
16
29
  def default_list_method
17
- role_groups_list_map[role_groups_system] || :role_groups_list
30
+ role_group_methods[:list] || :role_groups_list
31
+ end
32
+
33
+ def role_group_methods
34
+ role_groups_list_map[role_group_system] || {}
18
35
  end
19
36
 
20
37
  def role_groups_list_map
21
38
  @role_groups_list_map ||= {
22
- :troles => :role_group_list
39
+ :troles => {:list => :role_group_list}
23
40
  }
24
41
  end
25
42
  end
@@ -3,28 +3,43 @@ module CanTango
3
3
  class Roles < RoleRegistry
4
4
  include Singleton
5
5
 
6
- attr_writer :roles_system
6
+ def role_system= name
7
+ raise ArgumentError, "Must be a label" if !name.kind_of_label?
8
+ @role_system = name.to_sym
9
+ end
10
+
11
+ def roles_list_map= role_systems_hash
12
+ raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_systems_hash}" if !role_systems_hash.kind_of?(Hash)
13
+ @roles_list_map = role_systems_hash
14
+ end
15
+
16
+ def role_system
17
+ @role_system ||= :simple_roles
18
+ end
7
19
 
8
- def roles_system
9
- @roles_system ||= :troles
20
+ def add_role_system role_system_hash
21
+ raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_system_hash}" if !role_system_hash.kind_of?(Hash)
22
+ roles_list_map.merge! role_system
10
23
  end
11
24
 
12
25
  def default_has_method
13
- :has_role?
26
+ role_system_methods[:list] || :has_role?
14
27
  end
15
28
 
16
29
  def default_list_method
17
- role_list_map[roles_system] || :roles_list
30
+ role_system_methods[:list] || :roles_list
18
31
  end
19
32
 
20
- def role_list_map
21
- @role_list_map ||= {
22
- :troles => :role_list
33
+ def role_system_methods
34
+ roles_list_map[role_system] || {}
35
+ end
36
+
37
+ def roles_list_map
38
+ @roles_list_map ||= {
39
+ :troles => {:list => :role_list},
40
+ :simple_roles => {:list => :roles_list}
23
41
  }
24
42
  end
25
43
  end
26
44
  end
27
45
  end
28
-
29
-
30
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantango
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4.6
4
+ version: 0.9.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-11-24 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &760593560 !ruby/object:Gem::Requirement
17
+ requirement: &903784170 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *760593560
25
+ version_requirements: *903784170
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: cancan
28
- requirement: &760570980 !ruby/object:Gem::Requirement
28
+ requirement: &903783700 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *760570980
36
+ version_requirements: *903783700
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sugar-high
39
- requirement: &760567230 !ruby/object:Gem::Requirement
39
+ requirement: &903783080 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.6.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *760567230
47
+ version_requirements: *903783080
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sweetloader
50
- requirement: &760562470 !ruby/object:Gem::Requirement
50
+ requirement: &903782120 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.1.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *760562470
58
+ version_requirements: *903782120
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: hashie
61
- requirement: &760559870 !ruby/object:Gem::Requirement
61
+ requirement: &903781490 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0.4'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *760559870
69
+ version_requirements: *903781490
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-rails
72
- requirement: &760553610 !ruby/object:Gem::Requirement
72
+ requirement: &903780620 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.6.1
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *760553610
80
+ version_requirements: *903780620
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: forgery
83
- requirement: &760551830 !ruby/object:Gem::Requirement
83
+ requirement: &903780130 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0.3'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *760551830
91
+ version_requirements: *903780130
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: factory_girl
94
- requirement: &760549670 !ruby/object:Gem::Requirement
94
+ requirement: &903778990 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *760549670
102
+ version_requirements: *903778990
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: sqlite3
105
- requirement: &760536730 !ruby/object:Gem::Requirement
105
+ requirement: &903778330 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *760536730
113
+ version_requirements: *903778330
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: sourcify
116
- requirement: &760536290 !ruby/object:Gem::Requirement
116
+ requirement: &903777880 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *760536290
124
+ version_requirements: *903777880
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: dkastner-moneta
127
- requirement: &760535520 !ruby/object:Gem::Requirement
127
+ requirement: &903777250 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: '1.0'
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *760535520
135
+ version_requirements: *903777250
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: rspec
138
- requirement: &760535020 !ruby/object:Gem::Requirement
138
+ requirement: &903776620 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ! '>='
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: 2.4.0
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *760535020
146
+ version_requirements: *903776620
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: jeweler
149
- requirement: &760534760 !ruby/object:Gem::Requirement
149
+ requirement: &903775990 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ! '>='
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: 1.6.4
155
155
  type: :development
156
156
  prerelease: false
157
- version_requirements: *760534760
157
+ version_requirements: *903775990
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: bundler
160
- requirement: &760534360 !ruby/object:Gem::Requirement
160
+ requirement: &903775040 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ! '>='
@@ -165,10 +165,10 @@ dependencies:
165
165
  version: 1.0.1
166
166
  type: :development
167
167
  prerelease: false
168
- version_requirements: *760534360
168
+ version_requirements: *903775040
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: rdoc
171
- requirement: &760533950 !ruby/object:Gem::Requirement
171
+ requirement: &903774590 !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements:
174
174
  - - ! '>='
@@ -176,7 +176,7 @@ dependencies:
176
176
  version: '0'
177
177
  type: :development
178
178
  prerelease: false
179
- version_requirements: *760533950
179
+ version_requirements: *903774590
180
180
  description: ! 'Define your permission rules as role- or role group specific permits.
181
181
 
182
182
  Integrates well with multiple Devise user acounts.
@@ -873,7 +873,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
873
873
  version: '0'
874
874
  segments:
875
875
  - 0
876
- hash: 967356769
876
+ hash: -1049245295
877
877
  required_rubygems_version: !ruby/object:Gem::Requirement
878
878
  none: false
879
879
  requirements: