hydra-access-controls 6.4.0.pre2 → 6.4.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35f2c828c01a662e99c864d3a3188f83ffa0a2d3
4
- data.tar.gz: 5b305407bd3d90d231c7c5098de035608dabb6d1
3
+ metadata.gz: 08285f91280c40edeb4fc605b7d953b44a70d1f5
4
+ data.tar.gz: 9f59a3412954e6e8f615bea4fa597e1017fa2158
5
5
  SHA512:
6
- metadata.gz: 80c97916451cd6546514a2b18d36c8c6025696d5b09dfa0644eae31fb3c39770ccd1938423ebf9174daae3430e012386e9feec511a566d886541df56efd13d57
7
- data.tar.gz: 11ae4e897b165e0c21bc29491179ef23907de5c6c5dc1da6639811c85dfb488cb0b41200dfa85b4510d51fbf11d6a67a13668778ba6110f036dd94c659aa1f8e
6
+ metadata.gz: 93a2d9fe2e17186dbbd219ac14db54aa89056ea45bcbbdba01b91b93a9a8fe4bf05cb41a6a0c82ee927b3b3cf2f926d60e7e9c9a28f5cf1896fc5a71a46f363a
7
+ data.tar.gz: c5d34233e4e9f2732636c1bdc5ce7cc66f6b97130c453081eb22fceff5a5dd2b6f0799f74bb7d8d0a1f403f8f7ea368c3f4af94f12020640bb30d4ff5a30d7cf
@@ -49,6 +49,107 @@ module Hydra
49
49
  rightsMetadata.individuals.map {|x| Permission.new(type: 'user', access: x[1], name: x[0] )})
50
50
  end
51
51
 
52
+ # Return a list of groups that have discover permission
53
+ def discover_groups
54
+ rightsMetadata.groups.map {|k, v| k if v == 'discover'}.compact
55
+ end
56
+
57
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
58
+ # @param[Array] groups a list of group names
59
+ # @example
60
+ # r.discover_groups= ['one', 'two', 'three']
61
+ # r.discover_groups
62
+ # => ['one', 'two', 'three']
63
+ #
64
+ def discover_groups=(groups)
65
+ set_discover_groups(groups, discover_groups)
66
+ end
67
+
68
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
69
+ # @param[String] groups a list of group names
70
+ # @example
71
+ # r.discover_groups_string= 'one, two, three'
72
+ # r.discover_groups
73
+ # => ['one', 'two', 'three']
74
+ #
75
+ def discover_groups_string=(groups)
76
+ self.discover_groups=groups.split(/[\s,]+/)
77
+ end
78
+
79
+ # Display the groups a comma delimeted string
80
+ def discover_groups_string
81
+ self.discover_groups.join(', ')
82
+ end
83
+
84
+ # Grant discover permissions to the groups specified. Revokes discover permission for
85
+ # any of the eligible_groups that are not in groups.
86
+ # This may be used when different users are responsible for setting different
87
+ # groups. Supply the groups the current user is responsible for as the
88
+ # 'eligible_groups'
89
+ # @param[Array] groups a list of groups
90
+ # @param[Array] eligible_groups the groups that are eligible to have their discover permssion revoked.
91
+ # @example
92
+ # r.discover_groups = ['one', 'two', 'three']
93
+ # r.discover_groups
94
+ # => ['one', 'two', 'three']
95
+ # r.set_discover_groups(['one'], ['three'])
96
+ # r.discover_groups
97
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
98
+ #
99
+ def set_discover_groups(groups, eligible_groups)
100
+ set_entities(:discover, :group, groups, eligible_groups)
101
+ end
102
+
103
+ def discover_users
104
+ rightsMetadata.individuals.map {|k, v| k if v == 'discover'}.compact
105
+ end
106
+
107
+ # Grant discover permissions to the users specified. Revokes discover permission for all other users.
108
+ # @param[Array] users a list of usernames
109
+ # @example
110
+ # r.discover_users= ['one', 'two', 'three']
111
+ # r.discover_users
112
+ # => ['one', 'two', 'three']
113
+ #
114
+ def discover_users=(users)
115
+ set_discover_users(users, discover_users)
116
+ end
117
+
118
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other users.
119
+ # @param[String] users a list of usernames
120
+ # @example
121
+ # r.discover_users_string= 'one, two, three'
122
+ # r.discover_users
123
+ # => ['one', 'two', 'three']
124
+ #
125
+ def discover_users_string=(users)
126
+ self.discover_users=users.split(/[\s,]+/)
127
+ end
128
+
129
+ # Display the users as a comma delimeted string
130
+ def discover_users_string
131
+ self.discover_users.join(', ')
132
+ end
133
+
134
+ # Grant discover permissions to the users specified. Revokes discover permission for
135
+ # any of the eligible_users that are not in users.
136
+ # This may be used when different users are responsible for setting different
137
+ # users. Supply the users the current user is responsible for as the
138
+ # 'eligible_users'
139
+ # @param[Array] users a list of users
140
+ # @param[Array] eligible_users the users that are eligible to have their discover permssion revoked.
141
+ # @example
142
+ # r.discover_users = ['one', 'two', 'three']
143
+ # r.discover_users
144
+ # => ['one', 'two', 'three']
145
+ # r.set_discover_users(['one'], ['three'])
146
+ # r.discover_users
147
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
148
+ #
149
+ def set_discover_users(users, eligible_users)
150
+ set_entities(:discover, :person, users, eligible_users)
151
+ end
152
+
52
153
  # Return a list of groups that have discover permission
