light-service-ext 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -3
- data/lib/light-service-ext/application_context.rb +12 -12
- data/lib/light-service-ext/configuration.rb +2 -2
- data/lib/light-service-ext/version.rb +1 -1
- data/light-service-ext.gemspec +2 -2
- data/spec/light-service-ext/application_context_spec.rb +6 -6
- data/spec/light-service-ext/application_contract_spec.rb +3 -3
- data/spec/light-service-ext/configuration_spec.rb +2 -2
- data/spec/light-service-ext/record_actions_spec.rb +4 -4
- data/spec/light_service_ext_spec.rb +2 -2
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6820ebd6438ad162b257eb86a7963c0680cc9fc08305481eb7a73ce851006d4
|
4
|
+
data.tar.gz: 6c282a19d473b54b3d38effff3b3d1ba4f6a6dea1e793a45608cf8eccabb63ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc3d14223917e6e1be10980a39798dcbbc35285f4149c931a37d76cfa8f52341ebd0befa424610822ae81cd4d06e26366528458af32989df71b0c0308c67abc8
|
7
|
+
data.tar.gz: 1dfa2a6a4182a0b828ed454f1533ca348ca8ba4ffd75e8287044cad028582a8bb12d23418c69a452ef7599cedf2cf1e43349226be0e3e41085b2b62e0c89ac45
|
data/.github/workflows/main.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in light-service-ext.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
9
|
-
gem
|
8
|
+
gem 'rubocop', '~> 1.56', '>= 1.56.1'
|
9
|
+
gem 'rubocop-performance', '~> 1.19'
|
10
10
|
gem "rubocop-rake", ">= 0.6.0"
|
11
|
-
gem
|
11
|
+
gem 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
|
@@ -29,11 +29,11 @@ module LightServiceExt
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def add_params(**params)
|
32
|
-
add_attrs_to_ctx(:params, params)
|
32
|
+
add_attrs_to_ctx(:params, **params)
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_errors(**errors)
|
36
|
-
add_attrs_to_ctx(:errors, errors)
|
36
|
+
add_attrs_to_ctx(:errors, **errors)
|
37
37
|
end
|
38
38
|
|
39
39
|
def add_errors!(**errors)
|
@@ -77,16 +77,6 @@ module LightServiceExt
|
|
77
77
|
!!self[:allow_raise_on_failure]
|
78
78
|
end
|
79
79
|
|
80
|
-
def method_missing(method_name, *arguments, &block)
|
81
|
-
return self[method_name] if key?(method_name)
|
82
|
-
|
83
|
-
super
|
84
|
-
end
|
85
|
-
|
86
|
-
def respond_to_missing?(method_name, include_private = false)
|
87
|
-
key?(method_name) || super
|
88
|
-
end
|
89
|
-
|
90
80
|
private
|
91
81
|
|
92
82
|
def add_value_to_ctx(key, value)
|
@@ -107,5 +97,15 @@ module LightServiceExt
|
|
107
97
|
self[key] = self[key].concat(values).compact
|
108
98
|
nil
|
109
99
|
end
|
100
|
+
|
101
|
+
def method_missing(method_name, *arguments, &block)
|
102
|
+
return self[method_name] if key?(method_name)
|
103
|
+
|
104
|
+
super
|
105
|
+
end
|
106
|
+
|
107
|
+
def respond_to_missing?(method_name, include_private = false)
|
108
|
+
key?(method_name) || super
|
109
|
+
end
|
110
110
|
end
|
111
111
|
end
|
@@ -4,8 +4,8 @@ module LightServiceExt
|
|
4
4
|
class Configuration
|
5
5
|
include ActiveSupport::Configurable
|
6
6
|
|
7
|
-
config_accessor(:allow_raise_on_failure
|
8
|
-
config_accessor(:non_fatal_error_classes
|
7
|
+
config_accessor(:allow_raise_on_failure, default: true)
|
8
|
+
config_accessor(:non_fatal_error_classes, default: [])
|
9
9
|
config_accessor(:default_non_fatal_error_classes) { ['Rails::ActiveRecordError'.safe_constantize] }
|
10
10
|
config_accessor(:logger) { (defined? Rails.logger).nil? ? Logger.new($stdout) : Rails.logger }
|
11
11
|
|
data/light-service-ext.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.name = "light-service-ext"
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
gem.version = LightServiceExt::VERSION
|
19
|
-
gem.required_ruby_version = ">=
|
19
|
+
gem.required_ruby_version = ">= 3"
|
20
20
|
|
21
21
|
gem.metadata["homepage_uri"] = gem.homepage
|
22
22
|
gem.metadata["source_code_uri"] = gem.homepage
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_runtime_dependency 'dry-struct', '~> 1.6'
|
27
27
|
gem.add_runtime_dependency 'dry-validation', '~> 1.10'
|
28
28
|
gem.add_runtime_dependency 'json', '~> 2.6', '>= 2.6.3'
|
29
|
-
gem.add_runtime_dependency 'activesupport', '>=
|
29
|
+
gem.add_runtime_dependency 'activesupport', '~> 6.0', '>= 6.0.6'
|
30
30
|
|
31
31
|
gem.add_development_dependency("rake", "~> 13.0.6")
|
32
32
|
gem.add_development_dependency("rspec", "~> 3.12.0")
|
@@ -11,7 +11,7 @@ module LightServiceExt
|
|
11
11
|
it 'adds successful action name to context' do
|
12
12
|
ctx.add_to_successful_actions(value)
|
13
13
|
|
14
|
-
expect(ctx.successful_actions).to
|
14
|
+
expect(ctx.successful_actions).to contain_exactly(value)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'preserves other successful action name' do
|
@@ -19,7 +19,7 @@ module LightServiceExt
|
|
19
19
|
|
20
20
|
ctx.add_to_successful_actions('other-value')
|
21
21
|
|
22
|
-
expect(ctx.successful_actions).to
|
22
|
+
expect(ctx.successful_actions).to contain_exactly(value, 'other-value')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,7 +27,7 @@ module LightServiceExt
|
|
27
27
|
it 'adds last api response to context' do
|
28
28
|
ctx.add_to_api_responses(value)
|
29
29
|
|
30
|
-
expect(ctx.api_responses).to
|
30
|
+
expect(ctx.api_responses).to contain_exactly(value)
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'preserves other api responses' do
|
@@ -35,7 +35,7 @@ module LightServiceExt
|
|
35
35
|
|
36
36
|
ctx.add_to_api_responses('other-value')
|
37
37
|
|
38
|
-
expect(ctx.api_responses).to
|
38
|
+
expect(ctx.api_responses).to contain_exactly(value, 'other-value')
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -263,7 +263,7 @@ module LightServiceExt
|
|
263
263
|
end
|
264
264
|
|
265
265
|
it 'allows for overrides' do
|
266
|
-
expect(ctx_with_defaults[:successful_actions]).to
|
266
|
+
expect(ctx_with_defaults[:successful_actions]).to contain_exactly('some-action-class-name')
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
@@ -273,7 +273,7 @@ module LightServiceExt
|
|
273
273
|
end
|
274
274
|
|
275
275
|
it 'allows for overrides' do
|
276
|
-
expect(ctx_with_defaults[:api_responses]).to
|
276
|
+
expect(ctx_with_defaults[:api_responses]).to contain_exactly('some-api-response')
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
@@ -12,7 +12,7 @@ module LightServiceExt
|
|
12
12
|
|
13
13
|
describe '.keys' do
|
14
14
|
it 'returns schema rule keys' do
|
15
|
-
expect(contract_class.keys).to
|
15
|
+
expect(contract_class.keys).to contain_exactly(:email)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -38,10 +38,10 @@ module LightServiceExt
|
|
38
38
|
expect(result).to be_failure
|
39
39
|
|
40
40
|
errors = result.errors.to_h
|
41
|
-
expect(errors.keys).to
|
41
|
+
expect(errors.keys).to contain_exactly(:email)
|
42
42
|
|
43
43
|
error_messages = errors[:email]
|
44
|
-
expect(error_messages).to
|
44
|
+
expect(error_messages).to contain_exactly("must be a valid email")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -13,7 +13,7 @@ module LightServiceExt
|
|
13
13
|
|
14
14
|
describe '#non_fatal_error_classes' do
|
15
15
|
it 'returns set fatal error classes' do
|
16
|
-
expect(config.non_fatal_error_classes).to
|
16
|
+
expect(config.non_fatal_error_classes).to contain_exactly(error_class)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -27,7 +27,7 @@ module LightServiceExt
|
|
27
27
|
|
28
28
|
describe '#default_non_fatal_error_classes' do
|
29
29
|
it 'returns set non fatal error classes' do
|
30
|
-
expect(config.default_non_fatal_error_classes).to
|
30
|
+
expect(config.default_non_fatal_error_classes).to contain_exactly(default_error_class)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -21,8 +21,8 @@ module LightServiceExt
|
|
21
21
|
|
22
22
|
it 'returns expected context' do
|
23
23
|
expect(called_ctx.success?).to be_truthy
|
24
|
-
expect(called_ctx.successful_actions).to
|
25
|
-
expect(called_ctx.api_responses).to
|
24
|
+
expect(called_ctx.successful_actions).to be_empty
|
25
|
+
expect(called_ctx.api_responses).to be_empty
|
26
26
|
expect(called_ctx.status).to eql(Status::INCOMPLETE)
|
27
27
|
expect(called_ctx[:last_failed_context]).to be_nil
|
28
28
|
end
|
@@ -33,8 +33,8 @@ module LightServiceExt
|
|
33
33
|
|
34
34
|
it 'adds api_response as last api response' do
|
35
35
|
expect(called_ctx.success?).to be_truthy
|
36
|
-
expect(called_ctx.successful_actions).to
|
37
|
-
expect(called_ctx.api_responses).to
|
36
|
+
expect(called_ctx.successful_actions).to contain_exactly(action_name)
|
37
|
+
expect(called_ctx.api_responses).to contain_exactly(current_api_response)
|
38
38
|
expect(called_ctx.status).to eql(Status::INCOMPLETE)
|
39
39
|
expect(called_ctx[:last_failed_context]).to be_nil
|
40
40
|
end
|
@@ -26,7 +26,7 @@ RSpec.describe LightServiceExt do
|
|
26
26
|
|
27
27
|
describe '#non_fatal_error_classes' do
|
28
28
|
it 'returns set fatal error classes' do
|
29
|
-
expect(config.non_fatal_error_classes).to
|
29
|
+
expect(config.non_fatal_error_classes).to contain_exactly(error_class)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -40,7 +40,7 @@ RSpec.describe LightServiceExt do
|
|
40
40
|
|
41
41
|
describe '#default_non_fatal_error_classes' do
|
42
42
|
it 'returns set non fatal error classes' do
|
43
|
-
expect(config.default_non_fatal_error_classes).to
|
43
|
+
expect(config.default_non_fatal_error_classes).to contain_exactly(default_error_class)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light-service-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Desmond O'Leary
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: light-service
|
@@ -82,16 +82,22 @@ dependencies:
|
|
82
82
|
name: activesupport
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '6.0'
|
85
88
|
- - ">="
|
86
89
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
90
|
+
version: 6.0.6
|
88
91
|
type: :runtime
|
89
92
|
prerelease: false
|
90
93
|
version_requirements: !ruby/object:Gem::Requirement
|
91
94
|
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '6.0'
|
92
98
|
- - ">="
|
93
99
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
100
|
+
version: 6.0.6
|
95
101
|
- !ruby/object:Gem::Dependency
|
96
102
|
name: rake
|
97
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,7 +219,7 @@ metadata:
|
|
213
219
|
homepage_uri: https://github.com/omnitech-solutions/light-service-ext
|
214
220
|
source_code_uri: https://github.com/omnitech-solutions/light-service-ext
|
215
221
|
changelog_uri: https://github.com/omnitech-solutions/light-service-ext/CHANGELOG.md
|
216
|
-
post_install_message:
|
222
|
+
post_install_message:
|
217
223
|
rdoc_options: []
|
218
224
|
require_paths:
|
219
225
|
- lib
|
@@ -221,15 +227,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
227
|
requirements:
|
222
228
|
- - ">="
|
223
229
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
230
|
+
version: '3'
|
225
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
232
|
requirements:
|
227
233
|
- - ">="
|
228
234
|
- !ruby/object:Gem::Version
|
229
235
|
version: '0'
|
230
236
|
requirements: []
|
231
|
-
rubygems_version: 3.
|
232
|
-
signing_key:
|
237
|
+
rubygems_version: 3.2.33
|
238
|
+
signing_key:
|
233
239
|
specification_version: 4
|
234
240
|
summary: Extends light-service with opinionated functionality
|
235
241
|
test_files:
|