snfoil-context 1.2.0 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c8dbabb2362b9f056aa022c30b3b272a66f77c9316e65693f3b1a62312b7f70
4
- data.tar.gz: 6bbb3416847d30ffc991751760076cbe709b127a203c2172bbe13d600ae55c00
3
+ metadata.gz: 7bfb206310a325e0f3d5ed9ba2debba0daa1070ac209c811d7d8826a2ff60165
4
+ data.tar.gz: 4bbc2c868407ed28f80ddc2ee6ec573e6e49f3310fd08cc30b8fe8ee0ebc77fa
5
5
  SHA512:
6
- metadata.gz: aa99ee8c5289136c65ab060112b33e664d92fc866d43cc131f6c783159c2c81e9213d25789955360e41758835ee4b3068b17546131598474a63513d35a8ffc66
7
- data.tar.gz: 779f732fe717014a137e8450465e0cde4be9bd4e13080674af794aefcb2f5a2eeb162f4e0f66568d24199b2a0b89d5c975b37a0643d7b67ac25e86bfc18818a8
6
+ metadata.gz: e3a5d75e17919fb047578af09195b5969d344fb839744cf8812c7bb69c45ba59980b0abedd5752787383be8ec37f31102a1884246aa5ea839033d9cb9819b9b3
7
+ data.tar.gz: 9df3742c8f316f48bf62be83162db71d26c45b70b58d32f02f8211ed5414be40e72bc62cf91a87f1d27b4940c8485c40146b20a042f568504ec773b7798444d3
data/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ ARG RUBY_VERSION=3.4.3
2
+
3
+ FROM ruby:${RUBY_VERSION}-slim
4
+
5
+ RUN apt update && \
6
+ apt install -y --no-install-recommends \
7
+ build-essential \
8
+ libyaml-dev \
9
+ git \
10
+ curl
11
+
12
+ WORKDIR /workspace
13
+
14
+ COPY . .
15
+
16
+ RUN bundle install
17
+
18
+ CMD ["bundle", "exec", "rspec"]
data/Gemfile CHANGED
@@ -6,12 +6,12 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  group :development, :test do
9
- gem 'bundle-audit', '~> 0.1.0'
10
- gem 'fasterer', '~> 0.10.0'
11
- gem 'pry-byebug', '~> 3.9', platform: :mri
9
+ gem 'bundler-audit', '~> 0.9.0'
10
+ gem 'debug', '~> 1.10'
11
+ gem 'fasterer', '~> 0.11.0'
12
12
  gem 'rake', '~> 13.0'
13
13
  gem 'rspec', '~> 3.10'
14
- gem 'rubocop', '1.33'
15
- gem 'rubocop-performance', '1.14.3'
16
- gem 'rubocop-rspec', '2.12.1'
14
+ gem 'rubocop', '~> 1.75'
15
+ gem 'rubocop-performance', '~> 1.25'
16
+ gem 'rubocop-rspec', '~> 3.6'
17
17
  end
data/README.md CHANGED
@@ -309,6 +309,14 @@ end
309
309
  #### Why before and after?
310
310
  Simply to make sure the entity is allowed access to the primary target and is allowed to make the requested alterations/interactions.
311
311
 
312
+ #### Did Authorize Run?
313
+ If there is a valid policy to call SnFoil-Context will update the `:authorize` key in the options.
314
+
315
+ Values are:
316
+ - `false` - The authorize method never ran
317
+ - `:setup` - The authorize method ran after the setup interval (the first run)
318
+ - `:before` - The authorize method ran after the before interval (the second run)
319
+
312
320
  ### Intervals
313
321
  There might be a situation where you don't need a before, after, success or failure, and just need a single name pipeline you can hook into. `interval` allows you to create a single action-like segment.
314
322
 
@@ -0,0 +1,11 @@
1
+ services:
2
+ workspace:
3
+ build:
4
+ context: .
5
+ dockerfile: Dockerfile
6
+ command: sleep infinity
7
+ volumes:
8
+ - .:/workspace
9
+ env_file:
10
+ - path: .env
11
+ required: false
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require_relative './error'
17
+ require_relative 'error'
18
18
  require 'active_support/concern'
