consent 2.5.0 → 2.6.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: 8a7f3d0bface397869a595d46763a6c17aafa1563e074d7b658454fc0b1e4c2f
4
- data.tar.gz: 301924b497164138ee60d4de3970caa9dee41ebb01697ecccf7ef9fc9202ee70
3
+ metadata.gz: a6c7e94dbb1d102068875abf44fd3cc46eca7e437eb6958a5523a2a044790e4d
4
+ data.tar.gz: 86424bc2149fcb347526554c9b4a82822f5f68c728031ae7313fb728efe55c08
5
5
  SHA512:
6
- metadata.gz: 7fdc2b3e5ff872bdc11da1688fb362d360f33e217ea5d5ffe6e8a9e2e0438454e94a7402d8c0db32ca738524e690e007a14a9e2ccdc51401a13926887d44d949
7
- data.tar.gz: 78e9b088d5e3dd9772944155ae8704f33a9b474c952c9513c78f73bff420871eee1352e8d692dd42b5a924e93bf4083023c34574300db6003adb4ad070f08224
6
+ metadata.gz: cfe9c13129199fdc7c6ae108646bbdd928e7879355896592fa97df8b41cd2039a8a5bbea9c0b44516c94055cb226bb75abf955c0fcb839d58a6f748306cfd039
7
+ data.tar.gz: ccd782f1aa33ff06111b8d0407e849ee4f99a2b610248a368c66f4a4ef9b9c4c45e9501a93109ef5dc29fc7801a2bc496c7c272e59a7e80078f47737f9ee54ac
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ PATH
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- consent (2.5.0)
14
+ consent (2.6.0)
15
15
  cancancan (= 3.2.1)
16
16
 
17
17
  GEM
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### [2.6.0] - 2026-06-15
4
+
5
+ - Changed permission checksum calculation to use permission data rather than permission file contents. [#438](https://github.com/powerhome/power-tools/pull/438)
6
+
3
7
  ### [2.5.0] - 2026-05-27
4
8
 
5
9
  - Drop support for Ruby < 3.3 and Rails < 7.1 [#396](https://github.com/powerhome/power-tools/pull/396)
@@ -11,7 +11,7 @@ PATH
11
11
  PATH
12
12
  remote: ..
13
13
  specs:
14
- consent (2.5.0)
14
+ consent (2.6.0)
15
15
  cancancan (= 3.2.1)
16
16
 
17
17
  GEM
@@ -11,7 +11,7 @@ PATH
11
11
  PATH
12
12
  remote: ..
13
13
  specs:
14
- consent (2.5.0)
14
+ consent (2.6.0)
15
15
  cancancan (= 3.2.1)
16
16
 
17
17
  GEM
@@ -22,12 +22,18 @@ module Consent
22
22
  end
23
23
 
24
24
  def to_permission_payload
25
+ views = self.views.values.sort
25
26
  {
26
27
  action: key,
27
28
  label: label,
28
- views: views.values.map(&:to_permission_payload),
29
+ views: views.map(&:to_permission_payload),
30
+ options: options.except(:views),
29
31
  default_view: default_view&.to_permission_payload,
30
32
  }
31
33
  end
34
+
35
+ def <=>(other)
36
+ key <=> other.key
37
+ end
32
38
  end
33
39
  end
@@ -3,9 +3,10 @@
3
3
  module Consent
4
4
  class PermissionDefinitionPayload
5
5
  def self.generate
6
+ subjects = Consent.subjects.sort
6
7
  {
7
8
  consent_version: Consent::VERSION,
8
- permissions: Consent.subjects.map(&:to_permission_payload),
9
+ permissions: subjects.map(&:to_permission_payload),
9
10
  }
10
11
  end
11
12
  end
@@ -12,12 +12,20 @@ module Consent
12
12
  end
13
13
 
14
14
  def to_permission_payload
15
+ actions = self.actions.sort
16
+ views = self.views.values.sort
15
17
  {
16
18
  subject: key,
17
19
  label: label,
18
20
  actions: actions.map(&:to_permission_payload),
19
- views: views.values.map(&:to_permission_payload),
21
+ views: views.map(&:to_permission_payload),
20
22
  }
21
23
  end
24
+
25
+ def <=>(other)
26
+ key = Consent::SubjectCoder.dump(key)
27
+ other_key = Consent::SubjectCoder.dump(other.key)
28
+ key <=> other_key
29
+ end
22
30
  end
23
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Consent
4
- VERSION = "2.5.0"
4
+ VERSION = "2.6.0"
5
5
  end
data/lib/consent/view.rb CHANGED
@@ -29,5 +29,9 @@ module Consent
29
29
  label: label,
30
30
  }
31
31
  end
32
+
33
+ def <=>(other)
34
+ key <=> other.key
35
+ end
32
36
  end
33
37
  end
data/lib/consent.rb CHANGED
@@ -84,24 +84,14 @@ module Consent
84
84
  Dir[*permission_files].each { |file| Kernel.load(file) }
85
85
  end
86
86
 
87
- # Returns the concatenated contents of all permission files
87
+ # Calculates a deterministic checksum of all permission definitions
88
88
  #
89
- # @param paths [Array<String,#to_s>] paths where the ruby files are located
90
- # @return [String] concatenated file contents
91
- def self.subjects_content(paths)
92
- permission_files = paths.map { |dir| File.join(dir, "*.rb") }
93
- files = Dir[*permission_files].sort
94
- files.map { |file| File.read(file) }.join
95
- end
96
-
97
- # Calculates a deterministic checksum of all permission files
98
- #
99
- # @param paths [Array<String,#to_s>] paths where the ruby files are located
100
- # @return [String] SHA256 hexdigest of all permission file contents
101
- def self.subjects_checksum(paths)
89
+ # @return [String] SHA256 hexdigest of all permission definitions
90
+ def self.subjects_checksum
102
91
  require "digest/sha2"
103
92
 
104
- Digest::SHA256.hexdigest(subjects_content(paths))
93
+ subjects = Consent.subjects.sort
94
+ Digest::SHA256.hexdigest(subjects.map(&:to_permission_payload).to_json)
105
95
  end
106
96
 
107
97
  # Defines a subject with the given key, label and options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares