snfoil-policy 0.0.4 → 1.0.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 +4 -4
- data/lib/snfoil/policy/version.rb +1 -1
- data/lib/snfoil/policy.rb +15 -7
- data/snfoil-policy.gemspec +6 -6
- metadata +11 -18
- data/.fasterer.yml +0 -22
- data/.github/workflows/main.yml +0 -50
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -40
- data/Rakefile +0 -12
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 905c2b441897ed1fdd4e183cb1dfd4daa32a3ad851e73f4634fc5cfe88f51f1d
|
4
|
+
data.tar.gz: 2ca0b403563f5fce64c9a31c818575c9b34d89f20b6c2033dab7e2f20e32cc01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f7654605cbf5c05e230313200b1dcc4a6dbb4bec6e41069c3261196766a9506293f4892f8b9c21d831c47749320132570d43b56077d59b649f698daee2c7caa
|
7
|
+
data.tar.gz: 96ac8425c4663798e92df0b543a7589ecc2b50ad0773e560dad5f329e01268dc82b0303b21e495c66764be39e275cf1858a1e33917b85a6f375a67cdc4693f28
|
data/lib/snfoil/policy.rb
CHANGED
@@ -28,21 +28,29 @@ module SnFoil
|
|
28
28
|
extend ActiveSupport::Concern
|
29
29
|
|
30
30
|
class_methods do
|
31
|
-
def
|
32
|
-
@
|
31
|
+
def snfoil_permissions
|
32
|
+
@snfoil_permissions ||= {}
|
33
33
|
end
|
34
34
|
|
35
35
|
def permission(authorization_type, entity_class = nil, with: nil, &block)
|
36
|
-
@
|
37
|
-
@
|
38
|
-
if @
|
36
|
+
@snfoil_permissions ||= {}
|
37
|
+
@snfoil_permissions[authorization_type] ||= {}
|
38
|
+
if @snfoil_permissions[authorization_type][entity_class]
|
39
39
|
raise SnFoil::Policy::Error,
|
40
40
|
"permission #{entity_class} #{authorization_type} already defined for #{name}"
|
41
41
|
end
|
42
42
|
|
43
|
-
@
|
43
|
+
@snfoil_permissions[authorization_type][entity_class] = build_permission_exec(with, block)
|
44
44
|
define_permission_method(authorization_type)
|
45
45
|
end
|
46
|
+
|
47
|
+
def inherited(subclass)
|
48
|
+
super
|
49
|
+
|
50
|
+
instance_variables.grep(/@snfoil_.+/).each do |i|
|
51
|
+
subclass.instance_variable_set(i, instance_variable_get(i).dup)
|
52
|
+
end
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
attr_reader :record, :entity
|
@@ -83,7 +91,7 @@ module SnFoil
|
|
83
91
|
|
84
92
|
def define_permission_method(authorization_type)
|
85
93
|
define_method authorization_type do
|
86
|
-
self.class.
|
94
|
+
self.class.snfoil_permissions[authorization_type].each do |klass, exec|
|
87
95
|
return instance_eval(&exec) if klass.nil? || entity.is_a?(klass)
|
88
96
|
end
|
89
97
|
|
data/snfoil-policy.gemspec
CHANGED
@@ -12,17 +12,17 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'A set of helper functions to build permission files inspired by Pundit.'
|
13
13
|
spec.homepage = 'https://github.com/limited-effort/snfoil-policy'
|
14
14
|
spec.license = 'Apache-2.0'
|
15
|
-
spec.required_ruby_version = '>= 2.
|
15
|
+
spec.required_ruby_version = '>= 2.7'
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
19
|
spec.metadata['changelog_uri'] = 'https://github.com/limited-effort/snfoil-policy/blob/main/CHANGELOG.md'
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
ignore_list = %r{\A(?:test/|spec/|bin/|features/|Rakefile|\.\w)}
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) { `git ls-files -z`.split("\x0").reject { |f| f.match(ignore_list) } }
|
26
26
|
|
27
27
|
spec.bindir = 'exe'
|
28
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
@@ -31,11 +31,11 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'activesupport', '>= 5.2.6'
|
32
32
|
|
33
33
|
spec.add_development_dependency 'bundle-audit', '~> 0.1.0'
|
34
|
-
spec.add_development_dependency 'fasterer', '~> 0.
|
34
|
+
spec.add_development_dependency 'fasterer', '~> 0.10.0'
|
35
35
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
36
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
37
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
38
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 1.29'
|
39
39
|
spec.add_development_dependency 'rubocop-performance', '~> 1.11'
|
40
40
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.5'
|
41
41
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snfoil-policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Howes
|
8
8
|
- Cliff Campbell
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: 0.10.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.10.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: pry-byebug
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,14 +101,14 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '1.
|
104
|
+
version: '1.29'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '1.
|
111
|
+
version: '1.29'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rubocop-performance
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,19 +145,11 @@ executables: []
|
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
|
-
- ".fasterer.yml"
|
149
|
-
- ".github/workflows/main.yml"
|
150
|
-
- ".gitignore"
|
151
|
-
- ".rspec"
|
152
|
-
- ".rubocop.yml"
|
153
148
|
- CHANGELOG.md
|
154
149
|
- CODE_OF_CONDUCT.md
|
155
150
|
- Gemfile
|
156
151
|
- LICENSE.txt
|
157
152
|
- README.md
|
158
|
-
- Rakefile
|
159
|
-
- bin/console
|
160
|
-
- bin/setup
|
161
153
|
- lib/snfoil/policy.rb
|
162
154
|
- lib/snfoil/policy/version.rb
|
163
155
|
- snfoil-policy.gemspec
|
@@ -168,7 +160,8 @@ metadata:
|
|
168
160
|
homepage_uri: https://github.com/limited-effort/snfoil-policy
|
169
161
|
source_code_uri: https://github.com/limited-effort/snfoil-policy
|
170
162
|
changelog_uri: https://github.com/limited-effort/snfoil-policy/blob/main/CHANGELOG.md
|
171
|
-
|
163
|
+
rubygems_mfa_required: 'true'
|
164
|
+
post_install_message:
|
172
165
|
rdoc_options: []
|
173
166
|
require_paths:
|
174
167
|
- lib
|
@@ -176,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
169
|
requirements:
|
177
170
|
- - ">="
|
178
171
|
- !ruby/object:Gem::Version
|
179
|
-
version: 2.
|
172
|
+
version: '2.7'
|
180
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
174
|
requirements:
|
182
175
|
- - ">="
|
@@ -184,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
177
|
version: '0'
|
185
178
|
requirements: []
|
186
179
|
rubygems_version: 3.1.6
|
187
|
-
signing_key:
|
180
|
+
signing_key:
|
188
181
|
specification_version: 4
|
189
182
|
summary: Pundit Style Permissions Builder
|
190
183
|
test_files: []
|
data/.fasterer.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
speedups:
|
2
|
-
rescue_vs_respond_to: true
|
3
|
-
module_eval: true
|
4
|
-
shuffle_first_vs_sample: true
|
5
|
-
for_loop_vs_each: true
|
6
|
-
each_with_index_vs_while: false
|
7
|
-
map_flatten_vs_flat_map: true
|
8
|
-
reverse_each_vs_reverse_each: true
|
9
|
-
select_first_vs_detect: true
|
10
|
-
sort_vs_sort_by: true
|
11
|
-
fetch_with_argument_vs_block: true
|
12
|
-
keys_each_vs_each_key: true
|
13
|
-
hash_merge_bang_vs_hash_brackets: true
|
14
|
-
block_vs_symbol_to_proc: true
|
15
|
-
proc_call_vs_yield: true
|
16
|
-
gsub_vs_tr: true
|
17
|
-
select_last_vs_reverse_detect: true
|
18
|
-
getter_vs_attr_reader: true
|
19
|
-
setter_vs_attr_writer: true
|
20
|
-
|
21
|
-
exclude_paths:
|
22
|
-
- 'vendor/**/*.rb'
|
data/.github/workflows/main.yml
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
name: build
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [ main ]
|
5
|
-
pull_request:
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
test:
|
9
|
-
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
strategy:
|
13
|
-
matrix:
|
14
|
-
ruby-version: [2.7, 2.6, 2.5, '3.0']
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
19
|
-
uses: ruby/setup-ruby@v1.81.0
|
20
|
-
with:
|
21
|
-
ruby-version: ${{ matrix.ruby-version }}
|
22
|
-
bundler-cache: true
|
23
|
-
- name: Install dependencies
|
24
|
-
run: bundle install
|
25
|
-
- name: Run tests
|
26
|
-
run: bundle exec rspec
|
27
|
-
lint:
|
28
|
-
|
29
|
-
runs-on: ubuntu-latest
|
30
|
-
|
31
|
-
strategy:
|
32
|
-
matrix:
|
33
|
-
ruby-version: [2.7, 2.6, 2.5, '3.0']
|
34
|
-
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v2
|
37
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
38
|
-
uses: ruby/setup-ruby@v1.81.0
|
39
|
-
with:
|
40
|
-
ruby-version: ${{ matrix.ruby-version }}
|
41
|
-
bundler-cache: true
|
42
|
-
- name: Install dependencies
|
43
|
-
run: bundle install
|
44
|
-
- name: Run rubocop
|
45
|
-
run: bundle exec rubocop
|
46
|
-
- name: Run fasterer
|
47
|
-
run: bundle exec fasterer
|
48
|
-
- name: Run bundle audit
|
49
|
-
run: bundle exec bundle audit check --update
|
50
|
-
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-performance
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
NewCops: enable
|
7
|
-
SuggestExtensions: false
|
8
|
-
TargetRubyVersion: 2.5.0
|
9
|
-
|
10
|
-
# ================ LAYOUT ==============
|
11
|
-
Layout/LineLength:
|
12
|
-
Max: 150
|
13
|
-
|
14
|
-
# ================ LINT ================
|
15
|
-
Lint/AmbiguousBlockAssociation:
|
16
|
-
Exclude:
|
17
|
-
- spec/**/*_spec.rb
|
18
|
-
|
19
|
-
Lint/EmptyClass:
|
20
|
-
Exclude:
|
21
|
-
- spec/**/*_spec.rb
|
22
|
-
|
23
|
-
# ================ Metics ================
|
24
|
-
Metrics/BlockLength:
|
25
|
-
Exclude:
|
26
|
-
- spec/**/*_spec.rb
|
27
|
-
- snfoil-policy.gemspec
|
28
|
-
|
29
|
-
# ================ RSPEC ================
|
30
|
-
RSpec/FilePath:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
RSpec/MultipleExpectations:
|
34
|
-
Max: 5
|
35
|
-
|
36
|
-
RSpec/MultipleMemoizedHelpers:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
RSpec/NestedGroups:
|
40
|
-
Max: 5
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'snfoil/policy'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|