snfoil-context 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/snfoil/context/structure.rb +25 -23
- data/lib/snfoil/context/version.rb +1 -1
- data/lib/snfoil/context.rb +8 -8
- data/snfoil-context.gemspec +7 -7
- metadata +12 -19
- data/.fasterer.yml +0 -22
- data/.github/workflows/main.yml +0 -49
- 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: 865d3b34caed7991d357df2f115087b8c99b84c5e1a0050e691e9bf751149647
|
4
|
+
data.tar.gz: 28c589b8f0fd88f7828c91678de7c58051d1489107ff2c96ad3c94e4c1cfba02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7115fd9f9bbb8de53f6008fccaa4018f41fc2ce2c13066a7a00e08192d1054589d3c0a471e3be837ac9d26d62cd32088ccc5e39700d7842d954d98d24fb9b9cc
|
7
|
+
data.tar.gz: a7d880bbff1e6cb9fa1fcb39a9f865ebb171d940ec3804ae0ae05a92c97fce9007b480876dcb1b05fab188635f88d28e3e65ea2f37f39d1b8819a3f4e144aacc
|
@@ -50,39 +50,41 @@ module SnFoil
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
included do
|
54
|
+
attr_reader :entity
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
def initialize(**keywords)
|
57
|
+
@entity = keywords[:entity]
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def authorize(name, **options)
|
61
|
+
configured_call = self.class.snfoil_authorizations&.fetch(name.to_sym, nil)
|
62
|
+
configured_call ||= self.class.snfoil_authorizations&.fetch(nil, nil)
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
if configured_call
|
65
|
+
run_hook(configured_call, **options)
|
66
|
+
else
|
67
|
+
SnFoil.logger.info "No configuration for #{name} in #{self.class.name}. Authorize not called" if SnFoil.respond_to?(:logger)
|
68
|
+
true
|
69
|
+
end
|
68
70
|
end
|
69
|
-
end
|
70
71
|
|
71
|
-
|
72
|
+
private
|
72
73
|
|
73
|
-
|
74
|
-
|
74
|
+
def run_hook(hook, **options)
|
75
|
+
return options unless hook && hook_valid?(hook, **options)
|
75
76
|
|
76
|
-
|
77
|
+
return send(hook[:method], **options) if hook[:method]
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
instance_exec(**options, &hook[:block])
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
def hook_valid?(hook, **options)
|
83
|
+
return false if !hook[:if].nil? && hook[:if].call(**options) == false
|
84
|
+
return false if !hook[:unless].nil? && hook[:unless].call(**options) == true
|
84
85
|
|
85
|
-
|
86
|
+
true
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
data/lib/snfoil/context.rb
CHANGED
@@ -64,11 +64,11 @@ module SnFoil
|
|
64
64
|
# making them more complex. If anyone has a better way please let me know
|
65
65
|
class_methods do # rubocop:disable Metrics/BlockLength
|
66
66
|
def define_workflow(name)
|
67
|
-
interval
|
68
|
-
interval
|
69
|
-
interval
|
70
|
-
interval
|
71
|
-
interval
|
67
|
+
interval "setup_#{name}"
|
68
|
+
interval "before_#{name}"
|
69
|
+
interval "after_#{name}_success"
|
70
|
+
interval "after_#{name}_failure"
|
71
|
+
interval "after_#{name}"
|
72
72
|
end
|
73
73
|
|
74
74
|
def define_action_primary(name, method, block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -94,10 +94,10 @@ module SnFoil
|
|
94
94
|
singleton_var = "snfoil_#{method_name}_hooks"
|
95
95
|
instance_variable_set("@#{singleton_var}", [])
|
96
96
|
define_singleton_method(singleton_var) { instance_variable_get("@#{singleton_var}") }
|
97
|
-
define_singleton_method(method_name) do |
|
98
|
-
raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if
|
97
|
+
define_singleton_method(method_name) do |with: nil, **options, &block|
|
98
|
+
raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if with.nil? && block.nil?
|
99
99
|
|
100
|
-
instance_variable_get("@#{singleton_var}") << { method:
|
100
|
+
instance_variable_get("@#{singleton_var}") << { method: with,
|
101
101
|
block: block,
|
102
102
|
if: options[:if],
|
103
103
|
unless: options[:unless] }
|
data/snfoil-context.gemspec
CHANGED
@@ -8,21 +8,21 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Matthew Howes', 'Cliff Campbell']
|
9
9
|
spec.email = ['howeszy@gmail.com', 'cliffcampbell@hey.com']
|
10
10
|
|
11
|
-
spec.summary = 'Setup
|
11
|
+
spec.summary = 'Setup Simple Pipelined Workflows'
|
12
12
|
spec.description = 'An easy way to make extensible workflows and actions'
|
13
13
|
spec.homepage = 'https://github.com/limited-effort/snfoil-context'
|
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-context/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-context
|
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/context.rb
|
162
154
|
- lib/snfoil/context/argument_error.rb
|
163
155
|
- lib/snfoil/context/error.rb
|
@@ -171,7 +163,8 @@ metadata:
|
|
171
163
|
homepage_uri: https://github.com/limited-effort/snfoil-context
|
172
164
|
source_code_uri: https://github.com/limited-effort/snfoil-context
|
173
165
|
changelog_uri: https://github.com/limited-effort/snfoil-context/blob/main/CHANGELOG.md
|
174
|
-
|
166
|
+
rubygems_mfa_required: 'true'
|
167
|
+
post_install_message:
|
175
168
|
rdoc_options: []
|
176
169
|
require_paths:
|
177
170
|
- lib
|
@@ -179,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
172
|
requirements:
|
180
173
|
- - ">="
|
181
174
|
- !ruby/object:Gem::Version
|
182
|
-
version: 2.
|
175
|
+
version: '2.7'
|
183
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
177
|
requirements:
|
185
178
|
- - ">="
|
@@ -187,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
180
|
version: '0'
|
188
181
|
requirements: []
|
189
182
|
rubygems_version: 3.1.6
|
190
|
-
signing_key:
|
183
|
+
signing_key:
|
191
184
|
specification_version: 4
|
192
|
-
summary: Setup
|
185
|
+
summary: Setup Simple Pipelined Workflows
|
193
186
|
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,49 +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
|
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-context.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__)
|