overseer-testing-control-rails 0.1.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.
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'overseer/testing_control/discovery'
5
+ require 'rails'
6
+
7
+ require_relative 'rails/version'
8
+ require_relative 'rails/protocol_v3'
9
+ require_relative 'rails/request_context'
10
+ require_relative 'rails/correlation_middleware'
11
+ require_relative 'rails/stores'
12
+ require_relative 'rails/configuration'
13
+ require_relative 'rails/engine'
14
+
15
+ module Overseer
16
+ module TestingControl
17
+ module Rails
18
+ module_function
19
+
20
+ def configuration
21
+ @configuration ||= Configuration.new
22
+ end
23
+
24
+ def configure
25
+ unless block_given?
26
+ raise ConfigurationError,
27
+ 'Overseer Rails testing-control adapter configuration requires a block'
28
+ end
29
+
30
+ yield configuration
31
+ end
32
+
33
+ def active?
34
+ ::Rails.env.test? && ENV['OVERSEER_TESTING_CONTROL_ENABLED'] == 'true' &&
35
+ configuration.runtime_identity_valid?
36
+ rescue StandardError
37
+ false
38
+ end
39
+
40
+ def capture_effect(**attributes)
41
+ raise CaptureError, 'Testing control is inactive' unless active?
42
+
43
+ configuration.finalize!
44
+ context = RequestContext.current
45
+ unless context&.run_id && context.correlation_id
46
+ raise CaptureError, 'A correlated run context is required to capture a fake effect'
47
+ end
48
+
49
+ configuration.sink_store.capture(context:, **attributes)
50
+ end
51
+
52
+ def reset_configuration!
53
+ @configuration = Configuration.new
54
+ end
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: overseer-testing-control-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maurizio De Magnis
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: overseer-testing-protocol
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '='
17
+ - !ruby/object:Gem::Version
18
+ version: 0.1.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - '='
24
+ - !ruby/object:Gem::Version
25
+ version: 0.1.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: rails
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '7.2'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '9'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '7.2'
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '9'
46
+ description: Provides thin, fail-closed Rails and Rack mechanics for isolated testing-control
47
+ v3 runtimes.
48
+ email:
49
+ - root@olisti.co
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - app/controllers/overseer/testing_control/rails/application_controller.rb
57
+ - app/controllers/overseer/testing_control/rails/capabilities_controller.rb
58
+ - app/controllers/overseer/testing_control/rails/probes_controller.rb
59
+ - app/controllers/overseer/testing_control/rails/resets_controller.rb
60
+ - app/controllers/overseer/testing_control/rails/sinks_controller.rb
61
+ - app/controllers/overseer/testing_control/rails/states_controller.rb
62
+ - config/routes.rb
63
+ - lib/overseer/testing_control/rails.rb
64
+ - lib/overseer/testing_control/rails/configuration.rb
65
+ - lib/overseer/testing_control/rails/correlation_middleware.rb
66
+ - lib/overseer/testing_control/rails/engine.rb
67
+ - lib/overseer/testing_control/rails/protocol_v3.rb
68
+ - lib/overseer/testing_control/rails/request_context.rb
69
+ - lib/overseer/testing_control/rails/stores.rb
70
+ - lib/overseer/testing_control/rails/version.rb
71
+ homepage: https://source.olisti.co/overseer/helper-rails
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ source_code_uri: https://source.olisti.co/overseer/helper-rails
76
+ rubygems_mfa_required: 'true'
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 3.2.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 4.0.16
92
+ specification_version: 4
93
+ summary: Optional Rails adapter for Overseer testing-control protocol v3
94
+ test_files: []