cancan-permits 0.3.6 → 0.3.7
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/README.markdown +176 -164
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/cancan-permits.gemspec +11 -2
- data/spec/cancan-permits/license/save_license_spec.rb +23 -0
- data/spec/cancan-permits/loader/config/permits.yml +12 -0
- data/spec/spec_helper.rb +2 -0
- metadata +39 -6
data/README.markdown
CHANGED
@@ -2,17 +2,6 @@
|
|
2
2
|
|
3
3
|
Role specific Permits for use with [CanCan](http://github.com/ryanb/cancan) permission system.
|
4
4
|
|
5
|
-
## Changes
|
6
|
-
|
7
|
-
See Changelog.txt (Major updates as per Nov 24. 2010)
|
8
|
-
|
9
|
-
Nov 28:
|
10
|
-
Added Generators to create individual Permit and License!
|
11
|
-
|
12
|
-
Nov 29:
|
13
|
-
Added ability to specify YAML files with configurations for Permits, Licenses and even Permissions for individual users.
|
14
|
-
Thanks to 'ticktricktrack' for the request and suggestion. (I hope you can use this and move on from here...)
|
15
|
-
|
16
5
|
## Install
|
17
6
|
|
18
7
|
<code>gem install cancan-permits</code>
|
@@ -31,58 +20,76 @@ See [CanCan permits demo app](https://github.com/kristianmandrup/cancan-permits-
|
|
31
20
|
|
32
21
|
## Rails 3 configuration
|
33
22
|
|
23
|
+
Note: This description does not apply to how CanCan-permits is used with [Cream](https://github.com/kristianmandrup/cream)
|
24
|
+
|
34
25
|
Create a rails initializer with the following code:
|
35
|
-
<code>
|
36
|
-
module Cream
|
37
|
-
# specify all roles available in your app!
|
38
|
-
def self.available_roles
|
39
|
-
[:guest, :admin]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
</code>
|
43
26
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Cream.available_roles
|
49
|
-
end
|
50
|
-
|
51
|
-
def has_role? role
|
52
|
-
(self.role || 'guest').to_sym == role.to_sym
|
53
|
-
end
|
27
|
+
<pre>module Cream
|
28
|
+
# specify all roles available in your app!
|
29
|
+
def self.available_roles
|
30
|
+
[:guest, :admin]
|
54
31
|
end
|
55
|
-
|
32
|
+
end
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
Modify the User model in 'models/user.rb' (optional)
|
56
36
|
|
57
|
-
|
37
|
+
<pre>class User
|
38
|
+
def self.roles
|
39
|
+
Cream.available_roles
|
40
|
+
end
|
41
|
+
|
42
|
+
def has_role? role
|
43
|
+
(self.role || 'guest').to_sym == role.to_sym
|
44
|
+
end
|
45
|
+
end
|
46
|
+
</pre>
|
58
47
|
|
59
|
-
|
60
|
-
- config/user_permissions.yml
|
48
|
+
## Load Permissions from yaml files
|
61
49
|
|
62
|
-
|
50
|
+
Permissions can be defined in yaml files in the config directory of your Rails app.
|
51
|
+
These permissions will then be applied at the appropriate point when calculation permissions of the user.
|
63
52
|
|
64
|
-
|
65
|
-
|
66
|
-
|
53
|
+
* Individual user permissions
|
54
|
+
* Permits
|
55
|
+
* Licenses
|
56
|
+
|
57
|
+
### Permission editor
|
58
|
+
|
59
|
+
A simple [Permits editor](https://github.com/kristianmandrup/permits_editor) is available. This is a Rails 3 app which provides a web interface to
|
60
|
+
edit the permits config files for: user permissions, permits and licenses.
|
61
|
+
|
62
|
+
I would like to have this editor refactored into an engine and later into a mountable app so that this administrative interface can easily be integrated into a Cream app.
|
63
|
+
|
64
|
+
_You are most welcome to help in this effort ;)_
|
65
|
+
|
66
|
+
### Individual user permissions
|
67
|
+
|
68
|
+
You can define individual user permissions in a yaml file.
|
69
|
+
|
70
|
+
YAML file: _config/user_permissions.yml_
|
71
|
+
|
72
|
+
Each key at the top level is expected to match an email value for a user.
|
73
|
+
|
74
|
+
Example yaml config file:
|
75
|
+
<pre>abc@mail.ru:
|
67
76
|
can:
|
68
77
|
update: [Comment, Fruit, Car, Friendship]
|
69
78
|
manage:
|
70
79
|
- Article
|
71
80
|
owns:
|
72
81
|
- User
|
73
|
-
mike.shedlock.com:
|
82
|
+
mike.shedlock@acc.com:
|
74
83
|
can:
|
75
84
|
read:
|
76
85
|
- all
|
77
86
|
cannot:
|
78
87
|
update:
|
79
88
|
- Post
|
80
|
-
</
|
81
|
-
|
82
|
-
Usage in a permit
|
89
|
+
</pre>
|
83
90
|
|
84
|
-
|
85
|
-
class AdminPermit < Permit::Base
|
91
|
+
Loading YAML user_permits file in a Permit:
|
92
|
+
<pre>class AdminPermit < Permit::Base
|
86
93
|
def initialize(ability, options = {})
|
87
94
|
super
|
88
95
|
end
|
@@ -91,22 +98,23 @@ class AdminPermit < Permit::Base
|
|
91
98
|
super
|
92
99
|
return if !role_match? user
|
93
100
|
can :manage, :all
|
101
|
+
|
94
102
|
load_rules user
|
95
103
|
end
|
96
104
|
end
|
97
|
-
</
|
105
|
+
</pre>
|
106
|
+
|
107
|
+
The call to #load_rules will call both _#load_user_roles_ and _#load_role_rules_. Hence by default it applies both the _user_permits_ and _permits_ config files.
|
108
|
+
If you want, you can call these methods individually in case only want to apply one set of rules.
|
98
109
|
|
99
|
-
|
100
|
-
If you want you can call these methods individually, fx if you only want to apply one set of rules.
|
110
|
+
### Permit rules
|
101
111
|
|
102
|
-
|
103
|
-
- config/permits.yml
|
112
|
+
YAML file: _config/permits.yml_
|
104
113
|
|
105
114
|
Each key at the top level is expected to match a permit/role name.
|
106
115
|
|
107
116
|
Example yml config file:
|
108
|
-
<
|
109
|
-
admin:
|
117
|
+
<pre>admin:
|
110
118
|
can:
|
111
119
|
manage:
|
112
120
|
- Article
|
@@ -118,33 +126,19 @@ guest:
|
|
118
126
|
cannot:
|
119
127
|
manage:
|
120
128
|
- User
|
121
|
-
</
|
129
|
+
</pre>
|
122
130
|
|
123
|
-
|
131
|
+
As you can see
|
124
132
|
|
125
|
-
|
126
|
-
class GuestPermit < Permit::Base
|
127
|
-
def initialize(ability, options = {})
|
128
|
-
super
|
129
|
-
end
|
133
|
+
### License permissions
|
130
134
|
|
131
|
-
|
132
|
-
super
|
133
|
-
return if !role_match? user
|
134
|
-
can :manage, :all
|
135
|
-
load_rules user
|
136
|
-
end
|
137
|
-
end
|
138
|
-
</code>
|
139
|
-
|
140
|
-
*License permissions:*
|
141
|
-
- config/licenses.yml
|
135
|
+
YAML file: _config/licenses.yml_
|
142
136
|
|
143
137
|
Each key at the top level is expected to match a license name.
|
144
138
|
|
145
139
|
Example yml config file:
|
146
|
-
|
147
|
-
blogging:
|
140
|
+
|
141
|
+
<pre>blogging:
|
148
142
|
can:
|
149
143
|
manage:
|
150
144
|
- Article
|
@@ -156,25 +150,24 @@ admin:
|
|
156
150
|
cannot:
|
157
151
|
manage:
|
158
152
|
- User
|
159
|
-
</
|
160
|
-
|
161
|
-
Usage in a license
|
153
|
+
</pre>
|
162
154
|
|
163
|
-
|
164
|
-
class UserAdminLicense < License::Base
|
155
|
+
Usage in a license:
|
156
|
+
<pre>class UserAdminLicense < License::Base
|
165
157
|
def initialize name
|
166
158
|
super
|
167
159
|
end
|
168
160
|
|
169
161
|
def enforce!
|
170
162
|
can(:manage, User)
|
163
|
+
|
171
164
|
load_rules
|
172
165
|
end
|
173
|
-
</
|
166
|
+
</pre>
|
174
167
|
|
175
168
|
### User Roles
|
176
169
|
|
177
|
-
|
170
|
+
_CanCan permits_ requires that you have some kind of Role system in place and that User#has_role? uses this Role system.
|
178
171
|
You can either add a 'role' field directly to User or fx use a [Roles Generic ](https://github.com/kristianmandrup/roles_generic) role strategy.
|
179
172
|
|
180
173
|
## Usage
|
@@ -188,39 +181,42 @@ To add Roles to your app, you might consider using a *roles* gem such as [Roles
|
|
188
181
|
|
189
182
|
### Define which Roles are available
|
190
183
|
|
191
|
-
|
192
|
-
<pre>
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
[:admin, :guest]
|
201
|
-
end
|
184
|
+
Default configuration:
|
185
|
+
<pre>module Permits::Roles
|
186
|
+
def self.available
|
187
|
+
if defined? ::Cream
|
188
|
+
Cream.available_roles
|
189
|
+
elsif defined? ::User
|
190
|
+
User.roles
|
191
|
+
else
|
192
|
+
[:admin, :guest]
|
202
193
|
end
|
203
194
|
end
|
195
|
+
end
|
204
196
|
</pre>
|
205
197
|
|
198
|
+
_CanCan permits_ will first try to assume it is used with Cream. If not it will fallback to try and get the roles from User#roles.
|
199
|
+
If all else fails, it will assume only the :guest and :admin roles are available.
|
200
|
+
|
201
|
+
You can always monkeypatch this configuration implementation to suit your own needs.
|
202
|
+
|
206
203
|
### Define a Permit for each Role.
|
207
204
|
|
208
|
-
|
205
|
+
You can use the _Permits generator_ to generate your permits. Permits should be placed in the app/permits folder.
|
209
206
|
|
210
207
|
Permit example:
|
211
|
-
<pre
|
212
|
-
|
213
|
-
|
214
|
-
super
|
215
|
-
end
|
216
|
-
|
217
|
-
def permit?(user, options = {})
|
218
|
-
super
|
219
|
-
return if !role_match? user
|
220
|
-
can :manage, :all
|
221
|
-
end
|
208
|
+
<pre>class AdminPermit < Permit::Base
|
209
|
+
def initialize(ability, options = {})
|
210
|
+
super
|
222
211
|
end
|
223
|
-
|
212
|
+
|
213
|
+
def permit?(user, options = {})
|
214
|
+
super
|
215
|
+
return if !role_match? user
|
216
|
+
can :manage, :all
|
217
|
+
end
|
218
|
+
end
|
219
|
+
</pre>
|
224
220
|
|
225
221
|
## Special Permits
|
226
222
|
|
@@ -232,9 +228,7 @@ The Any permit, can be used to set permissions that should hold true for a user
|
|
232
228
|
F.ex, maybe in your app, any user should be able to read comments, articles and posts:
|
233
229
|
|
234
230
|
For this to hold true, put the following permit logic in your Any permit.
|
235
|
-
<pre>
|
236
|
-
can :read, [Comment, Article, Post]
|
237
|
-
</pre>
|
231
|
+
<pre>can :read, [Comment, Article, Post]</pre>
|
238
232
|
|
239
233
|
### System permit
|
240
234
|
|
@@ -242,9 +236,10 @@ The System permit is run before any of the other permits. This gives you a chanc
|
|
242
236
|
By returning a value of :break you force a break-out from the permission flow, ensuring none of the other permits are run.
|
243
237
|
|
244
238
|
Example:
|
245
|
-
The system permit can be used to allow management of all resources
|
239
|
+
The system permit can be used to allow management of all resources when the request is from localhost (which usually means "in development mode").
|
240
|
+
By default this logic is setup and ready to go.
|
246
241
|
|
247
|
-
You can
|
242
|
+
You can configure this simply by setting the following boolean class variable:
|
248
243
|
|
249
244
|
<code>Permits::Configuration.localhost_manager = true</code>
|
250
245
|
|
@@ -254,31 +249,27 @@ By default the permits for the roles System and Guest are also generated.
|
|
254
249
|
|
255
250
|
### Licenses
|
256
251
|
|
257
|
-
Permits
|
258
|
-
Licenses are a way to group logical fragments of permission statements to be reused across multiple
|
259
|
-
The generator will create a licenses.rb file in the permits folder where you can put your licenses. For more complex scenarios, you might want to have a separate
|
260
|
-
licenses subfolder where you put your license files.
|
252
|
+
Permits support creation of more fine-grained permits through the use of _Licenses_.
|
253
|
+
Licenses are a way to group logical fragments of permission statements to be reused across multiple Permits.
|
261
254
|
|
262
|
-
|
263
|
-
<pre><code>
|
264
|
-
class BloggingLicense - License::Base
|
265
|
-
def initialize name
|
266
|
-
super
|
267
|
-
end
|
255
|
+
You can use the _License generator_ to generate your licenses. Lincenses should be placed in the _app/licenses_ folder.
|
268
256
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
</code></pre>
|
257
|
+
License example:
|
258
|
+
<pre>class BloggingLicense < License::Base
|
259
|
+
def initialize name
|
260
|
+
super
|
261
|
+
end
|
276
262
|
|
277
|
-
|
263
|
+
def enforce!
|
264
|
+
can(:read, Blog)
|
265
|
+
can(:create, Post)
|
266
|
+
owns(user, Post)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
</pre>
|
278
270
|
|
279
271
|
Usage example:
|
280
|
-
<pre
|
281
|
-
class GuestPermit - Permit::Base
|
272
|
+
<pre>class GuestPermit < Permit::Base
|
282
273
|
def initialize(ability, options = {})
|
283
274
|
super
|
284
275
|
end
|
@@ -291,9 +282,9 @@ Usage example:
|
|
291
282
|
end
|
292
283
|
end
|
293
284
|
end
|
294
|
-
</
|
285
|
+
</pre>
|
295
286
|
|
296
|
-
|
287
|
+
The permits system will try to find a license named UserAdminLicense and BloggingLicense in this example and then call _#enforce!_ on each license.
|
297
288
|
|
298
289
|
## ORMs
|
299
290
|
|
@@ -303,13 +294,19 @@ The easiest option is to directly set the orm as a class variable. An appropriat
|
|
303
294
|
Permits::Ability.orm = :data_mapper
|
304
295
|
</pre>
|
305
296
|
|
306
|
-
Alternatively set it for the Ability instance for more fine grained control
|
307
|
-
<pre>
|
308
|
-
ability = Permits::Ability.new(@editor, :strategy => :string)
|
309
|
-
</pre>
|
310
|
-
|
311
297
|
The ORMs currently supported (and tested) are :active_record, :data_mapper, :mongoid, :mongo_mapper
|
312
298
|
|
299
|
+
For more fine grained control, you can set a :strategy option directly on the Ability instance. This way the ownership strategy is set explicitly.
|
300
|
+
The current valid values are :default and :string.
|
301
|
+
|
302
|
+
The strategy option :string can be used for most ORMs. Setting orm to :active_record or :generic makes use of the :default strategy.
|
303
|
+
All the other ORMs use the :string ownership strategy,
|
304
|
+
|
305
|
+
Note: You can dive into the code and implement your own strategy if needed.
|
306
|
+
|
307
|
+
Setting the ownership strategy directly:
|
308
|
+
<pre>ability = Permits::Ability.new(@editor, :strategy => :string)</pre>
|
309
|
+
|
313
310
|
## Advanced Permit options
|
314
311
|
|
315
312
|
Note that the options hash (second argument of the initializer) can also be used to pass custom data for the permission system to use to determine whether an action
|
@@ -317,26 +314,23 @@ should be permitted. An example use of this is to pass in the HTTP request objec
|
|
317
314
|
|
318
315
|
The ability would most likely be configured with the current request in a view helper or directly from within the controller.
|
319
316
|
|
320
|
-
<code>
|
321
|
-
editor_ability = Permits::Ability.new(@editor, :request => request)
|
322
|
-
</code>
|
317
|
+
<code>editor_ability = Permits::Ability.new(@editor, :request => request)</code>
|
323
318
|
|
324
|
-
A Permit can then use this information
|
325
|
-
|
326
|
-
<code>
|
327
|
-
def permit?(user, options = {})
|
328
|
-
request = options[:request]
|
329
|
-
if request && request.host.localhost? && localhost_manager?
|
330
|
-
can(:manage, :all)
|
331
|
-
return :break
|
332
|
-
end
|
333
|
-
end
|
334
|
-
</code>
|
319
|
+
A Permit can then use this extra information
|
335
320
|
|
336
|
-
|
337
|
-
|
321
|
+
Advanced #permit? functionality:
|
322
|
+
<pre>def permit?(user, options = {})
|
323
|
+
request = options[:request]
|
324
|
+
if request && request.host.localhost? && localhost_manager?
|
325
|
+
can(:manage, :all)
|
326
|
+
return :break
|
327
|
+
end
|
328
|
+
end
|
329
|
+
</pre>
|
330
|
+
|
331
|
+
### Global manage permission for localhost
|
338
332
|
|
339
|
-
|
333
|
+
The Permits system allows a global setting in order to allow localhost to manage all objects. This can be useful in development or administration mode.
|
340
334
|
|
341
335
|
To configure permits to allow localhost to manage objects:
|
342
336
|
<code>
|
@@ -345,17 +339,28 @@ To configure permits to allow localhost to manage objects:
|
|
345
339
|
|
346
340
|
Please provide suggestions and feedback on how to improve this :)
|
347
341
|
|
342
|
+
Assuming the following:
|
343
|
+
- a request object is present
|
344
|
+
- the host of the request is 'localhost'
|
345
|
+
- Permits::Configuration has been configured to allow localhost to manage objects:
|
346
|
+
|
347
|
+
Then the user is allowed to manage all objects and no other Permits will be evaluated to restrict further.
|
348
|
+
|
349
|
+
Note: In the code above, the built in <code>#localhost_manager?</code> method is used.
|
350
|
+
|
348
351
|
## Generators
|
349
352
|
|
350
353
|
The gem comes with the following generators
|
351
354
|
|
352
|
-
* cancan:permits
|
353
|
-
* cancan:permit
|
354
|
-
* cancan:licenses
|
355
|
-
* cancan:license
|
355
|
+
* cancan:permits - generate multiple permits
|
356
|
+
* cancan:permit - generate a single permit
|
357
|
+
* cancan:licenses - generate multiple licenses
|
358
|
+
* cancan:license - generate a single license
|
356
359
|
|
357
360
|
## Permits Generator
|
358
361
|
|
362
|
+
Generates one or more permits in _app/permits_
|
363
|
+
|
359
364
|
Options
|
360
365
|
* --orm : The ORM to use (active_record, data_mapper, mongoid, mongo_mapper) - creates a Rails initializer
|
361
366
|
* --initializer : A Rails 3 initializer file for Permits is generated by default. Use --no-initializer option to disable this
|
@@ -366,15 +371,18 @@ Options
|
|
366
371
|
|
367
372
|
### What does the generator generate?
|
368
373
|
|
369
|
-
To get an understanding of what the generator generates for a Rails 3 application, try to run the spec
|
370
|
-
|
371
|
-
<code>$ rspec spec/generators/cancan/permits_generator_spec.rb</code>
|
374
|
+
To get an understanding of what the generator generates for a Rails 3 application, try to run the spec _permit_generator_spec.rb_ with _RSpec 2_ as follows:
|
372
375
|
|
373
|
-
In the file
|
376
|
+
In the file _permits_generator_spec.rb_ make the following change <code>config.remove_temp_dir = false</code>
|
374
377
|
This will prevent the rails /tmp dir from being deleted after the test run, so you can inspect what is generated in the Rails app.
|
375
378
|
|
379
|
+
Now run the generator spec to see the result:
|
380
|
+
<code>$ rspec spec/generators/cancan/permits_generator_spec.rb</code>
|
381
|
+
|
376
382
|
## Licenses Generator
|
377
383
|
|
384
|
+
Generates one or more licenses in _app/licenses_
|
385
|
+
|
378
386
|
Options
|
379
387
|
* --licenses : The licenses to generate; default UserAdmin and Blogging licenses are generated
|
380
388
|
* --default-licenses : By default exemplar licenses are generated. Use --no-default-licenses option to disable this
|
@@ -395,15 +403,19 @@ Create both specific and default licenses:
|
|
395
403
|
|
396
404
|
### What does the generator generate?
|
397
405
|
|
398
|
-
To get an understanding of what the generator generates for a Rails 3 application, try to run the spec
|
406
|
+
To get an understanding of what the generator generates for a Rails 3 application, try to run the spec _licenses_generator_spec.rb_ with rspec 2 as follows:
|
399
407
|
|
408
|
+
In the file _licenses_generator_spec.rb_ make the following change <code>config.remove_temp_dir = false</code>
|
409
|
+
This will prevent the rails /tmp dir from being deleted after the test run, so you can inspect what is generated in the Rails app.
|
410
|
+
|
411
|
+
Now run the generator spec to see the result:
|
400
412
|
<code>$ rspec spec/generators/cancan/licenses_generator_spec.rb</code>
|
401
413
|
|
402
|
-
In the file <code>licenses_generator_spec.rb</code> make the following change <code>config.remove_temp_dir = false</code>
|
403
|
-
This will prevent the rails /tmp dir from being deleted after the test run, so you can inspect what is generated in the Rails app.
|
404
414
|
|
405
415
|
## License Generator
|
406
416
|
|
417
|
+
Generates a single license in _app/licenses_
|
418
|
+
|
407
419
|
<code>rails g cancan:license [NAME]</code>
|
408
420
|
|
409
421
|
Options
|
@@ -420,7 +432,7 @@ Generate licenses:
|
|
420
432
|
|
421
433
|
## Permit Generator
|
422
434
|
|
423
|
-
|
435
|
+
Generates a single license in _app/permits_
|
424
436
|
|
425
437
|
<code>rails g cancan:permit [ROLE]</code>
|
426
438
|
|
@@ -436,9 +448,9 @@ Generate licenses:
|
|
436
448
|
|
437
449
|
<code>$ rails g cancan:permit editor --owns article post --read blog --licenses blog_editing</code>
|
438
450
|
|
439
|
-
# TODO
|
451
|
+
# TODO
|
440
452
|
|
441
|
-
The Permits generator should attempt to attempt to uncover which roles are currently defined as available to the system
|
453
|
+
The Permits generator should attempt to attempt to uncover which roles are currently defined as available to the system, trying Cream#available_roles and then User#roles. It could then generate permits for those roles. Any roles specified in the --roles option should be merged with the roles available in the app.
|
442
454
|
|
443
455
|
## Note on Patches/Pull Requests
|
444
456
|
|
data/Rakefile
CHANGED
@@ -15,7 +15,9 @@ begin
|
|
15
15
|
gem.add_dependency 'require_all', "~> 1.2.0"
|
16
16
|
gem.add_dependency 'sugar-high', "~> 0.3.0"
|
17
17
|
gem.add_dependency 'rails3_artifactor', "~> 0.3.1"
|
18
|
+
gem.add_dependency 'activemodel', ">= 3.0.1"
|
18
19
|
gem.add_dependency 'activesupport', ">= 3.0.1"
|
20
|
+
gem.add_dependency 'activeresource', ">= 3.0.1"
|
19
21
|
gem.add_dependency 'logging_assist', ">= 0.1.6"
|
20
22
|
|
21
23
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/cancan-permits.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cancan-permits}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.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"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-24}
|
13
13
|
s.description = %q{Role specific Permits for use with CanCan permission system}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -62,7 +62,9 @@ Gem::Specification.new do |s|
|
|
62
62
|
"spec/active_record/owner_permits_spec.rb",
|
63
63
|
"spec/active_record/permits_spec.rb",
|
64
64
|
"spec/active_record/spec_helper.rb",
|
65
|
+
"spec/cancan-permits/license/save_license_spec.rb",
|
65
66
|
"spec/cancan-permits/loader/config/licenses.yml",
|
67
|
+
"spec/cancan-permits/loader/config/permits.yml",
|
66
68
|
"spec/cancan-permits/loader/config/user_permissions.yml",
|
67
69
|
"spec/cancan-permits/loader/license_loader_spec.rb",
|
68
70
|
"spec/cancan-permits/loader/permits_loader_spec.rb",
|
@@ -119,6 +121,7 @@ Gem::Specification.new do |s|
|
|
119
121
|
"spec/active_record/owner_permits_spec.rb",
|
120
122
|
"spec/active_record/permits_spec.rb",
|
121
123
|
"spec/active_record/spec_helper.rb",
|
124
|
+
"spec/cancan-permits/license/save_license_spec.rb",
|
122
125
|
"spec/cancan-permits/loader/license_loader_spec.rb",
|
123
126
|
"spec/cancan-permits/loader/permits_loader_spec.rb",
|
124
127
|
"spec/cancan-permits/loader/user_permissions_loader.rb",
|
@@ -173,7 +176,9 @@ Gem::Specification.new do |s|
|
|
173
176
|
s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
|
174
177
|
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.0"])
|
175
178
|
s.add_runtime_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
|
179
|
+
s.add_runtime_dependency(%q<activemodel>, [">= 3.0.1"])
|
176
180
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.1"])
|
181
|
+
s.add_runtime_dependency(%q<activeresource>, [">= 3.0.1"])
|
177
182
|
s.add_runtime_dependency(%q<logging_assist>, [">= 0.1.6"])
|
178
183
|
else
|
179
184
|
s.add_dependency(%q<rspec>, [">= 2.0.1"])
|
@@ -183,7 +188,9 @@ Gem::Specification.new do |s|
|
|
183
188
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
184
189
|
s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
|
185
190
|
s.add_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
|
191
|
+
s.add_dependency(%q<activemodel>, [">= 3.0.1"])
|
186
192
|
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
193
|
+
s.add_dependency(%q<activeresource>, [">= 3.0.1"])
|
187
194
|
s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
|
188
195
|
end
|
189
196
|
else
|
@@ -194,7 +201,9 @@ Gem::Specification.new do |s|
|
|
194
201
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
195
202
|
s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
|
196
203
|
s.add_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
|
204
|
+
s.add_dependency(%q<activemodel>, [">= 3.0.1"])
|
197
205
|
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
206
|
+
s.add_dependency(%q<activeresource>, [">= 3.0.1"])
|
198
207
|
s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
|
199
208
|
end
|
200
209
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'cancan-permits'
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
DIR = File.dirname(__FILE__)
|
6
|
+
|
7
|
+
require_all DIR + '/../../../app/models'
|
8
|
+
|
9
|
+
describe 'Save License to yaml' do
|
10
|
+
before :each do
|
11
|
+
@license = LicenseConfig.new :name => 'blogging'
|
12
|
+
@license.can = PermissionSet.new :read => ['Article', 'Post']
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should save license to license.yml file" do
|
16
|
+
puts @license
|
17
|
+
puts @license.to_yaml
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 7
|
9
|
+
version: 0.3.7
|
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-
|
17
|
+
date: 2010-12-24 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
type: :runtime
|
124
124
|
version_requirements: *id007
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: activemodel
|
127
127
|
prerelease: false
|
128
128
|
requirement: &id008 !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
@@ -138,9 +138,39 @@ dependencies:
|
|
138
138
|
type: :runtime
|
139
139
|
version_requirements: *id008
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: activesupport
|
142
142
|
prerelease: false
|
143
143
|
requirement: &id009 !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
segments:
|
149
|
+
- 3
|
150
|
+
- 0
|
151
|
+
- 1
|
152
|
+
version: 3.0.1
|
153
|
+
type: :runtime
|
154
|
+
version_requirements: *id009
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: activeresource
|
157
|
+
prerelease: false
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
segments:
|
164
|
+
- 3
|
165
|
+
- 0
|
166
|
+
- 1
|
167
|
+
version: 3.0.1
|
168
|
+
type: :runtime
|
169
|
+
version_requirements: *id010
|
170
|
+
- !ruby/object:Gem::Dependency
|
171
|
+
name: logging_assist
|
172
|
+
prerelease: false
|
173
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
144
174
|
none: false
|
145
175
|
requirements:
|
146
176
|
- - ">="
|
@@ -151,7 +181,7 @@ dependencies:
|
|
151
181
|
- 6
|
152
182
|
version: 0.1.6
|
153
183
|
type: :runtime
|
154
|
-
version_requirements: *
|
184
|
+
version_requirements: *id011
|
155
185
|
description: Role specific Permits for use with CanCan permission system
|
156
186
|
email: kmandrup@gmail.com
|
157
187
|
executables: []
|
@@ -207,7 +237,9 @@ files:
|
|
207
237
|
- spec/active_record/owner_permits_spec.rb
|
208
238
|
- spec/active_record/permits_spec.rb
|
209
239
|
- spec/active_record/spec_helper.rb
|
240
|
+
- spec/cancan-permits/license/save_license_spec.rb
|
210
241
|
- spec/cancan-permits/loader/config/licenses.yml
|
242
|
+
- spec/cancan-permits/loader/config/permits.yml
|
211
243
|
- spec/cancan-permits/loader/config/user_permissions.yml
|
212
244
|
- spec/cancan-permits/loader/license_loader_spec.rb
|
213
245
|
- spec/cancan-permits/loader/permits_loader_spec.rb
|
@@ -291,6 +323,7 @@ test_files:
|
|
291
323
|
- spec/active_record/owner_permits_spec.rb
|
292
324
|
- spec/active_record/permits_spec.rb
|
293
325
|
- spec/active_record/spec_helper.rb
|
326
|
+
- spec/cancan-permits/license/save_license_spec.rb
|
294
327
|
- spec/cancan-permits/loader/license_loader_spec.rb
|
295
328
|
- spec/cancan-permits/loader/permits_loader_spec.rb
|
296
329
|
- spec/cancan-permits/loader/user_permissions_loader.rb
|