repository-manager 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5570145fdab6a68044c23360f2cda512bbff93da
4
- data.tar.gz: 63ac568cef21b1e6e1c69f34ec14701a811e393b
3
+ metadata.gz: 7f4887b6bdb653d978499c8da9c904af411cdcdf
4
+ data.tar.gz: 30bcb1450fc36c85e7f45146ddd6d355bcc06032
5
5
  SHA512:
6
- metadata.gz: 3aa7875fc7c3cbcb7653af770e548eade784c6d10dc35bb6e86a8baffcd5c3764acf9133d3cf86386cb1fc98ae33a5ec7c757c4f88ea7723bbb52930bf05a208
7
- data.tar.gz: 82b701bd769e352108cbcf7c25773d1e48ad0b7b068056c6f75f2956429f74cc238124b5182393f8af7228c626aba9f8c65e019f75fa278d81534ca8a8dd54d8
6
+ metadata.gz: 4a4fad797cc95fd161805a8c226baa52d3a8f209871b3679b27aa68f32629cdc3bfb79d39dfed2797f03453ab604be590a527b45b527cdf6e11f16af6370ece3
7
+ data.tar.gz: 01f74b128f2f88026bd078479a0a81268608b9c77ef3830797df2a433c3da52a98edb2df2c022ca8432b567853161abb876d40e3a1d1ee6a796583ee32a663f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- repository-manager (0.1.17)
4
+ repository-manager (0.1.18)
5
5
  ancestry
6
6
  carrierwave (>= 0.5.8)
7
7
  rails (> 3.0.0)
