pundit 2.2.0 → 2.5.2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -29
  3. data/CONTRIBUTING.md +3 -5
  4. data/README.md +125 -54
  5. data/SECURITY.md +19 -0
  6. data/config/rubocop-rspec.yml +5 -0
  7. data/lib/generators/pundit/install/install_generator.rb +3 -1
  8. data/lib/generators/pundit/install/templates/{application_policy.rb → application_policy.rb.tt} +1 -1
  9. data/lib/generators/pundit/policy/policy_generator.rb +3 -1
  10. data/lib/generators/pundit/policy/templates/policy.rb.tt +16 -0
  11. data/lib/generators/rspec/policy_generator.rb +4 -1
  12. data/lib/generators/rspec/templates/{policy_spec.rb → policy_spec.rb.tt} +1 -1
  13. data/lib/generators/test_unit/policy_generator.rb +4 -1
  14. data/lib/pundit/authorization.rb +176 -75
  15. data/lib/pundit/cache_store/legacy_store.rb +27 -0
  16. data/lib/pundit/cache_store/null_store.rb +30 -0
  17. data/lib/pundit/cache_store.rb +24 -0
  18. data/lib/pundit/context.rb +190 -0
  19. data/lib/pundit/error.rb +71 -0
  20. data/lib/pundit/helper.rb +16 -0
  21. data/lib/pundit/policy_finder.rb +34 -2
  22. data/lib/pundit/railtie.rb +20 -0
  23. data/lib/pundit/rspec.rb +92 -7
  24. data/lib/pundit/version.rb +2 -1
  25. data/lib/pundit.rb +45 -140
  26. metadata +25 -170
  27. data/.gitignore +0 -19
  28. data/.rubocop.yml +0 -72
  29. data/.travis.yml +0 -26
  30. data/.yardopts +0 -1
  31. data/CODE_OF_CONDUCT.md +0 -28
  32. data/Gemfile +0 -7
  33. data/Rakefile +0 -20
  34. data/lib/generators/pundit/policy/templates/policy.rb +0 -10
  35. data/pundit.gemspec +0 -33
  36. data/spec/authorization_spec.rb +0 -258
  37. data/spec/generators_spec.rb +0 -43
  38. data/spec/policies/post_policy_spec.rb +0 -22
  39. data/spec/policy_finder_spec.rb +0 -187
  40. data/spec/pundit_spec.rb +0 -427
  41. data/spec/spec_helper.rb +0 -275
  42. /data/lib/generators/test_unit/templates/{policy_test.rb → policy_test.rb.tt} +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pundit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-11 00:00:00.000000000 Z
12
+ date: 2025-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -25,191 +25,52 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 3.0.0
28
- - !ruby/object:Gem::Dependency
29
- name: actionpack
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 3.0.0
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: 3.0.0
42
- - !ruby/object:Gem::Dependency
43
- name: activemodel
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 3.0.0
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 3.0.0
56
- - !ruby/object:Gem::Dependency
57
- name: bundler
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: pry
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: railties
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 3.0.0
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: 3.0.0
98
- - !ruby/object:Gem::Dependency
99
- name: rake
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rspec
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: 3.0.0
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: 3.0.0
126
- - !ruby/object:Gem::Dependency
127
- name: rubocop
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - '='
131
- - !ruby/object:Gem::Version
132
- version: 1.24.0
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - '='
138
- - !ruby/object:Gem::Version
139
- version: 1.24.0
140
- - !ruby/object:Gem::Dependency
141
- name: simplecov
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- version: 0.17.0
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: 0.17.0
154
- - !ruby/object:Gem::Dependency
155
- name: yard
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
28
  description: Object oriented authorization for Rails applications
169
29
  email:
170
30
  - jonas.nicklas@gmail.com
171
- - dev@elabs.se
31
+ - info@varvet.com
172
32
  executables: []
173
33
  extensions: []
174
34
  extra_rdoc_files: []
175
35
  files:
176
- - ".gitignore"
177
- - ".rubocop.yml"
178
- - ".travis.yml"
179
- - ".yardopts"
180
36
  - CHANGELOG.md
181
- - CODE_OF_CONDUCT.md
182
37
  - CONTRIBUTING.md
183
- - Gemfile
184
38
  - LICENSE.txt
185
39
  - README.md
186
- - Rakefile
40
+ - SECURITY.md
41
+ - config/rubocop-rspec.yml
187
42
  - lib/generators/pundit/install/USAGE
188
43
  - lib/generators/pundit/install/install_generator.rb