53
154
  def read_groups
54
155
  rightsMetadata.groups.map {|k, v| k if v == 'read'}.compact
@@ -3,6 +3,7 @@ module Hydra
3
3
  module RightsMetadata
4
4
  extend ActiveSupport::Concern
5
5
  extend Deprecation
6
+ include Hydra::AccessControls::Permissions
6
7
 
7
8
  included do
8
9
  Deprecation.warn(RightsMetadata, "Hydra::ModelMixins::RightsMetadata has been deprecated and will be removed in hydra-head 7.0. Use Hydra::AccessControls::Permissions instead", caller(3));
@@ -44,323 +45,6 @@ module Hydra
44
45
 
45
46
  end
46
47
 
47
- # Return a list of groups that have discover permission
48
- def discover_groups
49
- rightsMetadata.groups.map {|k, v| k if v == 'discover'}.compact
50
- end
51
-
52
- # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
53
- # @param[Array] groups a list of group names
54
- # @example
55
- # r.discover_groups= ['one', 'two', 'three']
56
- # r.discover_groups
57
- # => ['one', 'two', 'three']
58
- #
59
- def discover_groups=(groups)
60
- set_discover_groups(groups, discover_groups)
61
- end
62
-
63
- # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
64
- # @param[String] groups a list of group names
65
- # @example
66
- # r.discover_groups_string= 'one, two, three'
67
- # r.discover_groups
68
- # => ['one', 'two', 'three']
69
- #
70
- def discover_groups_string=(groups)
71
- self.discover_groups=groups.split(/[\s,]+/)
72
- end
73
-
74
- # Display the groups a comma delimeted string
75
- def discover_groups_string
76
- self.discover_groups.join(', ')
77
- end
78
-
79
- # Grant discover permissions to the groups specified. Revokes discover permission for
80
- # any of the eligible_groups that are not in groups.
81
- # This may be used when different users are responsible for setting different
82
- # groups. Supply the groups the current user is responsible for as the
83
- # 'eligible_groups'
84
- # @param[Array] groups a list of groups
85
- # @param[Array] eligible_groups the groups that are eligible to have their discover permssion revoked.
86
- # @example
87
- # r.discover_groups = ['one', 'two', 'three']
88
- # r.discover_groups
89
- # => ['one', 'two', 'three']
90
- # r.set_discover_groups(['one'], ['three'])
91
- # r.discover_groups
92
- # => ['one', 'two'] ## 'two' was not eligible to be removed
93
- #
94
- def set_discover_groups(groups, eligible_groups)
95
- set_entities(:discover, :group, groups, eligible_groups)
96
- end
97
-
98
- def discover_users
99
- rightsMetadata.individuals.map {|k, v| k if v == 'discover'}.compact
100
- end
101
-
102
- # Grant discover permissions to the users specified. Revokes discover permission for all other users.
103
- # @param[Array] users a list of usernames
104
- # @example
105
- # r.discover_users= ['one', 'two', 'three']
106
- # r.discover_users
107
- # => ['one', 'two', 'three']
108
- #
109
- def discover_users=(users)
110
- set_discover_users(users, discover_users)
111
- end
112
-
113
- # Grant discover permissions to the groups specified. Revokes discover permission for all other users.
114
- # @param[String] users a list of usernames
115
- # @example
116
- # r.discover_users_string= 'one, two, three'
117
- # r.discover_users
118
- # => ['one', 'two', 'three']
119
- #
120
- def discover_users_string=(users)
121
- self.discover_users=users.split(/[\s,]+/)
122
- end
123
-
124
- # Display the users as a comma delimeted string
125
- def discover_users_string
126
- self.discover_users.join(', ')
127
- end
128
-
129
- # Grant discover permissions to the users specified. Revokes discover permission for
130
- # any of the eligible_users that are not in users.
131
- # This may be used when different users are responsible for setting different
132
- # users. Supply the users the current user is responsible for as the
133
- # 'eligible_users'
134
- # @param[Array] users a list of users
135
- # @param[Array] eligible_users the users that are eligible to have their discover permssion revoked.
136
- # @example
137
- # r.discover_users = ['one', 'two', 'three']
138
- # r.discover_users
139
- # => ['one', 'two', 'three']
140
- # r.set_discover_users(['one'], ['three'])
141
- # r.discover_users
142
- # => ['one', 'two'] ## 'two' was not eligible to be removed
143
- #
144
- def set_discover_users(users, eligible_users)
145
- set_entities(:discover, :person, users, eligible_users)
146
- end
147
-
148
- # Return a list of groups that have discover permission
149
- def read_groups
150
- rightsMetadata.groups.map {|k, v| k if v == 'read'}.compact
151
- end
152
-
153
- # Grant read permissions to the groups specified. Revokes read permission for all other groups.
154
- # @param[Array] groups a list of group names
155
- # @example
156
- # r.read_groups= ['one', 'two', 'three']
157
- # r.read_groups
158
- # => ['one', 'two', 'three']
159
- #
160
- def read_groups=(groups)
161
- set_read_groups(groups, read_groups)
162
- end
163
-
164
- # Grant read permissions to the groups specified. Revokes read permission for all other groups.
165
- # @param[String] groups a list of group names
166
- # @example
167
- # r.read_groups_string= 'one, two, three'
168
- # r.read_groups
169
- # => ['one', 'two', 'three']
170
- #
171
- def read_groups_string=(groups)
172
- self.read_groups=groups.split(/[\s,]+/)
173
- end
174
-
175
- # Display the groups a comma delimeted string
176
- def read_groups_string
177
- self.read_groups.join(', ')
178
- end
179
-
180
- # Grant read permissions to the groups specified. Revokes read permission for
181
- # any of the eligible_groups that are not in groups.
182
- # This may be used when different users are responsible for setting different
183
- # groups. Supply the groups the current user is responsible for as the
184
- # 'eligible_groups'
185
- # @param[Array] groups a list of groups
186
- # @param[Array] eligible_groups the groups that are eligible to have their read permssion revoked.
187
- # @example
188
- # r.read_groups = ['one', 'two', 'three']
189
- # r.read_groups
190
- # => ['one', 'two', 'three']
191
- # r.set_read_groups(['one'], ['three'])
192
- # r.read_groups
193
- # => ['one', 'two'] ## 'two' was not eligible to be removed
194
- #
195
- def set_read_groups(groups, eligible_groups)
196
- set_entities(:read, :group, groups, eligible_groups)
197
- end
198
-
199
- def read_users
200
- rightsMetadata.individuals.map {|k, v| k if v == 'read'}.compact
201
- end
202
-
203
- # Grant read permissions to the users specified. Revokes read permission for all other users.
204
- # @param[Array] users a list of usernames
205
- # @example
206
- # r.read_users= ['one', 'two', 'three']
207
- # r.read_users
208
- # => ['one', 'two', 'three']
209
- #
210
- def read_users=(users)
211
- set_read_users(users, read_users)
212
- end
213
-
214
- # Grant read permissions to the groups specified. Revokes read permission for all other users.
215
- # @param[String] users a list of usernames
216
- # @example
217
- # r.read_users_string= 'one, two, three'
218
- # r.read_users
219
- # => ['one', 'two', 'three']
220
- #
221
- def read_users_string=(users)
222
- self.read_users=users.split(/[\s,]+/)
223
- end
224
-
225
- # Display the users as a comma delimeted string
226
- def read_users_string
227
- self.read_users.join(', ')
228
- end
229
-
230
- # Grant read permissions to the users specified. Revokes read permission for
231
- # any of the eligible_users that are not in users.
232
- # This may be used when different users are responsible for setting different
233
- # users. Supply the users the current user is responsible for as the
234
- # 'eligible_users'
235
- # @param[Array] users a list of users
236
- # @param[Array] eligible_users the users that are eligible to have their read permssion revoked.
237
- # @example
238
- # r.read_users = ['one', 'two', 'three']
239
- # r.read_users
240
- # => ['one', 'two', 'three']
241
- # r.set_read_users(['one'], ['three'])
242
- # r.read_users
243
- # => ['one', 'two'] ## 'two' was not eligible to be removed
244
- #
245
- def set_read_users(users, eligible_users)
246
- set_entities(:read, :person, users, eligible_users)
247
- end
248
-
249
-
250
- # Return a list of groups that have edit permission
251
- def edit_groups
252
- rightsMetadata.groups.map {|k, v| k if v == 'edit'}.compact
253
- end
254
-
255
- # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
256
- # @param[Array] groups a list of group names
257
- # @example
258
- # r.edit_groups= ['one', 'two', 'three']
259
- # r.edit_groups
260
- # => ['one', 'two', 'three']
261
- #
262
- def edit_groups=(groups)
263
- set_edit_groups(groups, edit_groups)
264
- end
265
-
266
- # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
267
- # @param[String] groups a list of group names
268
- # @example
269
- # r.edit_groups_string= 'one, two, three'
270
- # r.edit_groups
271
- # => ['one', 'two', 'three']
272
- #
273
- def edit_groups_string=(groups)
274
- self.edit_groups=groups.split(/[\s,]+/)
275
- end
276
-
277
- # Display the groups a comma delimeted string
278
- def edit_groups_string
279
- self.edit_groups.join(', ')
280
- end
281
-
282
- # Grant edit permissions to the groups specified. Revokes edit permission for
283
- # any of the eligible_groups that are not in groups.
284
- # This may be used when different users are responsible for setting different
285
- # groups. Supply the groups the current user is responsible for as the
286
- # 'eligible_groups'
287
- # @param[Array] groups a list of groups
288
- # @param[Array] eligible_groups the groups that are eligible to have their edit permssion revoked.
289
- # @example
290
- # r.edit_groups = ['one', 'two', 'three']
291
- # r.edit_groups
292
- # => ['one', 'two', 'three']
293
- # r.set_edit_groups(['one'], ['three'])
294
- # r.edit_groups
295
- # => ['one', 'two'] ## 'two' was not eligible to be removed
296
- #
297
- def set_edit_groups(groups, eligible_groups)
298
- set_entities(:edit, :group, groups, eligible_groups)
299
- end
300
-
301
- def edit_users
302
- rightsMetadata.individuals.map {|k, v| k if v == 'edit'}.compact
303
- end
304
-
305
- # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
306
- # @param[Array] users a list of usernames
307
- # @example
308
- # r.edit_users= ['one', 'two', 'three']
309
- # r.edit_users
310
- # => ['one', 'two', 'three']
311
- #
312
- def edit_users=(users)
313
- set_edit_users(users, edit_users)
314
- end
315
-
316
- # Grant edit permissions to the users specified. Revokes edit permission for
317
- # any of the eligible_users that are not in users.
318
- # This may be used when different users are responsible for setting different
319
- # users. Supply the users the current user is responsible for as the
320
- # 'eligible_users'
321
- # @param[Array] users a list of users
322
- # @param[Array] eligible_users the users that are eligible to have their edit permssion revoked.
323
- # @example
324
- # r.edit_users = ['one', 'two', 'three']
325
- # r.edit_users
326
- # => ['one', 'two', 'three']
327
- # r.set_edit_users(['one'], ['three'])
328
- # r.edit_users
329
- # => ['one', 'two'] ## 'two' was not eligible to be removed
330
- #
331
- def set_edit_users(users, eligible_users)
332
- set_entities(:edit, :person, users, eligible_users)
333
- end
334
-
335
-
336
- private
337
-
338
- # @param permission either :discover, :read or :edit
339
- # @param type either :person or :group
340
- # @param values Values to set
341
- # @param changeable Values we are allowed to change
342
- def set_entities(permission, type, values, changeable)
343
- g = preserved(type, permission)
344
- (changeable - values).each do |entity|
345
- #Strip permissions from users not provided
346
- g[entity] = 'none'
347
- end
348
- values.each { |name| g[name] = permission.to_s}
349
- rightsMetadata.update_permissions(type.to_s=>g)
350
- end
351
-
352
- ## Get those permissions we don't want to change
353
- def preserved(type, permission)
354
- case permission
355
- when :edit
356
- g = {}
357
- when :read
358
- Hash[rightsMetadata.quick_search_by_type(type).select {|k, v| v == 'edit'}]
359
- when :discover
360
- Hash[rightsMetadata.quick_search_by_type(type).select {|k, v| v == 'discover'}]
361
- end
362
- end
363
-
364
48
  end
365
49
  end
366
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-access-controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0.pre2
4
+ version: 6.4.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-28 00:00:00.000000000 Z
13
+ date: 2013-09-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport