consent 2.3.0 → 2.5.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.
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../../rubocop-powerhome
3
3
  specs:
4
- rubocop-powerhome (0.5.6)
5
- rubocop (= 1.75.0)
4
+ rubocop-powerhome (0.6.1)
5
+ rubocop (= 1.82.1)
6
6
  rubocop-performance
7
7
  rubocop-rails
8
8
  rubocop-rake
@@ -11,7 +11,7 @@ PATH
11
11
  PATH
12
12
  remote: ..
13
13
  specs:
14
- consent (2.3.0)
14
+ consent (2.5.0)
15
15
  cancancan (= 3.2.1)
16
16
 
17
17
  GEM
@@ -94,37 +94,36 @@ GEM
94
94
  thor (>= 0.14.0)
95
95
  ast (2.4.3)
96
96
  base64 (0.3.0)
97
- benchmark (0.4.1)
98
- bigdecimal (3.2.2)
97
+ benchmark (0.5.0)
98
+ bigdecimal (4.1.1)
99
99
  builder (3.3.0)
100
100
  byebug (11.1.3)
101
101
  cancancan (3.2.1)
102
- cgi (0.5.0)
103
102
  coderay (1.1.3)
104
103
  combustion (1.5.0)
105
104
  activesupport (>= 3.0.0)
106
105
  railties (>= 3.0.0)
107
106
  thor (>= 0.14.6)
108
- concurrent-ruby (1.3.5)
109
- connection_pool (2.5.3)
107
+ concurrent-ruby (1.3.6)
108
+ connection_pool (3.0.2)
110
109
  crass (1.0.6)
111
110
  csv (3.3.5)
112
- date (3.4.1)
111
+ date (3.5.1)
113
112
  diff-lcs (1.6.2)
114
113
  drb (2.2.3)
115
- erb (4.0.4)
116
- cgi (>= 0.3.3)
114
+ erb (6.0.2)
117
115
  erubi (1.13.1)
118
- globalid (1.2.1)
116
+ globalid (1.3.0)
119
117
  activesupport (>= 6.1)
120
- i18n (1.14.7)
118
+ i18n (1.14.8)
121
119
  concurrent-ruby (~> 1.0)
122
- io-console (0.8.1)
123
- irb (1.15.2)
120
+ io-console (0.8.2)
121
+ irb (1.17.0)
124
122
  pp (>= 0.6.0)
123
+ prism (>= 1.3.0)
125
124
  rdoc (>= 4.0.0)
126
125
  reline (>= 0.4.2)
127
- json (2.13.2)
126
+ json (2.19.3)
128
127
  language_server-protocol (3.17.0.5)
129
128
  license_finder (7.2.1)
130
129
  bundler
@@ -136,20 +135,23 @@ GEM
136
135
  xml-simple (~> 1.1.9)
137
136
  lint_roller (1.1.0)
138
137
  logger (1.7.0)
139
- loofah (2.24.1)
138
+ loofah (2.25.1)
140
139
  crass (~> 1.0.2)
141
140
  nokogiri (>= 1.12.0)
142
- mail (2.8.1)
141
+ mail (2.9.0)
142
+ logger
143
143
  mini_mime (>= 0.1.1)
144
144
  net-imap
145
145
  net-pop
146
146
  net-smtp
147
- marcel (1.0.4)
147
+ marcel (1.1.0)
148
148
  method_source (1.1.0)
149
149
  mini_mime (1.1.5)
150
- minitest (5.25.5)
151
- mutex_m (0.3.0)
152
- net-imap (0.4.22)
150
+ mini_portile2 (2.8.9)
151
+ minitest (6.0.3)
152
+ drb (~> 2.0)
153
+ prism (~> 1.5)
154
+ net-imap (0.6.3)
153
155
  date
154
156
  net-protocol
155
157
  net-pop (0.1.2)
@@ -158,44 +160,45 @@ GEM
158
160
  timeout
159
161
  net-smtp (0.5.1)