data/README.md CHANGED
@@ -6,7 +6,7 @@ Ruby on Rails plugin (gem) for managing repositories (files/folders/permissions/
6
6
 
7
7
  This gem add functionalities to manage repositories. Each instance (users, groups, etc..) can have it own repository (with files and folders). It can manage them (edit, remove, add, etc) and share them with other objects.
8
8
 
9
- This project is based on the need for a repository manager system for [Collaide](https://github.com/facenord-sud/collaide). A system for easily create/delete files and folders in a repository. For sharing these "repo items" easily with other object with a flexible and complete authorisations management.
9
+ This project is based on the need for a repository manager system for [Collaide](https://github.com/facenord-sud/collaide). A system for easily create/delete files and folders in a repository. For sharing these "repo items" easily with other object with a flexible and complete permissions management.
10
10
 
11
11
  Instead of creating my core repository manager system heavily
12
12
  dependent on our development, I'm trying to implement a generic and potent repository gem.
@@ -72,7 +72,7 @@ end
72
72
  ```
73
73
 
74
74
 
75
- See the chapter [Authorisations](#authorisations) for more details about the permissions.
75
+ See the chapter [Permissions](#permissions) for more details about the permissions.
76
76
 
77
77
  ## Preparing your models
78
78
 
@@ -116,7 +116,7 @@ A few methods are written in those two ways :
116
116
  - method(arg, options)
117
117
  - method!(arg, options) (note the "!")
118
118
 
119
- The two methods do the same, but the one with the "!" returns an Exception error if it is a problem (AuthorisationException or RepositoryManagerException for instance) and the method without "!" return false if it has a problem.
119
+ The two methods do the same, but the one with the "!" returns an Exception error if it is a problem (PermissionException or RepositoryManagerException for instance) and the method without "!" return false if it has a problem.
120
120
 
121
121
  ### How can I create/delete/move a repo_item (file or folder)
122
122
 
@@ -227,7 +227,7 @@ file.sender # Returns user1
227
227
 
228
228
  ```
229
229
 
230
- WARNING : There is no verification if the user has the authorisation to create a file or folder into this group. You have to check this in your controller ! The fact that user1 is the sender of this folder gives him NO AUTHORISATION on it !
230
+ WARNING : There is no verification if the user has the permission to create a file or folder into this group. You have to check this in your controller ! The fact that user1 is the sender of this folder gives him NO AUTHORISATION on it !
231
231
 
232
232
  ### How can I share a repo_item (file/folder)
233
233
 
@@ -254,7 +254,7 @@ sharing = user1.share(the_new_folder, members, options)
254
254
 
255
255
  `sharing_permissions` specifies if the member of the sharing can add or remove other members in this sharing.
256
256
 
257
- See the chapter [Authorisations](#authorisations) for more details.
257
+ See the chapter [Permissions](#permissions) for more details.
258
258
 
259
259
  ### Repository Manager and the nested sharing
260
260
 
@@ -338,7 +338,7 @@ For file details, more infos on [the documentation of the carrierwave gem](https
338
338
  ### How can I manage a sharing
339
339
 
340
340
 
341
- If it has the authorisation, an object can add members to a sharing.
341
+ If it has the permission, an object can add members to a sharing.
342
342
 
343
343
  ```ruby
344
344
  # user1 want to add members to his sharing
@@ -365,14 +365,14 @@ group2.can_remove_from?(sharing) # => false
365
365
  # If user2 (the user who was add with the sharing permissions : {can_add: true, can_remove: false}) add a member in the sharing, he can choose if the permission ':can_add' is true or false, but he can't put ':can_remove' to true (because he don't have this permission himself).
366
366
  ```
367
367
 
368
- If an object has the authorisation, it can remove members from a sharing, else the method return `false` (or raise an AuthorisationException if you user the `remove_members_from!` method).
368
+ If an object has the permission, it can remove members from a sharing, else the method return `false` (or raise an PermissionException if you user the `remove_members_from!` method).
369
369
 
370
370
  ```ruby
371
371
  # user1 want to remove group2 from the sharing `sharing`
372
372
  user1.remove_members_from(sharing, group2) # The second parameter can be an object or an array of object
373
373
  ```
374
374
 
375
- You can directly work with the `sharing`. Be careful, there is NO authorisation control !
375
+ You can directly work with the `sharing`. Be careful, there is NO permission control !
376
376
 
377
377
  ```ruby
378
378
  # Add a member to the sharing `sharing`
@@ -385,36 +385,36 @@ sharing.add_members(member, {can_add: true, can_remove: false})
385
385
  sharing.remove_members([user2, group1])
386
386
  ```
387
387
 
388
- ### Authorisations
388
+ ### Permissions
389
389
 
390
- #### Repository authorisations
390
+ #### Repository permissions
391
391
 
392
- The owner of a `repo_item` (file or folder) has all the authorisations on it. When he share this `repo_item`, he can choose what authorisation he gives to the share. The authorisations are :
392
+ The owner of a `repo_item` (file or folder) has all the permissions on it. When he share this `repo_item`, he can choose what permission he gives to the share. The permissions are :
393
393
  - `can_read?(repo_item)` : The member can read (=download) this file/folder.
394
394
  - `can_create?(repo_item)` : Can create in the repo_item (Note: if repo_item is nil (= own root), always true).
395
395
  - `can_update?(repo_item)` : Can update a repo_item (ex: rename).
396
396
  - `can_delete?(repo_item)` : Can delete a repo_item.
397
397
  - `can_share?(repo_item)` : Can share a repo_item.
398
398
 
399
- To check if a user has one of this authorisation, you just have to write : `user1.can_read?(repo_item)`, `user1.can_share?(repo_item)`, etc (it returns `true` or `false`).
399
+ To check if a user has one of this permission, you just have to write : `user1.can_read?(repo_item)`, `user1.can_share?(repo_item)`, etc (it returns `true` or `false`).
400
400
 
401
401
  NOTICE : An object who can share a repo_item, can't set new permissions that it doesn't have.
402
402
  For instance: `user3` has a `sharing` of `repo_item1` in which it `:can_delete => false` and `:can_share => true`. He can share `repo_item1` with `user4`, but he can't put `:can_delete => true` in the `repo_item_permission` of this new share.
403
403
 
404
- You can get all the authorisations of an `object` in a `repo_item` with this method: `object.get_authorisations(repo_item)`
404
+ You can get all the permissions of an `object` in a `repo_item` with this method: `object.get_permissions(repo_item)`
405
405
 
406
406
  ```ruby
407
- # Gets the repo authorisations
408
- # Return false if the entity has not the authorisation to share this rep
409
- # Return true if the entity can share this rep with all the authorisations
407
+ # Gets the repo permissions
408
+ # Return false if the entity has not the permission to share this rep
409
+ # Return true if the entity can share this rep with all the permissions
410
410
  # Return an Array if the entity can share but with restriction
411
- # Return true if the repo_item is nil (he as all authorisations on his own rep)
412
- def get_authorisations(repo_item = nil)
411
+ # Return true if the repo_item is nil (he as all permissions on his own rep)
412
+ def get_permissions(repo_item = nil)
413
413
  [...]
414
414
  end
415
415
  ```
416
416
 
417
- #### Sharing authorisations
417
+ #### Sharing permissions
418
418
 
419
419
  You can manage the permissions of a member in a sharing. The owner of the sharing has all the permissions. The sharing permissions are:
420
420
  - `can_add_to?(sharing)` : The member can add a new instance in this sharing.
@@ -422,7 +422,7 @@ You can manage the permissions of a member in a sharing. The owner of the sharin
422
422
 
423
423
  To check if the object can add or remove an instance in the sharing, just write : `group1.can_add_to?(sharing)` or `group1.can_remove_from?(sharing)` (it returns `true` or `false`).
424
424
 
425
- Like the repo_item authorisations, you can get the sharing authorisations of an `object` in a `sharing` with : `object.get_sharing_authorisations(sharing)`.
425
+ Like the repo_item permissions, you can get the sharing permissions of an `object` in a `sharing` with : `object.get_sharing_permissions(sharing)`.
426
426
 
427
427
  ### Download a repository
428
428
 
@@ -456,7 +456,6 @@ the_folder.delete_zip
456
456
  ## TODO
457
457
 
458
458
  - Do the rename file method
459
- - Test the copy method
460
459
  - Configure path to save files
461
460
  - Write the methods : share_link.
462
461
  - Snapshot the file if possible
@@ -50,7 +50,7 @@ class RepositoryManager::RepoFile < RepositoryManager::RepoItem
50
50
  def copy(options = {})
51
51
  begin
52
52
  copy!(options)
53
- rescue RepositoryManager::AuthorisationException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
53
+ rescue RepositoryManager::PermissionException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
54
54
  false
55
55
  end
56
56
  end
@@ -1,7 +1,6 @@
1
1
  require 'zip'
2
2
 
3
3
  class RepositoryManager::RepoFolder < RepositoryManager::RepoItem
4
- #attr_accessible :name if RepositoryManager.protected_attributes?
5
4
 
6
5
  validates :name, presence: true
7
6
 
@@ -84,7 +83,7 @@ class RepositoryManager::RepoFolder < RepositoryManager::RepoItem
84
83
  def copy(options = {})
85
84
  begin
86
85
  copy!(options)
87
- rescue RepositoryManager::AuthorisationException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
86
+ rescue RepositoryManager::PermissionException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
88
87
  false
89
88
  end
90
89
  end
@@ -19,8 +19,8 @@ class RepositoryManager::Sharing < ActiveRecord::Base
19
19
  # joins(:sharings_members).where('sharings_members.member_id' => member.id,'sharings_members.member_type' => member.class.base_class.to_s)
20
20
  #}
21
21
 
22
- # Return the authorisations of the sharing for the member
23
- def get_authorisations(member)
22
+ # Return the permissions of the sharing for the member
23
+ def get_permissions(member)
24
24
  # If the member is the owner, he can do what he want !
25
25
  if self.owner == member
26
26
  return true
@@ -2,7 +2,7 @@ module RepositoryManager
2
2
  class RepositoryManagerException < RuntimeError
3
3
  end
4
4
 
5
- class AuthorisationException < RepositoryManagerException
5
+ class PermissionException < RepositoryManagerException
6
6
  end
7
7
 
8
8
  class NestedSharingException < RepositoryManagerException
@@ -53,10 +53,10 @@ module RepositoryManager
53
53
  end
54
54
  end
55
55
 
56
- authorisations = get_authorisations(repo_item)
56
+ permissions = get_permissions(repo_item)
57
57
 
58
- # Here we look if the instance has the authorisation for making a sharing
59
- if can_share?(nil, authorisations)
58
+ # Here we look if the instance has the permission for making a sharing
59
+ if can_share?(nil, permissions)
60
60
 
61
61
  # We put the default options
62
62
  repo_item_permissions = RepositoryManager.default_repo_item_permissions
@@ -67,7 +67,7 @@ module RepositoryManager
67
67
  sharing_permissions = options[:sharing_permissions] if options[:sharing_permissions]
68
68
 
69
69
  # Correct the item permission with accepted permissions
70
- repo_item_permissions = make_repo_item_permissions(repo_item_permissions, authorisations)
70
+ repo_item_permissions = make_repo_item_permissions(repo_item_permissions, permissions)
71
71
 
72
72
  sharing = RepositoryManager::Sharing.new(repo_item_permissions)
73
73
  sharing.owner = self
@@ -80,14 +80,14 @@ module RepositoryManager
80
80
  sharing
81
81
  else
82
82
  # No permission => No sharing
83
- raise RepositoryManager::AuthorisationException.new("sharing failed. You don't have the permission to share the repo_item '#{repo_item.name}'")
83
+ raise RepositoryManager::PermissionException.new("sharing failed. You don't have the permission to share the repo_item '#{repo_item.name}'")
84
84
  end
85
85
  end
86
86
 
87
87
  def share(repo_item, members, options = {})
88
88
  begin
89
89
  share!(repo_item, members, options)
90
- rescue RepositoryManager::AuthorisationException, RepositoryManager::NestedSharingException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
90
+ rescue RepositoryManager::PermissionException, RepositoryManager::NestedSharingException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
91
91
  false
92
92
  end
93
93
  end
@@ -99,7 +99,7 @@ module RepositoryManager
99
99
  # Returns the object of the folder created if it is ok
100
100
  # Returns an Exception if the folder is not created
101
101
  # RepositoryManagerException if the name already exist
102
- # AuthorisationException if the object don't have the permission
102
+ # PermissionException if the object don't have the permission
103
103
  def create_folder!(name = '', options = {})
104
104
  source_folder = options[:source_folder]
105
105
  if source_folder
@@ -108,7 +108,7 @@ module RepositoryManager
108
108
  end
109
109
  end
110
110
 
111
- # If he want to create a folder in a directory, we have to check if he have the authorisation
111
+ # If he want to create a folder in a directory, we have to check if he have the permission
112
112
  if can_create?(source_folder)
113
113
 
114
114
  folder = RepoFolder.new
@@ -130,7 +130,7 @@ module RepositoryManager
130
130
 
131
131
  folder.save!
132
132
  else
133
- raise RepositoryManager::AuthorisationException.new("create_folder failed. You don't have the permission to create a folder in '#{source_folder.name}'")
133
+ raise RepositoryManager::PermissionException.new("create_folder failed. You don't have the permission to create a folder in '#{source_folder.name}'")
134
134
  end
135
135
  folder
136
136
  end
@@ -140,7 +140,7 @@ module RepositoryManager
140
140
  def create_folder(name = '', options = {})
141
141
  begin
142
142
  create_folder!(name, options)
143
- rescue RepositoryManager::AuthorisationException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
143
+ rescue RepositoryManager::PermissionException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
144
144
  false
145
145
  end
146
146
  end
@@ -150,14 +150,14 @@ module RepositoryManager
150
150
  if can_delete?(repo_item)
151
151
  repo_item.destroy
152
152
  else
153
- raise RepositoryManager::AuthorisationException.new("delete_repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
153
+ raise RepositoryManager::PermissionException.new("delete_repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
154
154
  end
155
155
  end
156
156
 
157
157
  def delete_repo_item(repo_item)
158
158
  begin
159
159
  delete_repo_item!(repo_item)
160
- rescue RepositoryManager::AuthorisationException
160
+ rescue RepositoryManager::PermissionException
161
161
  false
162
162
  end
163
163
  end
@@ -171,7 +171,7 @@ module RepositoryManager
171
171
  # Returns the object of the file created if it is ok
172
172
  # Returns an Exception if the folder is not created
173
173
  # RepositoryManagerException if the file already exist
174
- # AuthorisationException if the object don't have the permission
174
+ # PermissionException if the object don't have the permission
175
175
  def create_file!(file, options = {})
176
176
  source_folder = options[:source_folder]
177
177
  if source_folder
@@ -180,7 +180,7 @@ module RepositoryManager
180
180
  end
181
181
  end
182
182
 
183
- # If he want to create a file in a directory, we have to check if he have the authorisation
183
+ # If he want to create a file in a directory, we have to check if he have the permission
184
184
  if can_create?(source_folder)
185
185
 
186
186
  if file.class.name == 'RepositoryManager::RepoFile'
@@ -206,7 +206,7 @@ module RepositoryManager
206
206
 
207
207
  repo_file.save!
208
208
  else
209
- raise RepositoryManager::AuthorisationException.new("create_file failed. You don't have the permission to create a file")
209
+ raise RepositoryManager::PermissionException.new("create_file failed. You don't have the permission to create a file")
210
210
  end
211
211
  repo_file
212
212
  end
@@ -214,17 +214,17 @@ module RepositoryManager
214
214
  def create_file(file, options = {})
215
215
  begin
216
216
  create_file!(file, options)
217
- rescue RepositoryManager::AuthorisationException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
217
+ rescue RepositoryManager::PermissionException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
218
218
  false
219
219
  end
220
220
  end
221
221
 
222
- # Gets the repo authorisations
223
- # Return false if the entity has not the authorisation to share this rep
224
- # Return true if the entity can share this rep with all the authorisations
222
+ # Gets the repo permissions
223
+ # Return false if the entity has not the permission to share this rep
224
+ # Return true if the entity can share this rep with all the permissions
225
225
  # Return an Array if the entity can share but with restriction
226
- # Return true if the repo_item is nil (he as all authorisations on his own rep)
227
- def get_authorisations(repo_item = nil)
226
+ # Return true if the repo_item is nil (he as all permissions on his own rep)
227
+ def get_permissions(repo_item = nil)
228
228
  # If repo_item is nil, he can do what he want
229
229
  return true if repo_item == nil
230
230
 
@@ -256,14 +256,14 @@ module RepositoryManager
256
256
 
257
257
  repo_item.download!({object: self, path: path})
258
258
  else
259
- raise RepositoryManager::AuthorisationException.new("download failed. You don't have the permission to download the repo_item '#{repo_item.name}'")
259
+ raise RepositoryManager::PermissionException.new("download failed. You don't have the permission to download the repo_item '#{repo_item.name}'")
260
260
  end
261
261
  end
262
262
 
263
263
  def download(repo_item, options = {})
264
264
  begin
265
265
  download!(repo_item, options)
266
- rescue RepositoryManager::AuthorisationException
266
+ rescue RepositoryManager::PermissionException
267
267
  false
268
268
  end
269
269
  end
@@ -271,7 +271,7 @@ module RepositoryManager
271
271
  # Rename the repo_item with the new_name
272
272
  def rename_repo_item!(repo_item, new_name)
273
273
  unless can_update?(repo_item)
274
- raise RepositoryManager::AuthorisationException.new("rename repo_item failed. You don't have the permission to update the repo_item '#{repo_item.name}'")
274
+ raise RepositoryManager::PermissionException.new("rename repo_item failed. You don't have the permission to update the repo_item '#{repo_item.name}'")
275
275
  end
276
276
  repo_item.rename!(new_name)
277
277
  end
@@ -280,7 +280,7 @@ module RepositoryManager
280
280
  def rename_repo_item(repo_item, new_name)
281
281
  begin
282
282
  rename_repo_item!(repo_item, new_name)
283
- rescue RepositoryManager::AuthorisationException
283
+ rescue RepositoryManager::PermissionException
284
284
  false
285
285
  end
286
286
  end
@@ -290,26 +290,26 @@ module RepositoryManager
290
290
  # if target == nil, move to the root
291
291
  def move_repo_item!(repo_item, target = nil)
292
292
  if !can_read?(repo_item)
293
- raise RepositoryManager::AuthorisationException.new("move repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
293
+ raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
294
294
  end
295
- # If we want to change the owner we have to have the can_delete authorisation
295
+ # If we want to change the owner we have to have the can_delete permission
296
296
  if target
297
- # If want to change the owner, we have to check if we have the authorisation
297
+ # If want to change the owner, we have to check if we have the permission
298
298
  if target.owner != repo_item.owner && !can_delete?(repo_item)
299
- raise RepositoryManager::AuthorisationException.new("move repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
299
+ raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
300
300
  end
301
301
  # If we don't want to change the owner, we look if we can_update
302
302
  if target.owner == repo_item.owner && !can_update?(repo_item)
303
- raise RepositoryManager::AuthorisationException.new("move repo_item failed. You don't have the permission to update the '#{repo_item.name}'")
303
+ raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to update the '#{repo_item.name}'")
304
304
  end
305
305
  # We check if we can_create in the source_folder
306
306
  unless can_create?(target)
307
- raise RepositoryManager::AuthorisationException.new("move repo_item failed. You don't have the permission to create in the source_folder '#{options[:source_folder].name}'")
307
+ raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to create in the source_folder '#{options[:source_folder].name}'")
308
308
  end
309
309
  else
310
310
  # Else if there is no source_folder, we check if we can delete the repo_item, if the owner change
311
311
  if self != repo_item.owner && !can_delete?(repo_item)
312
- raise RepositoryManager::AuthorisationException.new("move repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
312
+ raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'")
313
313
  end
314
314
  end
315
315
  # If it has the permission, we move the repo_item in the source_folder
@@ -330,11 +330,11 @@ module RepositoryManager
330
330
  # :sender => the new sender (by default => still the old sender)
331
331
  def copy_repo_item!(repo_item, target = nil, options = {})
332
332
  unless can_read?(repo_item)
333
- raise RepositoryManager::AuthorisationException.new("copy repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
333
+ raise RepositoryManager::PermissionException.new("copy repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
334
334
  end
335
335
 
336
336
  if target && !can_create?(target)
337
- raise RepositoryManager::AuthorisationException.new("copy repo_item failed. You don't have the permission to create in the source_folder '#{target.name}'")
337
+ raise RepositoryManager::PermissionException.new("copy repo_item failed. You don't have the permission to create in the source_folder '#{target.name}'")
338
338
  end
339
339
 
340
340
  # The new owner
@@ -351,7 +351,7 @@ module RepositoryManager
351
351
  def copy_repo_item(repo_item, target = nil, options = {})
352
352
  begin
353
353
  copy_repo_item!(repo_item, target, options)
354
- rescue RepositoryManager::AuthorisationException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
354
+ rescue RepositoryManager::PermissionException, RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
355
355
  false
356
356
  end
357
357
  end
@@ -361,41 +361,41 @@ module RepositoryManager
361
361
  FileUtils.rm_rf(self.get_default_download_path())
362
362
  end
363
363
 
364
- #Return the authorisations of the sharing (can_add, can_remove)
365
- def get_sharing_authorisations(sharing)
366
- sharing.get_authorisations(self)
364
+ #Return the permissions of the sharing (can_add, can_remove)
365
+ def get_sharing_permissions(sharing)
366
+ sharing.get_permissions(self)
367
367
  end
368
368
 
369
369
  # Return true if you can share the repo, else false
370
- # You can give the authorisations or the repo_item as params
371
- def can_share?(repo_item, authorisations = nil)
372
- can_do?('share', repo_item, authorisations)
370
+ # You can give the permissions or the repo_item as params
371
+ def can_share?(repo_item, permissions = nil)
372
+ can_do?('share', repo_item, permissions)
373
373
  end
374
374
 
375
375
  # Return true if you can read the repo, else false
376
- def can_read?(repo_item, authorisations = nil)
377
- can_do?('read', repo_item, authorisations)
376
+ def can_read?(repo_item, permissions = nil)
377
+ can_do?('read', repo_item, permissions)
378
378
  end
379
379
 
380
380
  # Return true if you can download the repo, else false
381
381
  # Read = Download for the moment
382
- def can_download?(repo_item, authorisations = nil)
383
- can_do?('read', repo_item, authorisations)
382
+ def can_download?(repo_item, permissions = nil)
383
+ can_do?('read', repo_item, permissions)
384
384
  end
385
385
 
386
386
  # Return true if you can create in the repo, false else
387
- def can_create?(repo_item, authorisations = nil)
388
- can_do?('create', repo_item, authorisations)
387
+ def can_create?(repo_item, permissions = nil)
388
+ can_do?('create', repo_item, permissions)
389
389
  end
390
390
 
391
391
  # Returns true if you can edit the repo, false else
392
- def can_update?(repo_item, authorisations = nil)
393
- can_do?('update', repo_item, authorisations)
392
+ def can_update?(repo_item, permissions = nil)
393
+ can_do?('update', repo_item, permissions)
394
394
  end
395
395
 
396
396
  # Returns true if you can delete the repo, false else
397
- def can_delete?(repo_item, authorisations = nil)
398
- can_do?('delete', repo_item, authorisations)
397
+ def can_delete?(repo_item, permissions = nil)
398
+ can_do?('delete', repo_item, permissions)
399
399
  end
400
400
 
401
401
  ## Returns true if it exist a sharing in the ancestors of descendant_ids of the repo_item (without itself)
@@ -427,19 +427,19 @@ module RepositoryManager
427
427
  # You can here add new members in the sharing
428
428
  # Param member could be an object or an array of object
429
429
  def add_members_to!(sharing, members, options = RepositoryManager.default_sharing_permissions)
430
- authorisations = get_sharing_authorisations(sharing)
430
+ permissions = get_sharing_permissions(sharing)
431
431
  if can_add_to?(sharing)
432
- sharing_permissions = make_sharing_permissions(options, authorisations)
432
+ sharing_permissions = make_sharing_permissions(options, permissions)
433
433
  sharing.add_members(members, sharing_permissions)
434
434
  else
435
- raise RepositoryManager::AuthorisationException.new("add members failed. You don't have the permission to add a member in this sharing")
435
+ raise RepositoryManager::PermissionException.new("add members failed. You don't have the permission to add a member in this sharing")
436
436
  end
437
437
  end
438
438
 
439
439
  def add_members_to(sharing, members, options = RepositoryManager.default_sharing_permissions)
440
440
  begin
441
441
  add_members_to!(sharing, members, options = RepositoryManager.default_sharing_permissions)
442
- rescue RepositoryManager::AuthorisationException
442
+ rescue RepositoryManager::PermissionException
443
443
  false
444
444
  end
445
445
  end
@@ -450,14 +450,14 @@ module RepositoryManager
450
450
  if can_remove_from?(sharing)
451
451
  sharing.remove_members(members)
452
452
  else
453
- raise RepositoryManager::AuthorisationException.new("remove members failed. You don't have the permission to remove a member on this sharing")
453
+ raise RepositoryManager::PermissionException.new("remove members failed. You don't have the permission to remove a member on this sharing")
454
454
  end
455
455
  end
456
456
 
457
457
  def remove_members_from(sharing, members)
458
458
  begin
459
459
  remove_members_from!(sharing, members)
460
- rescue RepositoryManager::AuthorisationException
460
+ rescue RepositoryManager::PermissionException
461
461
  false
462
462
  end
463
463
  end
@@ -475,53 +475,53 @@ module RepositoryManager
475
475
  private
476
476
 
477
477
  # Return if you can do or not this action in the sharing
478
- def can_do_to?(what, sharing, authorisations = nil)
479
- if authorisations == nil
480
- authorisations = sharing.get_authorisations(self)
478
+ def can_do_to?(what, sharing, permissions = nil)
479
+ if permissions == nil
480
+ permissions = sharing.get_permissions(self)
481
481
  end
482
482
  case what
483
483
  when 'add'
484
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_add] == true)
484
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_add] == true)
485
485
  when 'remove'
486
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_remove] == true)
486
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_remove] == true)
487
487
  end
488
488
  end
489
489
 
490
490
  # reflexion: can_do?(what, options)
491
491
  # options
492
- # hash : authorisations hash
493
- # class: RepoItem => get_authorisations
492
+ # hash : permissions hash
493
+ # class: RepoItem => get_permissions
494
494
  # class: has_repository => regarder si on peu déplacer dans root (question: non pas possible ?)
495
495
 
496
496
  # Return if you can do or not this action (what)
497
- def can_do?(what, repo_item, authorisations = nil)
498
- # If we pass no authorisations we have to get it
499
- if authorisations == nil
500
- authorisations = get_authorisations(repo_item)
497
+ def can_do?(what, repo_item, permissions = nil)
498
+ # If we pass no permissions we have to get it
499
+ if permissions == nil
500
+ permissions = get_permissions(repo_item)
501
501
  end
502
502
 
503
503
  case what
504
504
  when 'read'
505
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_read] == true)
505
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_read] == true)
506
506
  when 'delete'
507
507
  if RepositoryManager.accept_nested_sharing
508
508
  # TODO implement to look if he can delete all the folder
509
509
  else
510
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_delete] == true)
510
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_delete] == true)
511
511
  end
