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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9996ed485265b54e92858f7471b6ed2ccfc3970b6ab7bed338f0b3ab729d240
4
- data.tar.gz: 2427755a9b61cf1fad8ddc48eaa6e5c1e7da651b6c6b8f760f6594e1a973c471
3
+ metadata.gz: 865d3b34caed7991d357df2f115087b8c99b84c5e1a0050e691e9bf751149647
4
+ data.tar.gz: 28c589b8f0fd88f7828c91678de7c58051d1489107ff2c96ad3c94e4c1cfba02
5
5
  SHA512:
6
- metadata.gz: d8e89dc09f5d1a1ca531487b04e9392c5323330c232d9f3a72946c4130ead35425451a2bec1d7a522702c414cdd7cb08ea85447f60d89a72a948fda27f17d667
7
- data.tar.gz: a1f773ecb81a5a4ee2ffce81b3bf350c49e18078ba465f35e4ed824b01587dd5a9d5fc4897131a1c4b93fe9675655c086d489c9d99e0c05615af139f4644d13f
6
+ metadata.gz: 7115fd9f9bbb8de53f6008fccaa4018f41fc2ce2c13066a7a00e08192d1054589d3c0a471e3be837ac9d26d62cd32088ccc5e39700d7842d954d98d24fb9b9cc
7
+ data.tar.gz: a7d880bbff1e6cb9fa1fcb39a9f865ebb171d940ec3804ae0ae05a92c97fce9007b480876dcb1b05fab188635f88d28e3e65ea2f37f39d1b8819a3f4e144aacc
@@ -50,39 +50,41 @@ module SnFoil
50
50
  end
51
51
  end
52
52
 
53
- attr_reader :entity
53
+ included do
54
+ attr_reader :entity
54
55
 
55
- def initialize(entity = nil)
56
- @entity = entity
57
- end
56
+ def initialize(**keywords)
57
+ @entity = keywords[:entity]
58
+ end
58
59
 
59
- def authorize(name, **options)
60
- configured_call = self.class.snfoil_authorizations&.fetch(name.to_sym, nil)
61
- configured_call ||= self.class.snfoil_authorizations&.fetch(nil, nil)
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
- if configured_call
64
- run_hook(configured_call, **options)
65
- else
66
- SnFoil.logger.info "No configuration for #{name} in #{self.class.name}. Authorize not called" if SnFoil.respond_to?(:logger)
67
- true
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
- private
72
+ private
72
73
 
73
- def run_hook(hook, **options)
74
- return options unless hook && hook_valid?(hook, **options)
74
+ def run_hook(hook, **options)
75
+ return options unless hook && hook_valid?(hook, **options)
75
76
 
76
- return send(hook[:method], **options) if hook[:method]
77
+ return send(hook[:method], **options) if hook[:method]
77
78
 
78
- instance_exec(**options, &hook[:block])
79
- end
79
+ instance_exec(**options, &hook[:block])
80
+ end
80
81
 
81
- def hook_valid?(hook, **options)
82
- return false if !hook[:if].nil? && hook[:if].call(**options) == false
83
- return false if !hook[:unless].nil? && hook[:unless].call(**options) == true
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
- true
86
+ true
87
+ end
86
88
  end
87
89
  end
88
90
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module SnFoil
18
18
  module Context
19
- VERSION = '0.0.4'
19
+ VERSION = '1.0.0'
20
20
  end
21
21
  end
@@ -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 format('setup_%s', name)
68
- interval format('before_%s', name)
69
- interval format('after_%s_success', name)
70
- interval format('after_%s_failure', name)
71
- interval format('after_%s', name)
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 |method = nil, **options, &block|
98
- raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if method.nil? && block.nil?
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: method,
100
+ instance_variable_get("@#{singleton_var}") << { method: with,
101
101
  block: block,
102
102
  if: options[:if],
103
103
  unless: options[:unless] }
@@ -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 simple pipelined workflows'
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.5.0'
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
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
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.9.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.21'
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
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: 2021-10-28 00:00:00.000000000 Z
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.9.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.9.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.21'
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.21'
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
- post_install_message:
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.5.0
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 simple pipelined workflows
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'
@@ -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
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- # GEMFILE
14
- Gemfile.lock
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
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
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require 'rubocop/rake_task'
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
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__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here