160
162
  net-protocol
161
- nio4r (2.7.4)
162
- nokogiri (1.17.2-aarch64-linux)
163
+ nio4r (2.7.5)
164
+ nokogiri (1.19.2)
165
+ mini_portile2 (~> 2.8.2)
163
166
  racc (~> 1.4)
164
- nokogiri (1.17.2-arm-linux)
167
+ nokogiri (1.19.2-aarch64-linux-gnu)
165
168
  racc (~> 1.4)
166
- nokogiri (1.17.2-arm64-darwin)
169
+ nokogiri (1.19.2-arm-linux-gnu)
167
170
  racc (~> 1.4)
168
- nokogiri (1.17.2-x86-linux)
171
+ nokogiri (1.19.2-arm64-darwin)
169
172
  racc (~> 1.4)
170
- nokogiri (1.17.2-x86_64-darwin)
173
+ nokogiri (1.19.2-x86_64-darwin)
171
174
  racc (~> 1.4)
172
- nokogiri (1.17.2-x86_64-linux)
175
+ nokogiri (1.19.2-x86_64-linux-gnu)
173
176
  racc (~> 1.4)
174
- parallel (1.27.0)
175
- parser (3.3.9.0)
177
+ parallel (1.28.0)
178
+ parser (3.3.11.1)
176
179
  ast (~> 2.4.1)
177
180
  racc
178
- pp (0.6.2)
181
+ pp (0.6.3)
179
182
  prettyprint
180
183
  prettyprint (0.2.0)
181
- prism (1.4.0)
184
+ prism (1.9.0)
182
185
  pry (0.14.2)
183
186
  coderay (~> 1.1)
184
187
  method_source (~> 1.0)
185
188
  pry-byebug (3.10.1)
186
189
  byebug (~> 11.0)
187
190
  pry (>= 0.13, < 0.15)
188
- psych (5.2.6)
191
+ psych (5.3.1)
189
192
  date
190
193
  stringio
191
194
  racc (1.8.1)
192
- rack (3.1.16)
193
- rack-session (2.1.1)
195
+ rack (3.1.21)
196
+ rack-session (2.1.2)
194
197
  base64 (>= 0.1.0)
195
198
  rack (>= 3.0.0)
196
199
  rack-test (2.2.0)
197
200
  rack (>= 1.3)
198
- rackup (2.2.1)
201
+ rackup (2.3.1)
199
202
  rack (>= 3)
200
203
  rails (7.2.2.1)
201
204
  actioncable (= 7.2.2.1)
@@ -215,8 +218,8 @@ GEM
215
218
  activesupport (>= 5.0.0)
216
219
  minitest
217
220
  nokogiri (>= 1.6)
218
- rails-html-sanitizer (1.6.2)
219
- loofah (~> 2.21)
221
+ rails-html-sanitizer (1.7.0)
222
+ loofah (~> 2.25)
220
223
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
221
224
  railties (7.2.2.1)
222
225
  actionpack (= 7.2.2.1)
@@ -227,24 +230,25 @@ GEM
227
230
  thor (~> 1.0, >= 1.2.2)
228
231
  zeitwerk (~> 2.6)
229
232
  rainbow (3.1.1)
230
- rake (13.3.0)
231
- rdoc (6.14.2)
233
+ rake (13.3.1)
234
+ rdoc (7.2.0)
232
235
  erb
233
236
  psych (>= 4.0.0)
234
- regexp_parser (2.11.0)
235
- reline (0.6.2)
237
+ tsort
238
+ regexp_parser (2.12.0)
239
+ reline (0.6.3)
236
240
  io-console (~> 0.5)
237
- rexml (3.4.1)
238
- rspec (3.13.1)
241
+ rexml (3.4.4)
242
+ rspec (3.13.2)
239
243
  rspec-core (~> 3.13.0)
240
244
  rspec-expectations (~> 3.13.0)
241
245
  rspec-mocks (~> 3.13.0)
242
- rspec-core (3.13.5)
246
+ rspec-core (3.13.6)
243
247
  rspec-support (~> 3.13.0)
244
248
  rspec-expectations (3.13.5)
245
249
  diff-lcs (>= 1.2.0, < 2.0)
246
250
  rspec-support (~> 3.13.0)
247
- rspec-mocks (3.13.5)
251
+ rspec-mocks (3.13.8)
248
252
  diff-lcs (>= 1.2.0, < 2.0)
249
253
  rspec-support (~> 3.13.0)
250
254
  rspec-rails (6.1.5)
@@ -255,8 +259,8 @@ GEM
255
259
  rspec-expectations (~> 3.13)
256
260
  rspec-mocks (~> 3.13)
257
261
  rspec-support (~> 3.13)
258
- rspec-support (3.13.4)
259
- rubocop (1.75.0)
262
+ rspec-support (3.13.7)
263
+ rubocop (1.82.1)
260
264
  json (~> 2.3)
261
265
  language_server-protocol (~> 3.17.0.2)
262
266
  lint_roller (~> 1.1.0)
@@ -264,46 +268,47 @@ GEM
264
268
  parser (>= 3.3.0.2)
265
269
  rainbow (>= 2.2.2, < 4.0)
266
270
  regexp_parser (>= 2.9.3, < 3.0)
267
- rubocop-ast (>= 1.43.0, < 2.0)
271
+ rubocop-ast (>= 1.48.0, < 2.0)
268
272
  ruby-progressbar (~> 1.7)
269
273
  unicode-display_width (>= 2.4.0, < 4.0)
270
- rubocop-ast (1.46.0)
274
+ rubocop-ast (1.49.1)
271
275
  parser (>= 3.3.7.2)
272
- prism (~> 1.4)
273
- rubocop-performance (1.24.0)
276
+ prism (~> 1.7)
277
+ rubocop-performance (1.26.1)
274
278
  lint_roller (~> 1.1)
275
- rubocop (>= 1.72.1, < 2.0)
276
- rubocop-ast (>= 1.38.0, < 2.0)
277
- rubocop-rails (2.30.3)
279
+ rubocop (>= 1.75.0, < 2.0)
280
+ rubocop-ast (>= 1.47.1, < 2.0)
281
+ rubocop-rails (2.34.3)
278
282
  activesupport (>= 4.2.0)
279
283
  lint_roller (~> 1.1)
280
284
  rack (>= 1.1)
281
- rubocop (>= 1.72.1, < 2.0)
282
- rubocop-ast (>= 1.38.0, < 2.0)
285
+ rubocop (>= 1.75.0, < 2.0)
286
+ rubocop-ast (>= 1.44.0, < 2.0)
283
287
  rubocop-rake (0.7.1)
284
288
  lint_roller (~> 1.1)
285
289
  rubocop (>= 1.72.1)
286
- rubocop-rspec (3.6.0)
290
+ rubocop-rspec (3.9.0)
287
291
  lint_roller (~> 1.1)
288
- rubocop (~> 1.72, >= 1.72.1)
292
+ rubocop (~> 1.81)
289
293
  ruby-progressbar (1.13.0)
290
294
  rubyzip (2.4.1)
291
- securerandom (0.3.2)
292
- sqlite3 (1.7.3-aarch64-linux)
293
- sqlite3 (1.7.3-arm-linux)
294
- sqlite3 (1.7.3-arm64-darwin)
295
- sqlite3 (1.7.3-x86-linux)
296
- sqlite3 (1.7.3-x86_64-darwin)
297
- sqlite3 (1.7.3-x86_64-linux)
298
- stringio (3.1.7)
299
- thor (1.4.0)
300
- timeout (0.4.3)
301
- tomlrb (2.0.3)
295
+ securerandom (0.4.1)
296
+ sqlite3 (2.9.2-aarch64-linux-gnu)
297
+ sqlite3 (2.9.2-arm-linux-gnu)
298
+ sqlite3 (2.9.2-arm64-darwin)
299
+ sqlite3 (2.9.2-x86-linux-gnu)
300
+ sqlite3 (2.9.2-x86_64-darwin)
301
+ sqlite3 (2.9.2-x86_64-linux-gnu)
302
+ stringio (3.2.0)
303
+ thor (1.5.0)
304
+ timeout (0.6.1)
305
+ tomlrb (2.0.4)
306
+ tsort (0.2.0)
302
307
  tzinfo (2.0.6)