512
512
  when 'update'
513
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_update] == true)
513
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_update] == true)
514
514
  when 'share'
515
515
  if RepositoryManager.accept_nested_sharing
516
516
  # TODO implement to look if he can delete all the folder
517
517
  else
518
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_share] == true)
518
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_share] == true)
519
519
  end
520
520
  when 'create'
521
521
  if RepositoryManager.accept_nested_sharing
522
522
  # TODO implement to look if he can delete all the folder
523
523
  else
524
- authorisations == true || (authorisations.kind_of?(Hash) && authorisations[:can_create] == true)
524
+ permissions == true || (permissions.kind_of?(Hash) && permissions[:can_create] == true)
525
525
  end
526
526
  else
527
527
  false
@@ -529,41 +529,41 @@ module RepositoryManager
529
529
 
530
530
  end
531
531
 
532
- # Correct the repo_item_permissions with the authorisations
533
- def make_repo_item_permissions(wanted_permissions, authorisations)
532
+ # Correct the repo_item_permissions with the permissions
533
+ def make_repo_item_permissions(wanted_permissions, permissions)
534
534
  # If it is an array, we have restriction in the permissions
535
- if authorisations.kind_of?(Hash) && wanted_permissions
535
+ if permissions.kind_of?(Hash) && wanted_permissions
536
536
  # Built the sharing with the accepted permissions