189
- - lib/generators/pundit/install/templates/application_policy.rb
44
+ - lib/generators/pundit/install/templates/application_policy.rb.tt
190
45
  - lib/generators/pundit/policy/USAGE
191
46
  - lib/generators/pundit/policy/policy_generator.rb
192
- - lib/generators/pundit/policy/templates/policy.rb
47
+ - lib/generators/pundit/policy/templates/policy.rb.tt
193
48
  - lib/generators/rspec/policy_generator.rb
194
- - lib/generators/rspec/templates/policy_spec.rb
49
+ - lib/generators/rspec/templates/policy_spec.rb.tt
195
50
  - lib/generators/test_unit/policy_generator.rb
196
- - lib/generators/test_unit/templates/policy_test.rb
51
+ - lib/generators/test_unit/templates/policy_test.rb.tt
197
52
  - lib/pundit.rb
198
53
  - lib/pundit/authorization.rb
54
+ - lib/pundit/cache_store.rb
55
+ - lib/pundit/cache_store/legacy_store.rb
56
+ - lib/pundit/cache_store/null_store.rb
57
+ - lib/pundit/context.rb
58
+ - lib/pundit/error.rb
59
+ - lib/pundit/helper.rb
199
60
  - lib/pundit/policy_finder.rb
61
+ - lib/pundit/railtie.rb
200
62
  - lib/pundit/rspec.rb
201
63
  - lib/pundit/version.rb
202
- - pundit.gemspec
203
- - spec/authorization_spec.rb
204
- - spec/generators_spec.rb
205
- - spec/policies/post_policy_spec.rb
206
- - spec/policy_finder_spec.rb
207
- - spec/pundit_spec.rb
208
- - spec/spec_helper.rb
209
64
  homepage: https://github.com/varvet/pundit
210
65
  licenses:
211
66
  - MIT
212
- metadata: {}
67
+ metadata:
68
+ rubygems_mfa_required: 'true'
69
+ bug_tracker_uri: https://github.com/varvet/pundit/issues
70
+ changelog_uri: https://github.com/varvet/pundit/blob/main/CHANGELOG.md
71
+ documentation_uri: https://github.com/varvet/pundit/blob/main/README.md
72
+ homepage_uri: https://github.com/varvet/pundit
73
+ source_code_uri: https://github.com/varvet/pundit
213
74
  post_install_message:
214
75
  rdoc_options: []
215
76
  require_paths:
@@ -225,14 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
86
  - !ruby/object:Gem::Version
226
87
  version: '0'
227
88
  requirements: []
228
- rubygems_version: 3.2.32
89
+ rubygems_version: 3.5.11
229
90
  signing_key:
230
91
  specification_version: 4
231
92
  summary: OO authorization for Rails