303
308
  concurrent-ruby (~> 1.0)
304
- unicode-display_width (3.1.4)
305
- unicode-emoji (~> 4.0, >= 4.0.4)
306
- unicode-emoji (4.0.4)
309
+ unicode-display_width (3.2.0)
310
+ unicode-emoji (~> 4.1)
311
+ unicode-emoji (4.2.0)
307
312
  useragent (0.16.11)
308
313
  websocket-driver (0.8.0)
309
314
  base64
@@ -312,7 +317,7 @@ GEM
312
317
  with_env (1.1.0)
313
318
  xml-simple (1.1.9)
314
319
  rexml
315
- zeitwerk (2.6.18)
320
+ zeitwerk (2.7.5)
316
321
 
317
322
  PLATFORMS
318
323
  aarch64-linux
@@ -325,17 +330,10 @@ PLATFORMS
325
330
  DEPENDENCIES
326
331
  activerecord (>= 5)
327
332
  appraisal (~> 2.5.0)
328
- base64
329
- bigdecimal
330
333
  bundler (~> 2.1)
331
334
  combustion (~> 1.3)
332
335
  consent!
333
- erb (< 5.1)
334
336
  license_finder (>= 7.0)
335
- logger
336
- mutex_m
337
- net-imap (< 0.5.0)
338
- nokogiri (< 1.19)
339
337
  pry (>= 0.14.2)
340
338
  pry-byebug (= 3.10.1)
341
339
  rails (= 7.2.2.1)
@@ -343,9 +341,7 @@ DEPENDENCIES
343
341
  rspec (~> 3.0)
344
342
  rspec-rails (~> 6.1.5)
345
343
  rubocop-powerhome!
346
- securerandom (< 0.4)
347
- sqlite3 (~> 1.7.3)
348
- zeitwerk (< 2.7.0)
344
+ sqlite3 (~> 2.9)
349
345
 
350
346
  BUNDLED WITH
351
347
  2.5.23
@@ -20,5 +20,14 @@ module Consent
20
20
 
21
21
  @default_view ||= @subject.views[@options[:default_view]]
22
22
  end
23
+
24
+ def to_permission_payload
25
+ {
26
+ action: key,
27
+ label: label,
28
+ views: views.values.map(&:to_permission_payload),
29
+ default_view: default_view&.to_permission_payload,
30
+ }
31
+ end
23
32
  end
24
33
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Consent
4
+ class PermissionDefinitionPayload
5
+ def self.generate
6
+ {
7
+ consent_version: Consent::VERSION,
8
+ permissions: Consent.subjects.map(&:to_permission_payload),
9
+ }
10
+ end
11
+ end
12
+ end
@@ -10,5 +10,14 @@ module Consent
10
10
  @actions = []
11
11
  @views = Consent.default_views.clone
12
12
  end
13
+
14
+ def to_permission_payload
15
+ {
16
+ subject: key,
17
+ label: label,
18
+ actions: actions.map(&:to_permission_payload),
19
+ views: views.values.map(&:to_permission_payload),
20
+ }
21
+ end
13
22
  end
14
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Consent
4
- VERSION = "2.3.0"
4
+ VERSION = "2.5.0"
5
5
  end
data/lib/consent/view.rb CHANGED
@@ -22,5 +22,12 @@ module Consent
22
22
 
23
23
  @instance.curry[*args]
24
24
  end