19
19
 
20
20
  module SnFoil
@@ -16,6 +16,6 @@
16
16
 
17
17
  module SnFoil
18
18
  module Context
19
- VERSION = '1.2.0'
19
+ VERSION = '1.2.2'
20
20
  end
21
21
  end
@@ -14,9 +14,9 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require_relative './context/error'
18
- require_relative './context/argument_error'
19
- require_relative './context/structure'
17
+ require_relative 'context/error'
18
+ require_relative 'context/argument_error'
19
+ require_relative 'context/structure'
20
20
 
21
21
  require 'active_support/concern'
22
22
 
@@ -60,7 +60,7 @@ module SnFoil
60
60
 
61
61
  private
62
62
 
63
- # rubocop:disable reason: These are builder/mapping methods that are just too complex to simplify without
63
+ # rubocop disable reason: These are builder/mapping methods that are just too complex to simplify without
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)
@@ -74,20 +74,14 @@ module SnFoil
74
74
  def define_action_primary(name, method, block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
75
75
  define_method(name) do |*_args, **options| # rubocop:disable Metrics/MethodLength
76
76
  options[:action] ||= name.to_sym
77
- options[:authorized] = false
78
77
 
79
78
  options = run_interval(format('setup_%s', name), **options)
80
79
 
81
- if respond_to?(:authorize)
82
- authorize(name, **options)
83
- options[:authorized] = :setup
84
- end
80
+ authorize(name, **options) if respond_to?(:authorize) && !options[:skip_first_authorize]
85
81
 
86
82
  options = run_interval(format('before_%s', name), **options)
87
- if respond_to?(:authorize)
88
- authorize(name, **options)
89
- options[:authorized] = :before
90
- end
83
+
84
+ authorize(name, **options) if respond_to?(:authorize) && !options[:skip_last_authorize]
91
85
 
92
86
  options = if run_action_primary(method, block, **options)
93
87
  run_interval(format('after_%s_success', name), **options)
@@ -103,7 +97,7 @@ module SnFoil
103
97
  instance_variable_set("@#{singleton_var}", [])
104
98
  define_singleton_method(singleton_var) { instance_variable_get("@#{singleton_var}") }
105
99
  define_singleton_method(method_name) do |with: nil, **options, &block|
106
- raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if with.nil? && block.nil?
100
+ raise SnFoil::Context::ArgumentError, "##{method_name} requires either a method name or a block" if with.nil? && block.nil?
107
101
 
108
102
  instance_variable_get("@#{singleton_var}") << { method: with,
109
103
  block: block,
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
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.6'
15
+ spec.required_ruby_version = '>= 3.0'
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = spec.homepage
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snfoil-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Howes
8
8
  - Cliff Campbell
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -35,9 +34,11 @@ extra_rdoc_files: []
35
34
  files:
36
35
  - CHANGELOG.md
37
36
  - CODE_OF_CONDUCT.md
37
+ - Dockerfile
38
38
  - Gemfile
39
39
  - LICENSE.txt
40
40
  - README.md
41
+ - docker-compose.yaml
41
42
  - lib/snfoil/context.rb
42
43
  - lib/snfoil/context/argument_error.rb
43
44
  - lib/snfoil/context/error.rb
@@ -52,7 +53,6 @@ metadata:
52
53
  source_code_uri: https://github.com/limited-effort/snfoil-context
53
54
  changelog_uri: https://github.com/limited-effort/snfoil-context/blob/main/CHANGELOG.md
54
55
  rubygems_mfa_required: 'true'
55
- post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
@@ -60,15 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '2.6'
63
+ version: '3.0'
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.3.7
71
- signing_key:
70
+ rubygems_version: 3.6.7
72
71
  specification_version: 4
73
72
  summary: Setup Simple Pipelined Workflows
74
73
  test_files: []