537
537
  # We remove the permission if we can't sharing it
538
- if wanted_permissions[:can_read] == true && authorisations[:can_read] == false
538
+ if wanted_permissions[:can_read] == true && permissions[:can_read] == false
539
539
  wanted_permissions[:can_read] = false
540
540
  end
541
- if wanted_permissions[:can_create] == true && authorisations[:can_create] == false
541
+ if wanted_permissions[:can_create] == true && permissions[:can_create] == false
542
542
  wanted_permissions[:can_create] = false
543
543
  end
544
- if wanted_permissions[:can_update] == true && authorisations[:can_update] == false
544
+ if wanted_permissions[:can_update] == true && permissions[:can_update] == false
545
545
  wanted_permissions[:can_update] = false
546
546
  end
547
- if wanted_permissions[:can_delete] == true && authorisations[:can_delete] == false
547
+ if wanted_permissions[:can_delete] == true && permissions[:can_delete] == false
548
548
  wanted_permissions[:can_delete] = false
549
549
  end
550
- if wanted_permissions[:can_share] == true && authorisations[:can_share] == false
550
+ if wanted_permissions[:can_share] == true && permissions[:can_share] == false
551
551
  wanted_permissions[:can_share] = false
552
552
  end
553
553
  end
554
554
  return wanted_permissions