232
- test_files:
233
- - spec/authorization_spec.rb
234
- - spec/generators_spec.rb
235
- - spec/policies/post_policy_spec.rb
236
- - spec/policy_finder_spec.rb
237
- - spec/pundit_spec.rb
238
- - spec/spec_helper.rb
93
+ test_files: []
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .coverage
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
19
- bin
data/.rubocop.yml DELETED
@@ -1,72 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
- Exclude:
4
- - "lib/generators/**/templates/**/*"
5
- SuggestExtensions: false
6
- NewCops: disable
7
-
8
- Metrics/BlockLength:
9
- Exclude:
10
- - "**/*_spec.rb"
11
-
12
- Metrics/MethodLength:
13
- Max: 40
14
-
15
- Metrics/ModuleLength:
16
- Max: 200
17
- Exclude:
18
- - "**/*_spec.rb"
19
-
20
- Layout/LineLength:
21
- Max: 120
22
-
23
- Metrics/AbcSize:
24
- Enabled: false
25
-
26
- Metrics/CyclomaticComplexity:
27
- Enabled: false
28
-
29
- Metrics/PerceivedComplexity:
30
- Enabled: false
31
-
32
- Gemspec/RequiredRubyVersion:
33
- Enabled: false
34
-
35
- Layout/ParameterAlignment:
36
- EnforcedStyle: with_fixed_indentation
37
-
38
- Layout/CaseIndentation:
39
- EnforcedStyle: case
40
- SupportedStyles:
41
- - case
42
- - end
43
- IndentOneStep: true
44
-
45
- Layout/EndAlignment:
46
- EnforcedStyleAlignWith: variable
47
-
48
- Style/PercentLiteralDelimiters:
49
- PreferredDelimiters:
50
- '%w': "[]"
51
- '%W': "[]"
52
-
53
- Style/StringLiterals:
54
- EnforcedStyle: double_quotes
55
-
56
- Style/StringLiteralsInInterpolation:
57
- EnforcedStyle: double_quotes
58
-
59
- Style/StructInheritance:
60
- Enabled: false
61
-
62
- Style/AndOr:
63
- Enabled: false
64
-
65
- Style/Not:
66
- Enabled: false
67
-
68
- Style/DoubleNegation:
69
- Enabled: false
70
-
71
- Style/Documentation:
72
- Enabled: false # TODO: Enable again once we have more docs
data/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- language: ruby
2
- dist: focal
3
-
4
- matrix:
5
- include:
6
- - name: "RuboCop lint on pre-installed Ruby version"
7
- rvm: 2.7.1 # Pre-installed Ruby version
8
- before_install:
9
- - gem install bundler
10
- script: bundle exec rake rubocop # ONLY lint once, first
11
- - rvm: 2.6.7
12
- before_script:
13
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
- - chmod +x ./cc-test-reporter
15
- - ./cc-test-reporter before-build
16
- after_script:
17
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
18
- - rvm: 2.7.3
19
- - rvm: 3.0.1
20
- - rvm: 3.1.0
21
- - rvm: jruby-9.2.17.0
22
- env:
23
- - JRUBY_OPTS="--debug"
24
- - rvm: truffleruby-head
25
- allow_failures:
26
- - rvm: truffleruby-head
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --api public --hide-void-return --markup markdown
data/CODE_OF_CONDUCT.md DELETED
@@ -1,28 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all
4
- people who contribute through reporting issues, posting feature requests,
5
- updating documentation, submitting pull requests or patches, and other
6
- activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, age, or religion.
12
-
13
- Examples of unacceptable behavior by participants include the use of sexual
14
- language or imagery, derogatory comments or personal attacks, trolling, public
15
- or private harassment, insults, or other unprofessional conduct.
16
-
17
- Project maintainers have the right and responsibility to remove, edit, or
18
- reject comments, commits, code, wiki edits, issues, and other contributions
19
- that are not aligned to this Code of Conduct. Project maintainers who do not
20
- follow the Code of Conduct may be removed from the project team.
21
-
22
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
23
- reported by opening an issue or contacting one or more of the project
24
- maintainers.
25
-
26
- This Code of Conduct is adapted from the [Contributor
27
- Covenant](http:contributor-covenant.org), version 1.0.0, available at
28
- [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- ruby RUBY_VERSION
6
-
7
- gemspec
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems"
4
- require "bundler/gem_tasks"
5
- require "rspec/core/rake_task"
6
- require "yard"
7
- require "rubocop/rake_task"
8
-
9
- RuboCop::RakeTask.new
10
-
11
- desc "Run all examples"
12
- RSpec::Core::RakeTask.new(:spec) do |t|
13
- t.rspec_opts = %w[--color]
14
- end
15
-
16
- YARD::Rake::YardocTask.new do |t|
17
- t.files = ["lib/**/*.rb"]
18
- end
19
-
20
- task default: :spec
@@ -1,10 +0,0 @@
1
- <% module_namespacing do -%>
2
- class <%= class_name %>Policy < ApplicationPolicy
3
- class Scope < Scope
4
- # NOTE: Be explicit about which records you allow access to!
5
- # def resolve
6
- # scope.all
7
- # end
8
- end
9
- end
10
- <% end -%>
data/pundit.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "pundit/version"
6
-
7
- Gem::Specification.new do |gem|
8
- gem.name = "pundit"
9
- gem.version = Pundit::VERSION
10
- gem.authors = ["Jonas Nicklas", "Varvet AB"]
11
- gem.email = ["jonas.nicklas@gmail.com", "dev@elabs.se"]
12
- gem.description = "Object oriented authorization for Rails applications"
13
- gem.summary = "OO authorization for Rails"
14
- gem.homepage = "https://github.com/varvet/pundit"
15
- gem.license = "MIT"
16
-
17
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
19
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
- gem.require_paths = ["lib"]
21
-
22
- gem.add_dependency "activesupport", ">= 3.0.0"
23
- gem.add_development_dependency "actionpack", ">= 3.0.0"
24
- gem.add_development_dependency "activemodel", ">= 3.0.0"
25
- gem.add_development_dependency "bundler"
26
- gem.add_development_dependency "pry"
27
- gem.add_development_dependency "railties", ">= 3.0.0"
28
- gem.add_development_dependency "rake"
29
- gem.add_development_dependency "rspec", ">= 3.0.0"
30
- gem.add_development_dependency "rubocop", "1.24.0"
31
- gem.add_development_dependency "simplecov", ">= 0.17.0"
32
- gem.add_development_dependency "yard"
33
- end