25
+
26
+ def to_permission_payload
27
+ {
28
+ view: key,
29
+ label: label,
30
+ }
31
+ end
25
32
  end
26
33
  end
data/lib/consent.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "cancancan"
4
4
 
5
5
  require "consent/ability"
6
+ require "consent/permission_definition_payload"
6
7
  require "consent/action"
7
8
  require "consent/dsl"
8
9
  require "consent/model_additions"
@@ -83,6 +84,26 @@ module Consent
83
84
  Dir[*permission_files].each { |file| Kernel.load(file) }
84
85
  end
85
86
 
87
+ # Returns the concatenated contents of all permission files
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)
102
+ require "digest/sha2"
103
+
104
+ Digest::SHA256.hexdigest(subjects_content(paths))
105
+ end
106
+
86
107
  # Defines a subject with the given key, label and options
87
108
  #
88
109
  # i.e:
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-10-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: cancancan
@@ -184,14 +183,14 @@ dependencies:
184
183
  requirements:
185
184
  - - "~>"
186
185
  - !ruby/object:Gem::Version
187
- version: 1.7.3
186
+ version: '2.9'
188
187
  type: :development
189
188
  prerelease: false
190
189
  version_requirements: !ruby/object:Gem::Requirement
191
190
  requirements:
192
191
  - - "~>"
193
192
  - !ruby/object:Gem::Version
194
- version: 1.7.3
193
+ version: '2.9'
195
194
  description: Consent permission based authorization
196
195
  email:
197
196
  - chjunior@gmail.com
@@ -220,10 +219,6 @@ files:
220
219
  - docs/CHANGELOG.md
221
220
  - docs/README.md
222
221
  - gemfiles/.bundle/config
223
- - gemfiles/rails_6_1.gemfile
224
- - gemfiles/rails_6_1.gemfile.lock
225
- - gemfiles/rails_7_0.gemfile
226
- - gemfiles/rails_7_0.gemfile.lock
227
222
  - gemfiles/rails_7_1.gemfile
228
223
  - gemfiles/rails_7_1.gemfile.lock
229
224
  - gemfiles/rails_7_2.gemfile
@@ -234,6 +229,7 @@ files:
234
229
  - lib/consent/dsl.rb
235
230
  - lib/consent/engine.rb
236
231
  - lib/consent/model_additions.rb
232
+ - lib/consent/permission_definition_payload.rb
237
233
  - lib/consent/permission_migration.rb
238
234
  - lib/consent/reloader.rb
239
235
  - lib/consent/rspec.rb
@@ -254,7 +250,6 @@ licenses:
254
250
  - MIT
255
251
  metadata:
256
252
  rubygems_mfa_required: 'true'
257
- post_install_message:
258
253
  rdoc_options: []
259
254
  require_paths:
260
255
  - lib
@@ -262,15 +257,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
257
  requirements:
263
258
  - - ">="
264
259
  - !ruby/object:Gem::Version
265
- version: '3.0'
260
+ version: '3.2'
266
261
  required_rubygems_version: !ruby/object:Gem::Requirement
267
262
  requirements:
268
263
  - - ">="
269
264
  - !ruby/object:Gem::Version
270
265
  version: '0'
271
266
  requirements: []
272
- rubygems_version: 3.5.22
273
- signing_key:
267
+ rubygems_version: 3.6.9
274
268
  specification_version: 4
275
269
  summary: Consent permission based authorization
276
270
  test_files: []
@@ -1,17 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "base64"
6
- gem "bigdecimal"
7
- gem "erb", "< 5.1"
8
- gem "logger"
9
- gem "mutex_m"
10
- gem "net-imap", "< 0.5.0"
11
- gem "nokogiri", "< 1.19"
12
- gem "rubocop-powerhome", path: "../../rubocop-powerhome"
13
- gem "securerandom", "< 0.4"
14
- gem "zeitwerk", "< 2.7.0"
15
- gem "rails", "6.1.7.7"
16
-
17
- gemspec path: "../"