555
555
  end
556
556
 
557
- # Correct the sharing_permissions with the authorisations
558
- def make_sharing_permissions(wanted_permissions, authorisations)
557
+ # Correct the sharing_permissions with the permissions
558
+ def make_sharing_permissions(wanted_permissions, permissions)
559
559
  # If it is an array, we have restriction in the permissions
560
- if authorisations.kind_of?(Hash) && wanted_permissions
560
+ if permissions.kind_of?(Hash) && wanted_permissions
561
561
  # Built the sharing with the accepted permissions
562
562
  # We remove the permission if we can't share it
563
- if wanted_permissions[:can_add] == true && authorisations[:can_add] == false
563
+ if wanted_permissions[:can_add] == true && permissions[:can_add] == false
564
564
  wanted_permissions[:can_add] = false
565
565
  end
566
- if wanted_permissions[:can_remove] == true && authorisations[:can_remove] == false
566
+ if wanted_permissions[:can_remove] == true && permissions[:can_remove] == false
567
567
  wanted_permissions[:can_remove] = false
568
568
  end
569
569
  end
@@ -1,3 +1,3 @@
1
1
  module RepositoryManager
2
- VERSION = '0.1.18'
2
+ VERSION = '0.1.19'
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.email = ['texicitys@gmail.com']
12
12
  s.homepage = 'https://github.com/Texicitys/repository-manager'
