hydra-access-controls 12.1.0 → 13.1.0

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
  SHA256:
3
- metadata.gz: d746a886953c496a8dc25145ca468473f24988db6d2aeabe191b3001a7570b3e
4
- data.tar.gz: 2b3d9f45bef0f184f735c16cfeb5ca8155ca5f6328d9e241c0065375d732b2f2
3
+ metadata.gz: b9ffdb463944fbf90c1e1b894dd1f25d4be83e18c1ae1ec3b2393a1c411a0528
4
+ data.tar.gz: 16207bb58ca3f13b1a3f7ceb2c1154a73c144f4494ed5c5286e39964417124af
5
5
  SHA512:
6
- metadata.gz: 476fc32fd3f1b0accceb8e5c67f14a15d057dc3be62ca483af84b0174f068e68a282dcab5ecdfa9854130650b9ab2743ce30bb53a71c037cb907ad7aab5a38c5
7
- data.tar.gz: 6340762ebeb31c19aeb67d185a0da530f0b57394bb7e982a9f19f2cd1c24fd1402df769b1ef1c1c2690b8c3458679ee9b6dafe9074a61efff471e3a90923be09
6
+ metadata.gz: 6e0161b3d4ca854caf3de3d69f91968c3343cc58d9a7096fb6cac0d2cbdb0e0a643d8a3577dc1b57f48ee00713740a2192b12226e435102b8fae28194c42dc38
7
+ data.tar.gz: 0ebcc1b9551e20431cc7520cdac61da660b04e3618df6c7856f359e51d52e66f10ab07588faa44a482d097b60687e78b8e3c374e2739936ce704f1da321097e8
@@ -8,69 +8,75 @@ module Hydra::AccessControls
8
8
  define_attribute_methods :visibility
9
9
  # instance variable needs to be initialized here based upon what is in read_groups
10
10
  after_initialize { @visibility = visibility }
11
+ # Starting in Rails 7.2, define_attribute_methods creates a module that overrides accessor methods
12
+ # defined in this module. In order for the methods in this module to take precedence over those
13
+ # they need to be defined in a submodule and included after running define_attribute_methods.
14
+ include InstanceMethods
11
15
  end
12
16
 
13
- def visibility=(value)
14
- return if value.nil?
15
- # only set explicit permissions
16
- case value
17
- when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
18
- public_visibility!
19
- when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
20
- registered_visibility!
21
- when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
22
- private_visibility!
23
- else
24
- raise ArgumentError, "Invalid visibility: #{value.inspect}"
17
+ module InstanceMethods
18
+ def visibility=(value)
19
+ return if value.nil?
20
+ # only set explicit permissions
21
+ case value
22
+ when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
23
+ public_visibility!
24
+ when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
25
+ registered_visibility!
26
+ when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
27
+ private_visibility!
28
+ else
29
+ raise ArgumentError, "Invalid visibility: #{value.inspect}"
30
+ end
31
+ @visibility = value
25
32
  end
26
- @visibility = value
27
- end
28
33
 
29
- def visibility
30
- if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
31
- AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
32
- elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
33
- AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
34
- else
35
- AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
34
+ def visibility
35
+ if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
36
+ AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
37
+ elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
38
+ AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
39
+ else
40
+ AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
41
+ end
36
42
  end
37
- end
38
43
 
39
- # Overridden for ActiveModel::Dirty tracking of visibility
40
- # Required by ActiveModel::AttributeMethods
41
- # @see https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html
42
- # An instance variable is used to avoid infinite recursion caused by calling #visibility
43
- # Using this approach requires setting visibility read groups through #visibility=
44
- # instead of manipulating them directly if #visibility_changed? is expected to work correctly.
45
- def attributes
46
- super.merge({ 'visibility' => @visibility })
47
- end
44
+ # Overridden for ActiveModel::Dirty tracking of visibility
45
+ # Required by ActiveModel::AttributeMethods
46
+ # @see https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html
47
+ # An instance variable is used to avoid infinite recursion caused by calling #visibility
48
+ # Using this approach requires setting visibility read groups through #visibility=
49
+ # instead of manipulating them directly if #visibility_changed? is expected to work correctly.
50
+ def attributes
51
+ super.merge({ 'visibility' => @visibility })
52
+ end
48
53
 
49
- private
54
+ private
50
55
 
