pundit 2.4.0 → 2.5.1
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 +4 -4
- data/CHANGELOG.md +66 -42
- data/README.md +31 -1
- data/lib/generators/pundit/install/install_generator.rb +3 -1
- data/lib/generators/pundit/policy/policy_generator.rb +3 -1
- data/lib/generators/rspec/policy_generator.rb +4 -1
- data/lib/generators/test_unit/policy_generator.rb +4 -1
- data/lib/pundit/authorization.rb +170 -77
- data/lib/pundit/cache_store/legacy_store.rb +10 -0
- data/lib/pundit/cache_store/null_store.rb +12 -0
- data/lib/pundit/cache_store.rb +24 -0
- data/lib/pundit/context.rb +89 -26
- data/lib/pundit/error.rb +71 -0
- data/lib/pundit/helper.rb +16 -0
- data/lib/pundit/policy_finder.rb +33 -1
- data/lib/pundit/railtie.rb +20 -0
- data/lib/pundit/rspec.rb +69 -6
- data/lib/pundit/version.rb +2 -1
- data/lib/pundit.rb +27 -61
- metadata +19 -179
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
- data/.github/PULL_REQUEST_TEMPLATE/gem_release_template.md +0 -8
- data/.github/pull_request_template.md +0 -9
- data/.github/workflows/main.yml +0 -112
- data/.github/workflows/push_gem.yml +0 -33
- data/.gitignore +0 -19
- data/.rubocop.yml +0 -63
- data/.yardopts +0 -1
- data/CODE_OF_CONDUCT.md +0 -28
- data/CONTRIBUTING.md +0 -31
- data/Gemfile +0 -8
- data/Rakefile +0 -20
- data/config/rubocop-rspec.yml +0 -5
- data/pundit.gemspec +0 -35
- data/spec/authorization_spec.rb +0 -274
- data/spec/dsl_spec.rb +0 -30
- data/spec/generators_spec.rb +0 -43
- data/spec/policies/post_policy_spec.rb +0 -49
- data/spec/policy_finder_spec.rb +0 -187
- data/spec/pundit_spec.rb +0 -448
- data/spec/spec_helper.rb +0 -352
- /data/lib/generators/pundit/install/templates/{application_policy.rb → application_policy.rb.tt} +0 -0
- /data/lib/generators/pundit/policy/templates/{policy.rb → policy.rb.tt} +0 -0
- /data/lib/generators/rspec/templates/{policy_spec.rb → policy_spec.rb.tt} +0 -0
- /data/lib/generators/test_unit/templates/{policy_test.rb → policy_test.rb.tt} +0 -0
data/lib/pundit.rb
CHANGED
@@ -1,65 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
4
|
+
|
3
5
|
require "pundit/version"
|
6
|
+
require "pundit/error"
|
4
7
|
require "pundit/policy_finder"
|
5
|
-
require "active_support/concern"
|
6
|
-
require "active_support/core_ext/string/inflections"
|
7
|
-
require "active_support/core_ext/object/blank"
|
8
|
-
require "active_support/core_ext/module/introspection"
|
9
|
-
require "active_support/dependencies/autoload"
|
10
|
-
require "pundit/authorization"
|
11
8
|
require "pundit/context"
|
9
|
+
require "pundit/authorization"
|
10
|
+
require "pundit/helper"
|
11
|
+
require "pundit/cache_store"
|
12
12
|
require "pundit/cache_store/null_store"
|
13
13
|
require "pundit/cache_store/legacy_store"
|
14
|
+
require "pundit/railtie" if defined?(Rails)
|
14
15
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# keep it here with compact class style definition.
|
18
|
-
class Pundit::Error < StandardError; end # rubocop:disable Style/ClassAndModuleChildren
|
19
|
-
|
16
|
+
# Hello? Yes, this is Pundit.
|
17
|
+
#
|
20
18
|
# @api public
|
21
19
|
module Pundit
|
22
|
-
|
20
|
+
# @api private
|
21
|
+
# @since v1.0.0
|
22
|
+
# @deprecated See {Pundit::PolicyFinder}
|
23
|
+
SUFFIX = Pundit::PolicyFinder::SUFFIX
|
23
24
|
|
24
25
|
# @api private
|
26
|
+
# @private
|
27
|
+
# @since v0.1.0
|
25
28
|
module Generators; end
|
26
29
|
|
27
|
-
# Error that will be raised when authorization has failed
|
28
|
-
class NotAuthorizedError < Error
|
29
|
-
attr_reader :query, :record, :policy
|
30
|
-
|
31
|
-
def initialize(options = {})
|
32
|
-
if options.is_a? String
|
33
|
-
message = options
|
34
|
-
else
|
35
|
-
@query = options[:query]
|
36
|
-
@record = options[:record]
|
37
|
-
@policy = options[:policy]
|
38
|
-
|
39
|
-
message = options.fetch(:message) do
|
40
|
-
record_name = record.is_a?(Class) ? record.to_s : "this #{record.class}"
|
41
|
-
"not allowed to #{policy.class}##{query} #{record_name}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
super(message)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Error that will be raised if a policy or policy scope constructor is not called correctly.
|
50
|
-
class InvalidConstructorError < Error; end
|
51
|
-
|
52
|
-
# Error that will be raised if a controller action has not called the
|
53
|
-
# `authorize` or `skip_authorization` methods.
|
54
|
-
class AuthorizationNotPerformedError < Error; end
|
55
|
-
|
56
|
-
# Error that will be raised if a controller action has not called the
|
57
|
-
# `policy_scope` or `skip_policy_scope` methods.
|
58
|
-
class PolicyScopingNotPerformedError < AuthorizationNotPerformedError; end
|
59
|
-
|
60
|
-
# Error that will be raised if a policy or policy scope is not defined.
|
61
|
-
class NotDefinedError < Error; end
|
62
|
-
|
63
30
|
def self.included(base)
|
64
31
|
location = caller_locations(1, 1).first
|
65
32
|
warn <<~WARNING
|
@@ -70,10 +37,12 @@ module Pundit
|
|
70
37
|
end
|
71
38
|
|
72
39
|
class << self
|
73
|
-
# @see
|
40
|
+
# @see Pundit::Context#authorize
|
41
|
+
# @since v1.0.0
|
74
42
|
def authorize(user, record, query, policy_class: nil, cache: nil)
|
75
43
|
context = if cache
|
76
|
-
|
44
|
+
policy_cache = CacheStore::LegacyStore.new(cache)
|
45
|
+
Context.new(user: user, policy_cache: policy_cache)
|
77
46
|
else
|
78
47
|
Context.new(user: user)
|
79
48
|
end
|
@@ -81,31 +50,28 @@ module Pundit
|
|
81
50
|
context.authorize(record, query: query, policy_class: policy_class)
|
82
51
|
end
|
83
52
|
|
84
|
-
# @see
|
53
|
+
# @see Pundit::Context#policy_scope
|
54
|
+
# @since v0.1.0
|
85
55
|
def policy_scope(user, *args, **kwargs, &block)
|
86
56
|
Context.new(user: user).policy_scope(*args, **kwargs, &block)
|
87
57
|
end
|
88
58
|
|
89
|
-
# @see
|
59
|
+
# @see Pundit::Context#policy_scope!
|
60
|
+
# @since v0.1.0
|
90
61
|
def policy_scope!(user, *args, **kwargs, &block)
|
91
62
|
Context.new(user: user).policy_scope!(*args, **kwargs, &block)
|
92
63
|
end
|
93
64
|
|
94
|
-
# @see
|
65
|
+
# @see Pundit::Context#policy
|
66
|
+
# @since v0.1.0
|
95
67
|
def policy(user, *args, **kwargs, &block)
|
96
68
|
Context.new(user: user).policy(*args, **kwargs, &block)
|
97
69
|
end
|
98
70
|
|
99
|
-
# @see
|
71
|
+
# @see Pundit::Context#policy!
|
72
|
+
# @since v0.1.0
|
100
73
|
def policy!(user, *args, **kwargs, &block)
|
101
74
|
Context.new(user: user).policy!(*args, **kwargs, &block)
|
102
75
|
end
|
103
76
|
end
|
104
|
-
|
105
|
-
# @api private
|
106
|
-
module Helper
|
107
|
-
def policy_scope(scope)
|
108
|
-
pundit_policy_scope(scope)
|
109
|
-
end
|
110
|
-
end
|
111
77
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pundit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
- Varvet AB
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -25,146 +25,6 @@ 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: '0'
|
133
|
-
type: :development
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - ">="
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '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
|
@@ -173,56 +33,43 @@ executables: []
|
|
173
33
|
extensions: []
|
174
34
|
extra_rdoc_files: []
|
175
35
|
files:
|
176
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
177
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
178
|
-
- ".github/PULL_REQUEST_TEMPLATE/gem_release_template.md"
|
179
|
-
- ".github/pull_request_template.md"
|
180
|
-
- ".github/workflows/main.yml"
|
181
|
-
- ".github/workflows/push_gem.yml"
|
182
|
-
- ".gitignore"
|
183
|
-
- ".rubocop.yml"
|
184
|
-
- ".yardopts"
|
185
36
|
- CHANGELOG.md
|
186
|
-
- CODE_OF_CONDUCT.md
|
187
|
-
- CONTRIBUTING.md
|
188
|
-
- Gemfile
|
189
37
|
- LICENSE.txt
|
190
38
|
- README.md
|
191
|
-
- Rakefile
|
192
39
|
- SECURITY.md
|
193
|
-
- config/rubocop-rspec.yml
|
194
40
|
- lib/generators/pundit/install/USAGE
|
195
41
|
- lib/generators/pundit/install/install_generator.rb
|
196
|
-
- lib/generators/pundit/install/templates/application_policy.rb
|
42
|
+
- lib/generators/pundit/install/templates/application_policy.rb.tt
|
197
43
|
- lib/generators/pundit/policy/USAGE
|
198
44
|
- lib/generators/pundit/policy/policy_generator.rb
|
199
|
-
- lib/generators/pundit/policy/templates/policy.rb
|
45
|
+
- lib/generators/pundit/policy/templates/policy.rb.tt
|
200
46
|
- lib/generators/rspec/policy_generator.rb
|
201
|
-
- lib/generators/rspec/templates/policy_spec.rb
|
47
|
+
- lib/generators/rspec/templates/policy_spec.rb.tt
|
202
48
|
- lib/generators/test_unit/policy_generator.rb
|
203
|
-
- lib/generators/test_unit/templates/policy_test.rb
|
49
|
+
- lib/generators/test_unit/templates/policy_test.rb.tt
|
204
50
|
- lib/pundit.rb
|
205
51
|
- lib/pundit/authorization.rb
|
52
|
+
- lib/pundit/cache_store.rb
|
206
53
|
- lib/pundit/cache_store/legacy_store.rb
|
207
54
|
- lib/pundit/cache_store/null_store.rb
|
208
55
|
- lib/pundit/context.rb
|
56
|
+
- lib/pundit/error.rb
|
57
|
+
- lib/pundit/helper.rb
|
209
58
|
- lib/pundit/policy_finder.rb
|
59
|
+
- lib/pundit/railtie.rb
|
210
60
|
- lib/pundit/rspec.rb
|
211
61
|
- lib/pundit/version.rb
|
212
|
-
- pundit.gemspec
|
213
|
-
- spec/authorization_spec.rb
|
214
|
-
- spec/dsl_spec.rb
|
215
|
-
- spec/generators_spec.rb
|
216
|
-
- spec/policies/post_policy_spec.rb
|
217
|
-
- spec/policy_finder_spec.rb
|
218
|
-
- spec/pundit_spec.rb
|
219
|
-
- spec/spec_helper.rb
|
220
62
|
homepage: https://github.com/varvet/pundit
|
221
63
|
licenses:
|
222
64
|
- MIT
|
223
65
|
metadata:
|
224
66
|
rubygems_mfa_required: 'true'
|
225
|
-
|
67
|
+
bug_tracker_uri: https://github.com/varvet/pundit/issues
|
68
|
+
changelog_uri: https://github.com/varvet/pundit/blob/main/CHANGELOG.md
|
69
|
+
documentation_uri: https://github.com/varvet/pundit/blob/main/README.md
|
70
|
+
homepage_uri: https://github.com/varvet/pundit
|
71
|
+
source_code_uri: https://github.com/varvet/pundit
|
72
|
+
post_install_message:
|
226
73
|
rdoc_options: []
|
227
74
|
require_paths:
|
228
75
|
- lib
|
@@ -238,14 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
85
|
version: '0'
|
239
86
|
requirements: []
|
240
87
|
rubygems_version: 3.5.11
|
241
|
-
signing_key:
|
88
|
+
signing_key:
|
242
89
|
specification_version: 4
|
243
90
|
summary: OO authorization for Rails
|
244
|
-
test_files:
|
245
|
-
- spec/authorization_spec.rb
|
246
|
-
- spec/dsl_spec.rb
|
247
|
-
- spec/generators_spec.rb
|
248
|
-
- spec/policies/post_policy_spec.rb
|
249
|
-
- spec/policy_finder_spec.rb
|
250
|
-
- spec/pundit_spec.rb
|
251
|
-
- spec/spec_helper.rb
|
91
|
+
test_files: []
|
@@ -1,20 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Bug report
|
3
|
-
about: Create a bug report to report a problem
|
4
|
-
title: ''
|
5
|
-
labels: problem
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Describe the bug**
|
11
|
-
A clear and concise description of what the bug is.
|
12
|
-
|
13
|
-
**To Reproduce**
|
14
|
-
Steps or runnable code to reproduce the problem.
|
15
|
-
|
16
|
-
**Expected behavior**
|
17
|
-
A clear and concise description of what you expected to happen.
|
18
|
-
|
19
|
-
**Additional context**
|
20
|
-
Add any other context about the problem here.
|
@@ -1,26 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Feature request
|
3
|
-
about: Suggest an idea
|
4
|
-
title: ''
|
5
|
-
labels: ['feature request']
|
6
|
-
assignees: ''
|
7
|
-
---
|
8
|
-
|
9
|
-
**Please consider**
|
10
|
-
- Could this feature break backwards-compatibility?
|
11
|
-
- Could this feature benefit the many who use Pundit?
|
12
|
-
- Could this feature be useful in _most_ projects that use Pundit?
|
13
|
-
- Would this feature require Rails?
|
14
|
-
- Am I open to creating a Pull Request with the necessary changes?
|
15
|
-
|
16
|
-
**Is your feature request related to a problem? Please describe.**
|
17
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
18
|
-
|
19
|
-
**Describe the solution you'd like**
|
20
|
-
A clear and concise description of how you'd like to approach solving the problem.
|
21
|
-
|
22
|
-
**Describe alternatives you've considered**
|
23
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
24
|
-
|
25
|
-
**Additional context**
|
26
|
-
Add any other context. Ex. if you've solved this problem in your own projects already, how that worked, and why the feature should be moved and maintained in Pundit instead.
|
@@ -1,8 +0,0 @@
|
|
1
|
-
## To do
|
2
|
-
|
3
|
-
- [ ] Make changes:
|
4
|
-
- [ ] Bump `Pundit::VERSION` in `lib/pundit/version.rb`.
|
5
|
-
- [ ] Update `CHANGELOG.md`.
|
6
|
-
- [ ] Open pull request 🚀 and merge it.
|
7
|
-
- [ ] Run [push gem](https://github.com/varvet/pundit/actions/workflows/push_gem.yml) GitHub Action.
|
8
|
-
- [ ] Make an announcement in [Pundit discussions](https://github.com/varvet/pundit/discussions/categories/announcements)
|
@@ -1,9 +0,0 @@
|
|
1
|
-
## To do
|
2
|
-
|
3
|
-
- [ ] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute).
|
4
|
-
- [ ] I have added relevant tests.
|
5
|
-
- [ ] I have adjusted relevant documentation.
|
6
|
-
- [ ] I have made sure the individual commits are meaningful.
|
7
|
-
- [ ] I have added relevant lines to the CHANGELOG.
|
8
|
-
|
9
|
-
PS: Thank you for contributing to Pundit ❤️
|
data/.github/workflows/main.yml
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
name: Main
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ "main" ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ "main" ]
|
8
|
-
workflow_dispatch:
|
9
|
-
|
10
|
-
permissions:
|
11
|
-
contents: read
|
12
|
-
|
13
|
-
env:
|
14
|
-
CC_TEST_REPORTER_ID: "ac477089fe20ab4fc7e0d304cab75f72d73d58a7596d366935d18fcc7d51f8f9"
|
15
|
-
|
16
|
-
# `github.ref` points to the *merge commit* when running tests on a pull request, which will be a commit
|
17
|
-
# that doesn't exists in our code base. Since this workflow triggers from a PR, we use the HEAD SHA instead.
|
18
|
-
#
|
19
|
-
# NOTE: These are both used by Code Climate (cc-test-reporter).
|
20
|
-
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
21
|
-
GIT_BRANCH: ${{ github.head_ref }}
|
22
|
-
|
23
|
-
jobs:
|
24
|
-
matrix-test:
|
25
|
-
runs-on: ubuntu-latest
|
26
|
-
continue-on-error: ${{ matrix.allow-failure || false }}
|
27
|
-
strategy:
|
28
|
-
fail-fast: false
|
29
|
-
matrix:
|
30
|
-
ruby-version:
|
31
|
-
- '3.1'
|
32
|
-
- '3.2'
|
33
|
-
- '3.3'
|
34
|
-
- 'jruby-9.3.10' # oldest supported jruby
|
35
|
-
- 'jruby'
|
36
|
-
include: # HEAD-versions
|
37
|
-
- ruby-version: 'head'
|
38
|
-
allow-failure: true
|
39
|
-
- ruby-version: 'jruby-head'
|
40
|
-
allow-failure: true
|
41
|
-
- ruby-version: 'truffleruby-head'
|
42
|
-
allow-failure: true
|
43
|
-
|
44
|
-
steps:
|
45
|
-
- uses: actions/checkout@v4
|
46
|
-
- name: Set up Ruby
|
47
|
-
uses: ruby/setup-ruby@v1
|
48
|
-
with:
|
49
|
-
rubygems: latest
|
50
|
-
ruby-version: ${{ matrix.ruby-version }}
|
51
|
-
bundler-cache: ${{ !startsWith(matrix.ruby-version, 'jruby') }}
|
52
|
-
- name: Bundler install (JRuby workaround)
|
53
|
-
if: ${{ startsWith(matrix.ruby-version, 'jruby') }}
|
54
|
-
run: |
|
55
|
-
gem install psych
|
56
|
-
bundle install
|
57
|
-
- name: Run tests
|
58
|
-
run: bundle exec rspec
|
59
|
-
|
60
|
-
test:
|
61
|
-
runs-on: ubuntu-latest
|
62
|
-
steps:
|
63
|
-
- uses: actions/checkout@v4
|
64
|
-
- name: Set up Ruby
|
65
|
-
uses: ruby/setup-ruby@v1
|
66
|
-
with:
|
67
|
-
rubygems: latest
|
68
|
-
ruby-version: 'ruby'
|
69
|
-
bundler-cache: true
|
70
|
-
- name: "Download cc-test-reporter from codeclimate.com"
|
71
|
-
run: |
|
72
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
73
|
-
chmod +x ./cc-test-reporter
|
74
|
-
- name: "Report to Code Climate that we will send a coverage report."
|
75
|
-
run: ./cc-test-reporter before-build
|
76
|
-
- name: Run tests
|
77
|
-
run: bundle exec rspec
|
78
|
-
env:
|
79
|
-
COVERAGE: 1
|
80
|
-
- name: Upload code coverage to Code Climate
|
81
|
-
run: |
|
82
|
-
./cc-test-reporter after-build \
|
83
|
-
--coverage-input-type simplecov \
|
84
|
-
./coverage/.resultset.json
|
85
|
-
|
86
|
-
rubocop:
|
87
|
-
runs-on: ubuntu-latest
|
88
|
-
steps:
|
89
|
-
- uses: actions/checkout@v4
|
90
|
-
- name: Set up Ruby
|
91
|
-
uses: ruby/setup-ruby@v1
|
92
|
-
with:
|
93
|
-
rubygems: default
|
94
|
-
ruby-version: 'ruby'
|
95
|
-
bundler-cache: false
|
96
|
-
- run: bundle install
|
97
|
-
- name: Run RuboCop
|
98
|
-
run: bundle exec rubocop
|
99
|
-
|
100
|
-
required-checks:
|
101
|
-
runs-on: ubuntu-latest
|
102
|
-
if: ${{ always() }}
|
103
|
-
needs:
|
104
|
-
- test
|
105
|
-
- matrix-test
|
106
|
-
- rubocop
|
107
|
-
steps:
|
108
|
-
- name: failure
|
109
|
-
if: ${{ failure() || contains(needs.*.result, 'failure') }}
|
110
|
-
run: exit 1
|
111
|
-
- name: success
|
112
|
-
run: exit 0
|
@@ -1,33 +0,0 @@
|
|
1
|
-
name: Push Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
workflow_dispatch:
|
5
|
-
|
6
|
-
permissions:
|
7
|
-
contents: read
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
push:
|
11
|
-
if: github.repository == 'varvet/pundit'
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
|
14
|
-
permissions:
|
15
|
-
contents: write
|
16
|
-
id-token: write
|
17
|
-
|
18
|
-
steps:
|
19
|
-
# Set up
|
20
|
-
- name: Harden Runner
|
21
|
-
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
|
22
|
-
with:
|
23
|
-
egress-policy: audit
|
24
|
-
|
25
|
-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
26
|
-
- name: Set up Ruby
|
27
|
-
uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
|
28
|
-
with:
|
29
|
-
bundler-cache: true
|
30
|
-
ruby-version: ruby
|
31
|
-
|
32
|
-
# Release
|
33
|
-
- uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1+ unreleased
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 3.1
|
3
|
-
Exclude:
|
4
|
-
- "lib/generators/**/templates/**/*"
|
5
|
-
<% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
|
6
|
-
- <%= path.sub(/^!! /, '').sub(/\/$/, '/**/*') %>
|
7
|
-
<% end %>
|
8
|
-
SuggestExtensions: false
|
9
|
-
NewCops: disable
|
10
|
-
|
11
|
-
Metrics/BlockLength:
|
12
|
-
Exclude:
|
13
|
-
- "**/*_spec.rb"
|
14
|
-
|
15
|
-
Metrics/MethodLength:
|
16
|
-
Max: 40
|
17
|
-
|
18
|
-
Metrics/ModuleLength:
|
19
|
-
Max: 200
|
20
|
-
Exclude:
|
21
|
-
- "**/*_spec.rb"
|
22
|
-
|
23
|
-
Layout/LineLength:
|
24
|
-
Max: 120
|
25
|
-
|
26
|
-
Gemspec/RequiredRubyVersion:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Layout/ParameterAlignment:
|
30
|
-
EnforcedStyle: with_fixed_indentation
|
31
|
-
|
32
|
-
Layout/CaseIndentation:
|
33
|
-
EnforcedStyle: case
|
34
|
-
SupportedStyles:
|
35
|
-
- case
|
36
|
-
- end
|
37
|
-
IndentOneStep: true
|
38
|
-
|
39
|
-
Layout/EndAlignment:
|
40
|
-
EnforcedStyleAlignWith: variable
|
41
|
-
|
42
|
-
Style/PercentLiteralDelimiters:
|
43
|
-
PreferredDelimiters:
|
44
|
-
'%w': "[]"
|
45
|
-
'%W': "[]"
|
46
|
-
|
47
|
-
Style/StringLiterals:
|
48
|
-
EnforcedStyle: double_quotes
|
49
|
-
|
50
|
-
Style/StringLiteralsInInterpolation:
|
51
|
-
EnforcedStyle: double_quotes
|
52
|
-
|
53
|
-
Style/StructInheritance:
|
54
|
-
Enabled: false
|
55
|
-
|
56
|
-
Style/DoubleNegation:
|
57
|
-
Enabled: false
|
58
|
-
|
59
|
-
Style/Documentation:
|
60
|
-
Enabled: false # TODO: Enable again once we have more docs
|
61
|
-
|
62
|
-
Style/HashSyntax:
|
63
|
-
EnforcedShorthandSyntax: never
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--api public --hide-void-return --markup markdown
|