13
13
  s.summary = "Ruby on Rails plugin (gem) for managing repositories (files/folders/permissions/sharings)."
14
- s.description = "This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For sharing these repositories easily with other object with a flexible and complete authorisations management.
14
+ s.description = "This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For sharing these repositories easily with other object with a flexible and complete permissions management.
15
15
  Each instance (users, groups, etc..) can have it own repositories (with files and folders). It can manage them easily (edit, remove, add, etc) and sharing them with other instance."
16
16
 
17
17
  #s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
Binary file
@@ -73,7 +73,7 @@ describe 'HasRepository' do
73
73
 
74
74
  # here user3 can share because he is the owner
75
75
  @user3.share(rep, members)
76
- # here user2 should can share because he has the authorisation
76
+ # here user2 should can share because he has the permission
77
77
  members = []
78
78
  members << @user1
79
79
  @user2.share(rep, members)
@@ -95,7 +95,7 @@ describe 'HasRepository' do
95
95
 
96
96
  # here user3 can share because he is the owner
97
97
  @user3.share(rep, members, options)
98
- # here user2 should can share because he has the authorisation
98
+ # here user2 should can share because he has the permission
99
99
  members = []
100
100
  members << @user1
101
101
  @user2.share(rep, members)
@@ -117,8 +117,8 @@ describe 'HasRepository' do
117
117
 