51
- # Override represented_visibility if you want to add another visibility that is
52
- # represented as a read group (e.g. on-campus)
53
- # @return [Array] a list of visibility types that are represented as read groups
54
- def represented_visibility
55
- [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED,
56
- AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
57
- end
56
+ # Override represented_visibility if you want to add another visibility that is
57
+ # represented as a read group (e.g. on-campus)
58
+ # @return [Array] a list of visibility types that are represented as read groups
59
+ def represented_visibility
60
+ [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED,
61
+ AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
62
+ end
58
63
 
59
- def public_visibility!
60
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
61
- remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
62
- set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], remove_groups)
63
- end
64
+ def public_visibility!
65
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
66
+ remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
67
+ set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], remove_groups)
68
+ end
64
69
 
65
- def registered_visibility!
66
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
67
- remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED]
68
- set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED], remove_groups)
69
- end
70
+ def registered_visibility!
71
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
72
+ remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED]
73
+ set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED], remove_groups)
74
+ end
70
75
 
71
- def private_visibility!
72
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
73
- set_read_groups([], represented_visibility)
74
- end
76
+ def private_visibility!
77
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
78
+ set_read_groups([], represented_visibility)
79
+ end
80
+ end
75
81
  end
76
82
  end
@@ -17,14 +17,14 @@ Gem::Specification.new do |gem|
17
17
  gem.license = "APACHE-2.0"
18
18
  gem.metadata = { "rubygems_mfa_required" => "true" }
19
19
 
20
- gem.required_ruby_version = '>= 2.4'
20
+ gem.required_ruby_version = '>= 3.1'
21
21
 
22
- gem.add_dependency 'activesupport', '>= 5.2', '< 7.1'
22
+ gem.add_dependency 'activesupport', '>= 6.1', '< 8.1'
23
23
  gem.add_dependency 'active-fedora', '>= 10.0.0'
24
24
  gem.add_dependency 'blacklight-access_controls', '~> 6.0'
25
25
  gem.add_dependency 'cancancan', '>= 1.8', '< 4'
26
26
  gem.add_dependency 'deprecation', '~> 1.0'
27
27
 
28
28
  gem.add_development_dependency 'rake', '>= 12.3.3'
29
- gem.add_development_dependency 'rspec', '~> 4.0'
29
+ gem.add_development_dependency 'rspec'
30
30
  end
@@ -7,7 +7,6 @@ require 'blacklight-access_controls'
7
7
 
8
8
  module Hydra
9
9
  extend ActiveSupport::Autoload
10
- autoload :AccessControls
11
10
  autoload :User
12
11
  autoload :AccessControlsEnforcement
13
12
  autoload :PolicyAwareAccessControlsEnforcement
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: 12.1.0
4
+ version: 13.1.0
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: 2023-01-27 00:00:00.000000000 Z
13
+ date: 2025-05-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -18,20 +18,20 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.2'
21
+ version: '6.1'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '7.1'
24
+ version: '8.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '5.2'
31
+ version: '6.1'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '7.1'
34
+ version: '8.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: active-fedora
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '4.0'
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '4.0'
124
+ version: '0'
125
125
  description: Access controls for project hydra
126
126
  email:
127
127
  - hydra-tech@googlegroups.com
@@ -135,7 +135,6 @@ files:
135
135
  - app/indexers/hydra/access_controls/embargo_indexer.rb
136
136
  - app/indexers/hydra/access_controls/lease_indexer.rb
137
137
  - app/models/ability.rb
138
- - app/models/concerns/hydra/access_controls.rb
139
138
  - app/models/concerns/hydra/access_controls/access_right.rb
140
139
  - app/models/concerns/hydra/access_controls/embargoable.rb
141
140
  - app/models/concerns/hydra/access_controls/permissions.rb
@@ -217,14 +216,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
216
  requirements:
218
217
  - - ">="
219
218
  - !ruby/object:Gem::Version
220
- version: '2.4'
219
+ version: '3.1'
221
220
  required_rubygems_version: !ruby/object:Gem::Requirement
222
221
  requirements:
223
222
  - - ">="
224
223
  - !ruby/object:Gem::Version
225
224
  version: '0'
226
225
  requirements: []
227
- rubygems_version: 3.3.26
226
+ rubygems_version: 3.4.1
228
227
  signing_key:
229
228
  specification_version: 4
230
229
  summary: Access controls for project hydra
@@ -1,10 +0,0 @@
1
- module Hydra
2
- module AccessControls
3
- extend ActiveSupport::Autoload
4
- autoload :AccessRight
5
- autoload :WithAccessRight
6
- autoload :Embargoable
7
- autoload :Visibility
8
- autoload :Permissions
9
- end
10
- end