luna_park 0.11.3 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -3
- data/Gemfile.lock +1 -1
- data/lib/luna_park/extensions/has_errors.rb +39 -4
- data/lib/luna_park/extensions/injector.rb +13 -0
- data/lib/luna_park/notifiers/log.rb +1 -1
- data/lib/luna_park/version.rb +1 -1
- data/lib/luna_park.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfa79de19dfdaeb2246f413fe75c89064077ba6b353af416984169a0c7122130
|
4
|
+
data.tar.gz: 3b44af84612de0a5eeaa04c960291647ad674336a8f33c50725410849a0bdbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73cf56e3506c153cf50b1b2f2912d04f2a329ab2b1c97f007e9a0c9bf69265d03cdc0d57e6a7d80f04e9c57aef386cf76c04c16497fc82ac35dc3b5297649bbe
|
7
|
+
data.tar.gz: 58b2fb6fe676786700d8d86cb1780c70bb9ae530d3a140d3ab25a88db5a8cbf00f342d43aaba9f0b3145e2570c1ac4dd1c3373b2b8bfd93e2e0f40f831e196a7
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,21 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.11.5] - 2022-09-27
|
8
|
+
Changed
|
9
|
+
- Added `.custom_error` method to `Extensions::HasError` to define errors with a custom superclass
|
10
|
+
- Added `#inject` method to `Extensions::Injector` - dependencies setter that allows you to create method chains
|
11
|
+
|
12
|
+
## [0.11.4] - 2022-07-11
|
13
|
+
Changed
|
14
|
+
- allow require Notifiers::Sentry when sentry-ruby version >= 4
|
15
|
+
|
7
16
|
## [0.11.3] - 2021-09-02
|
8
|
-
Added
|
17
|
+
Added
|
9
18
|
- new mapper `Mappers::Codirectionsl` with DSL
|
10
19
|
|
11
20
|
## [0.11.2] - 2021-09-01
|
12
|
-
Added
|
21
|
+
Added
|
13
22
|
- Github CI
|
14
23
|
|
15
24
|
## [0.11.1] - 2021-05-24
|
@@ -24,7 +33,7 @@ Changed
|
|
24
33
|
## [0.11.0] - 2021-03-18
|
25
34
|
Changed
|
26
35
|
- Rename Interactors to UseCases
|
27
|
-
- Rename Errors::Adaptive to Errors:Base
|
36
|
+
- Rename Errors::Adaptive to Errors:Base
|
28
37
|
- Rename Errors::Processing to Errors::Business
|
29
38
|
Added
|
30
39
|
- Add class Errors::System
|
data/Gemfile.lock
CHANGED
@@ -43,10 +43,10 @@ module LunaPark
|
|
43
43
|
# class Service
|
44
44
|
# include LunaPark::Extensions::HasErrors
|
45
45
|
#
|
46
|
-
# class
|
46
|
+
# class LogicError < LunaPark::Errors::Business; end
|
47
47
|
# end
|
48
48
|
#
|
49
|
-
# Service.new.error :
|
49
|
+
# Service.new.error :logic_error # => raise LogicError
|
50
50
|
#
|
51
51
|
# @param title [Symbol|String] - Title of error
|
52
52
|
# @param msg [String] - Message of error
|
@@ -89,12 +89,12 @@ module LunaPark
|
|
89
89
|
# class Service
|
90
90
|
# include LunaPark::Extensions::HasErrors
|
91
91
|
#
|
92
|
-
# system_error :tech_error, '
|
92
|
+
# system_error :tech_error, 'Error message'
|
93
93
|
# end
|
94
94
|
#
|
95
95
|
# tech_error = Service::TechError.new
|
96
96
|
# tech_error.is_a? LunaPark::Errors::System # => true
|
97
|
-
# tech_error.message # => '
|
97
|
+
# tech_error.message # => 'Error message'
|
98
98
|
def system_error(title, txt = nil, i18n_key: nil, notify: nil, &default_message_block)
|
99
99
|
error_class = Class.new(Errors::System)
|
100
100
|
error_class.message(txt, i18n_key: i18n_key, &default_message_block)
|
@@ -102,6 +102,41 @@ module LunaPark
|
|
102
102
|
const_set(error_class_name(title), error_class)
|
103
103
|
end
|
104
104
|
|
105
|
+
##
|
106
|
+
# Define error with a custom superclass.
|
107
|
+
# The superclass must be inherited from LunaPark::Errors::Base.
|
108
|
+
#
|
109
|
+
# @example
|
110
|
+
# class BaseError < LunaPark::Errors::Business
|
111
|
+
# alias description message
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# class Service
|
115
|
+
# include LunaPark::Extensions::HasErrors
|
116
|
+
#
|
117
|
+
# custom_error :custom_error, BaseError, 'Error message'
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# custom_error = Service::CustomError.new
|
121
|
+
# custom_error.is_a? BaseError # => true
|
122
|
+
# custom_error.description # => 'Error message'
|
123
|
+
# rubocop:disable Metrics/ParameterLists
|
124
|
+
def custom_error(title, inherit_from, txt = nil, i18n_key: nil, notify: nil, &default_message_block)
|
125
|
+
unless inherit_from < Errors::Base
|
126
|
+
raise ArgumentError, 'inherit_from must be a superclass of LunaPark::Errors::Base'
|
127
|
+
end
|
128
|
+
|
129
|
+
error_class = Class.new(inherit_from)
|
130
|
+
error_class.inherited(inherit_from)
|
131
|
+
error_class.notify(notify) unless notify.nil?
|
132
|
+
|
133
|
+
message_present = ![txt, i18n_key, default_message_block].all?(&:nil?)
|
134
|
+
error_class.message(txt, i18n_key: i18n_key, &default_message_block) if message_present
|
135
|
+
|
136
|
+
const_set(error_class_name(title), error_class)
|
137
|
+
end
|
138
|
+
# rubocop:enable Metrics/ParameterLists
|
139
|
+
|
105
140
|
##
|
106
141
|
# Get error class name
|
107
142
|
#
|
@@ -191,6 +191,19 @@ module LunaPark
|
|
191
191
|
def dependencies=(value)
|
192
192
|
@dependencies = Dependencies.wrap(value)
|
193
193
|
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Set dependencies, returns `self` to allow chaining
|
197
|
+
# Don't forget to override <b>all</b> dependencies.
|
198
|
+
#
|
199
|
+
# use_case
|
200
|
+
# .inject({ repo: -> { Fake::Repo.new }})
|
201
|
+
# .call
|
202
|
+
#
|
203
|
+
def inject(value)
|
204
|
+
self.dependencies = value
|
205
|
+
self
|
206
|
+
end
|
194
207
|
end
|
195
208
|
end
|
196
209
|
end
|
@@ -86,7 +86,7 @@ module LunaPark
|
|
86
86
|
#
|
87
87
|
# stderr = Stderr.new
|
88
88
|
# stderr.logger # => #<Logger:0x000056445e1e2118 ... @filename="example.log"...
|
89
|
-
# Or in the
|
89
|
+
# Or in the initialize of the instance
|
90
90
|
#
|
91
91
|
# - On instance
|
92
92
|
# stderr = LunaPark::Notifier::Log.new(logger: Logger.new(STDERR))
|
data/lib/luna_park/version.rb
CHANGED
data/lib/luna_park.rb
CHANGED
@@ -51,7 +51,7 @@ require 'luna_park/forms/single_item'
|
|
51
51
|
|
52
52
|
LunaPark::Tools.if_gem_installed('rest-client', '~> 2.1') { require 'luna_park/http/client' }
|
53
53
|
LunaPark::Tools.if_gem_installed('bugsnag', '~> 6') { require 'luna_park/notifiers/bugsnag' }
|
54
|
-
LunaPark::Tools.if_gem_installed('sentry-ruby', '
|
54
|
+
LunaPark::Tools.if_gem_installed('sentry-ruby', '>= 4') { require 'luna_park/notifiers/sentry' }
|
55
55
|
|
56
56
|
require 'luna_park/notifiers/log'
|
57
57
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luna_park
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kudrin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bugsnag
|