118
118
  # here user3 can share because he is the owner
119
119
  @user3.share(rep, members, options)
120
- # here user2 should can share because he has the authorisation
121
- # But he has only the authorisation of read (can_read = true), He can't share with more permissions
120
+ # here user2 should can share because he has the permission
121
+ # But he has only the permission of read (can_read = true), He can't share with more permissions
122
122
  members = []
123
123
  members << @user1
124
124
  #Here the permissions should be : :can_read => true, and all others false
@@ -146,8 +146,8 @@ describe 'HasRepository' do
146
146
 
147
147
  # here user3 can share because he is the owner
148
148
  @user3.share(rep, members, options)
149
- # here user2 should can share because he has the authorisation
150
- # But he has only the authorisation of read (can_read = true), He can't share with more permissions
149
+ # here user2 should can share because he has the permission
150
+ # But he has only the permission of read (can_read = true), He can't share with more permissions
151
151
  members = []
152
152
  members << @user1
153
153
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repository-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Baumann
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.0.0
111
111
  description: |-
112
- This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For sharing these repositories easily with other object with a flexible and complete authorisations management.
112
+ This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For sharing these repositories easily with other object with a flexible and complete permissions management.
113
113
  Each instance (users, groups, etc..) can have it own repositories (with files and folders). It can manage them easily (edit, remove, add, etc) and sharing them with other instance.
114
114
  email:
115
115
  - texicitys@gmail.com