umbrellio-utils 0.7.4 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fbbcbcfd7e518b7673e46222b16b7b1bd34043e6ce41daeab68be72061a0c02
4
- data.tar.gz: 77c3e024673156610281bcb81cbdaf25ec86e1034ab32c02975f0afa39ef7f06
3
+ metadata.gz: e5415ce42c2ba64403bb051b4d1772724226f8f0eb321d7eacae22af3db9961e
4
+ data.tar.gz: 11f4a31ba535995db43fd3d5f8d180061d494488baf2a7548fa13844ee5b5b53
5
5
  SHA512:
6
- metadata.gz: 79ed5bc2a2c4c1c1271fb7f9ed026b7993d22d426e11a25dc6af9c0f950d24f10a92cbd4820a84704f49c4af42696a8382bb9d5d3354684d2565509dd8cc356e
7
- data.tar.gz: 2d38414441ef3aeceab73d7089c2656dcffaf78c4a9f4142f9ce091ad058a0a816882b0a1e0b1d99388822100e1042489e68c689f14c75090b37e40144a2dc0d
6
+ metadata.gz: 715ccd8c42effe71b0be1e8482d8188b8dace23acd7e579b35d3491d4ba0c8d8d77b3e33396c22b034ea6f6199a0983b274828e05ab62ea684bc6ff57d74594b
7
+ data.tar.gz: d312202f931ee6d070f660f39148aaece7d71f5cca2a68ee31b61f4c5da525950b6702e0cd0f616e126047627aab9d6326641ed6310279c6ffa2e07cae536364
@@ -15,7 +15,7 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: ["2.7", "3.0", "3.1", "3.2"]
18
+ ruby: ["3.0", "3.1", "3.2", "3.3"]
19
19
 
20
20
  services:
21
21
  postgres:
@@ -53,9 +53,6 @@ jobs:
53
53
  - name: Run specs
54
54
  run: bundle exec ci-helper RunSpecs
55
55
 
56
- - name: Audit
57
- run: bundle exec ci-helper BundlerAudit
58
-
59
56
  - name: Coveralls
60
57
  uses: coverallsapp/github-action@master
61
58
  with:
data/.rubocop.yml CHANGED
@@ -3,7 +3,8 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0
7
+ SuggestExtensions: false
7
8
 
8
9
  Naming/MethodParameterName:
9
10
  AllowedNames: ["x", "y", "z"]
data/Gemfile CHANGED
@@ -8,10 +8,9 @@ gemspec
8
8
  group :development, :test do
9
9
  gem "activesupport"
10
10
  gem "bundler"
11
- gem "bundler-audit"
12
11
  gem "ci-helper"
13
12
  gem "http"
14
- gem "nokogiri"
13
+ gem "nokogiri", "~> 1.15.0"
15
14
  gem "nori"
16
15
  gem "pg"
17
16
  gem "pry"
data/Gemfile.lock CHANGED
@@ -1,128 +1,141 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-utils (0.7.4)
4
+ umbrellio-utils (1.0.0)
5
5
  memery (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.0.8)
11
- actionpack (= 7.0.8)
12
- activesupport (= 7.0.8)
10
+ actioncable (7.1.3.2)
11
+ actionpack (= 7.1.3.2)
12
+ activesupport (= 7.1.3.2)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (7.0.8)
16
- actionpack (= 7.0.8)
17
- activejob (= 7.0.8)
18
- activerecord (= 7.0.8)
19
- activestorage (= 7.0.8)
20
- activesupport (= 7.0.8)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.1.3.2)
17
+ actionpack (= 7.1.3.2)
18
+ activejob (= 7.1.3.2)
19
+ activerecord (= 7.1.3.2)
20
+ activestorage (= 7.1.3.2)
21
+ activesupport (= 7.1.3.2)
21
22
  mail (>= 2.7.1)
22
23
  net-imap
23
24
  net-pop
24
25
  net-smtp
25
- actionmailer (7.0.8)
26
- actionpack (= 7.0.8)
27
- actionview (= 7.0.8)
28
- activejob (= 7.0.8)
29
- activesupport (= 7.0.8)
26
+ actionmailer (7.1.3.2)
27
+ actionpack (= 7.1.3.2)
28
+ actionview (= 7.1.3.2)
29
+ activejob (= 7.1.3.2)
30
+ activesupport (= 7.1.3.2)
30
31
  mail (~> 2.5, >= 2.5.4)
31
32
  net-imap
32
33
  net-pop
33
34
  net-smtp
34
- rails-dom-testing (~> 2.0)
35
- actionpack (7.0.8)
36
- actionview (= 7.0.8)
37
- activesupport (= 7.0.8)
38
- rack (~> 2.0, >= 2.2.4)
35
+ rails-dom-testing (~> 2.2)
36
+ actionpack (7.1.3.2)
37
+ actionview (= 7.1.3.2)
38
+ activesupport (= 7.1.3.2)
39
+ nokogiri (>= 1.8.5)
40
+ racc
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
39
43
  rack-test (>= 0.6.3)
40
- rails-dom-testing (~> 2.0)
41
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
- actiontext (7.0.8)
43
- actionpack (= 7.0.8)
44
- activerecord (= 7.0.8)
45
- activestorage (= 7.0.8)
46
- activesupport (= 7.0.8)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.3.2)
47
+ actionpack (= 7.1.3.2)
48
+ activerecord (= 7.1.3.2)
49
+ activestorage (= 7.1.3.2)
50
+ activesupport (= 7.1.3.2)
47
51
  globalid (>= 0.6.0)
48
52
  nokogiri (>= 1.8.5)
49
- actionview (7.0.8)
50
- activesupport (= 7.0.8)
53
+ actionview (7.1.3.2)
54
+ activesupport (= 7.1.3.2)
51
55
  builder (~> 3.1)
52
- erubi (~> 1.4)
53
- rails-dom-testing (~> 2.0)
54
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
- activejob (7.0.8)
56
- activesupport (= 7.0.8)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.3.2)
60
+ activesupport (= 7.1.3.2)
57
61
  globalid (>= 0.3.6)
58
- activemodel (7.0.8)
59
- activesupport (= 7.0.8)
60
- activerecord (7.0.8)
61
- activemodel (= 7.0.8)
62
- activesupport (= 7.0.8)
63
- activestorage (7.0.8)
64
- actionpack (= 7.0.8)
65
- activejob (= 7.0.8)
66
- activerecord (= 7.0.8)
67
- activesupport (= 7.0.8)
62
+ activemodel (7.1.3.2)
63
+ activesupport (= 7.1.3.2)
64
+ activerecord (7.1.3.2)
65
+ activemodel (= 7.1.3.2)
66
+ activesupport (= 7.1.3.2)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.3.2)
69
+ actionpack (= 7.1.3.2)
70
+ activejob (= 7.1.3.2)
71
+ activerecord (= 7.1.3.2)
72
+ activesupport (= 7.1.3.2)
68
73
  marcel (~> 1.0)
69
- mini_mime (>= 1.1.0)
70
- activesupport (7.0.8)
74
+ activesupport (7.1.3.2)
75
+ base64
76
+ bigdecimal
71
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ connection_pool (>= 2.2.5)
79
+ drb
72
80
  i18n (>= 1.6, < 2)
73
81
  minitest (>= 5.1)
82
+ mutex_m
74
83
  tzinfo (~> 2.0)
75
- addressable (2.8.5)
84
+ addressable (2.8.6)
76
85
  public_suffix (>= 2.0.2, < 6.0)
77
- amazing_print (1.5.0)
86
+ amazing_print (1.6.0)
78
87
  amq-protocol (2.3.2)
79
88
  ast (2.4.2)
80
- bigdecimal (3.1.4)
89
+ base64 (0.2.0)
90
+ bigdecimal (3.1.7)
81
91
  builder (3.2.4)
82
- bundler-audit (0.9.1)
83
- bundler (>= 1.2.0, < 3)
84
- thor (~> 1.0)
85
92
  bunny (2.22.0)
86
93
  amq-protocol (~> 2.3, >= 2.3.1)
87
94
  sorted_set (~> 1, >= 1.0.2)
88
- ci-helper (0.5.0)
89
- colorize (~> 0.8)
90
- dry-inflector (~> 0.2)
91
- umbrellio-sequel-plugins (~> 0.4)
95
+ ci-helper (0.6.0)
96
+ colorize (~> 1.1)
97
+ dry-inflector (~> 1.0)
98
+ umbrellio-sequel-plugins (~> 0.14)
92
99
  coderay (1.1.3)
93
- colorize (0.8.1)
94
- concurrent-ruby (1.2.2)
100
+ colorize (1.1.0)
101
+ concurrent-ruby (1.2.3)
102
+ connection_pool (2.4.1)
95
103
  crass (1.0.6)
96
- date (3.3.3)
97
- diff-lcs (1.5.0)
104
+ date (3.3.4)
105
+ diff-lcs (1.5.1)
98
106
  docile (1.4.0)
99
- domain_name (0.5.20190701)
100
- unf (>= 0.0.5, < 1.0.0)
101
- dry-inflector (0.3.0)
107
+ domain_name (0.6.20240107)
108
+ drb (2.2.1)
109
+ dry-inflector (1.0.0)
102
110
  erubi (1.12.0)
103
- ffi (1.15.5)
104
- ffi-compiler (1.0.1)
105
- ffi (>= 1.0.0)
111
+ ffi (1.16.3)
112
+ ffi-compiler (1.3.2)
113
+ ffi (>= 1.15.5)
106
114
  rake
107
115
  globalid (1.2.1)
108
116
  activesupport (>= 6.1)
109
- http (5.1.1)
117
+ http (5.2.0)
110
118
  addressable (~> 2.8)
119
+ base64 (~> 0.1)
111
120
  http-cookie (~> 1.0)
112
121
  http-form_data (~> 2.2)
113
- llhttp-ffi (~> 0.4.0)
122
+ llhttp-ffi (~> 0.5.0)
114
123
  http-cookie (1.0.5)
115
124
  domain_name (~> 0.5)
116
125
  http-form_data (2.3.0)
117
- i18n (1.14.1)
126
+ i18n (1.14.4)
118
127
  concurrent-ruby (~> 1.0)
119
- json (2.6.3)
120
- lamian (1.7.0)
128
+ io-console (0.7.2)
129
+ irb (1.12.0)
130
+ rdoc
131
+ reline (>= 0.4.2)
132
+ json (2.7.2)
133
+ lamian (1.8.0)
121
134
  rails (>= 4.2)
122
- llhttp-ffi (0.4.0)
135
+ llhttp-ffi (0.5.0)
123
136
  ffi-compiler (~> 1.0)
124
137
  rake (~> 13.0)
125
- loofah (2.21.3)
138
+ loofah (2.22.0)
126
139
  crass (~> 1.0.2)
127
140
  nokogiri (>= 1.12.0)
128
141
  mail (2.8.1)
@@ -130,66 +143,69 @@ GEM
130
143
  net-imap
131
144
  net-pop
132
145
  net-smtp
133
- marcel (1.0.2)
146
+ marcel (1.0.4)
134
147
  memery (1.5.0)
135
148
  ruby2_keywords (~> 0.0.2)
136
- method_source (1.0.0)
149
+ method_source (1.1.0)
137
150
  mini_mime (1.1.5)
138
- mini_portile2 (2.8.4)
139
- minitest (5.20.0)
140
- net-imap (0.3.7)
151
+ mini_portile2 (2.8.6)
152
+ minitest (5.22.3)
153
+ mutex_m (0.2.0)
154
+ net-imap (0.4.10)
141
155
  date
142
156
  net-protocol
143
157
  net-pop (0.1.2)
144
158
  net-protocol
145
- net-protocol (0.2.1)
159
+ net-protocol (0.2.2)
146
160
  timeout
147
- net-smtp (0.3.3)
161
+ net-smtp (0.5.0)
148
162
  net-protocol
149
- nio4r (2.5.9)
150
- nokogiri (1.15.4)
163
+ nio4r (2.7.1)
164
+ nokogiri (1.15.6)
151
165
  mini_portile2 (~> 2.8.2)
152
166
  racc (~> 1.4)
153
- nokogiri (1.15.4-arm64-darwin)
154
- racc (~> 1.4)
155
- nokogiri (1.15.4-x86_64-darwin)
156
- racc (~> 1.4)
157
- nokogiri (1.15.4-x86_64-linux)
158
- racc (~> 1.4)
159
- nori (2.6.0)
160
- parallel (1.23.0)
161
- parser (3.2.2.3)
167
+ nori (2.7.0)
168
+ bigdecimal
169
+ parallel (1.24.0)
170
+ parser (3.3.0.5)
162
171
  ast (~> 2.4.1)
163
172
  racc
164
- pg (1.5.4)
173
+ pg (1.5.6)
165
174
  pry (0.14.2)
166
175
  coderay (~> 1.1)
167
176
  method_source (~> 1.0)
168
- public_suffix (5.0.3)
177
+ psych (5.1.2)
178
+ stringio
179
+ public_suffix (5.0.5)
169
180
  rabbit_messaging (0.13.0)
170
181
  bunny (~> 2.0)
171
182
  lamian
172
183
  rails (>= 5.2)
173
184
  sneakers (~> 2.0)
174
185
  tainbox
175
- racc (1.7.1)
176
- rack (2.2.8)
186
+ racc (1.7.3)
187
+ rack (3.0.10)
188
+ rack-session (2.0.0)
189
+ rack (>= 3.0.0)
177
190
  rack-test (2.1.0)
178
191
  rack (>= 1.3)
179
- rails (7.0.8)
180
- actioncable (= 7.0.8)
181
- actionmailbox (= 7.0.8)
182
- actionmailer (= 7.0.8)
183
- actionpack (= 7.0.8)
184
- actiontext (= 7.0.8)
185
- actionview (= 7.0.8)
186
- activejob (= 7.0.8)
187
- activemodel (= 7.0.8)
188
- activerecord (= 7.0.8)
189
- activestorage (= 7.0.8)
190
- activesupport (= 7.0.8)
192
+ rackup (2.1.0)
193
+ rack (>= 3)
194
+ webrick (~> 1.8)
195
+ rails (7.1.3.2)
196
+ actioncable (= 7.1.3.2)
197
+ actionmailbox (= 7.1.3.2)
198
+ actionmailer (= 7.1.3.2)
199
+ actionpack (= 7.1.3.2)
200
+ actiontext (= 7.1.3.2)
201
+ actionview (= 7.1.3.2)
202
+ activejob (= 7.1.3.2)
203
+ activemodel (= 7.1.3.2)
204
+ activerecord (= 7.1.3.2)
205
+ activestorage (= 7.1.3.2)
206
+ activesupport (= 7.1.3.2)
191
207
  bundler (>= 1.15.0)
192
- railties (= 7.0.8)
208
+ railties (= 7.1.3.2)
193
209
  rails-dom-testing (2.2.0)
194
210
  activesupport (>= 5.0.0)
195
211
  minitest
@@ -197,34 +213,39 @@ GEM
197
213
  rails-html-sanitizer (1.6.0)
198
214
  loofah (~> 2.21)
199
215
  nokogiri (~> 1.14)
200
- railties (7.0.8)
201
- actionpack (= 7.0.8)
202
- activesupport (= 7.0.8)
203
- method_source
216
+ railties (7.1.3.2)
217
+ actionpack (= 7.1.3.2)
218
+ activesupport (= 7.1.3.2)
219
+ irb
220
+ rackup (>= 1.0.0)
204
221
  rake (>= 12.2)
205
- thor (~> 1.0)
206
- zeitwerk (~> 2.5)
222
+ thor (~> 1.0, >= 1.2.2)
223
+ zeitwerk (~> 2.6)
207
224
  rainbow (3.1.1)
208
- rake (13.0.6)
225
+ rake (13.2.1)
209
226
  rbtree (0.4.6)
210
- regexp_parser (2.8.1)
227
+ rdoc (6.6.3.1)
228
+ psych (>= 4.0.0)
229
+ regexp_parser (2.9.0)
230
+ reline (0.5.1)
231
+ io-console (~> 0.5)
211
232
  rexml (3.2.6)
212
- rspec (3.12.0)
213
- rspec-core (~> 3.12.0)
214
- rspec-expectations (~> 3.12.0)
215
- rspec-mocks (~> 3.12.0)
216
- rspec-core (3.12.2)
217
- rspec-support (~> 3.12.0)
218
- rspec-expectations (3.12.3)
233
+ rspec (3.13.0)
234
+ rspec-core (~> 3.13.0)
235
+ rspec-expectations (~> 3.13.0)
236
+ rspec-mocks (~> 3.13.0)
237
+ rspec-core (3.13.0)
238
+ rspec-support (~> 3.13.0)
239
+ rspec-expectations (3.13.0)
219
240
  diff-lcs (>= 1.2.0, < 2.0)
220
- rspec-support (~> 3.12.0)
241
+ rspec-support (~> 3.13.0)
221
242
  rspec-json_matcher (0.2.0)
222
243
  amazing_print
223
244
  json
224
- rspec-mocks (3.12.6)
245
+ rspec-mocks (3.13.0)
225
246
  diff-lcs (>= 1.2.0, < 2.0)
226
- rspec-support (~> 3.12.0)
227
- rspec-support (3.12.1)
247
+ rspec-support (~> 3.13.0)
248
+ rspec-support (3.13.1)
228
249
  rubocop (1.50.2)
229
250
  json (~> 2.3)
230
251
  parallel (~> 1.10)
@@ -235,9 +256,9 @@ GEM
235
256
  rubocop-ast (>= 1.28.0, < 2.0)
236
257
  ruby-progressbar (~> 1.7)
237
258
  unicode-display_width (>= 2.4.0, < 3.0)
238
- rubocop-ast (1.29.0)
239
- parser (>= 3.2.1.0)
240
- rubocop-capybara (2.18.0)
259
+ rubocop-ast (1.31.2)
260
+ parser (>= 3.3.0.4)
261
+ rubocop-capybara (2.20.0)
241
262
  rubocop (~> 1.41)
242
263
  rubocop-config-umbrellio (1.50.0.85)
243
264
  rubocop (~> 1.50.0)
@@ -263,15 +284,15 @@ GEM
263
284
  ruby-progressbar (1.13.0)
264
285
  ruby2_keywords (0.0.5)
265
286
  self_data (1.3.0)
266
- semantic_logger (4.14.0)
287
+ semantic_logger (4.15.0)
267
288
  concurrent-ruby (~> 1.0)
268
- sequel (5.72.0)
289
+ sequel (5.79.0)
269
290
  bigdecimal
270
291
  sequel-batches (2.0.2)
271
292
  sequel
272
293
  serverengine (2.0.7)
273
294
  sigdump (~> 0.2.2)
274
- set (1.0.3)
295
+ set (1.1.0)
275
296
  sigdump (0.2.5)
276
297
  simplecov (0.22.0)
277
298
  docile (~> 1.1)
@@ -289,35 +310,35 @@ GEM
289
310
  sorted_set (1.0.3)
290
311
  rbtree
291
312
  set (~> 1.0)
313
+ stringio (3.1.0)
292
314
  symbiont-ruby (0.7.0)
293
- table_sync (6.4.1)
315
+ table_sync (6.5.0)
294
316
  memery
295
317
  rabbit_messaging (~> 0.13)
296
318
  rails
297
319
  self_data
298
320
  tainbox (2.1.2)
299
321
  activesupport
300
- thor (1.2.2)
322
+ thor (1.3.1)
301
323
  timecop (0.9.8)
302
- timeout (0.4.0)
324
+ timeout (0.4.1)
303
325
  tzinfo (2.0.6)
304
326
  concurrent-ruby (~> 1.0)
305
- umbrellio-sequel-plugins (0.14.0.187)
327
+ umbrellio-sequel-plugins (0.14.0.192)
306
328
  sequel
307
329
  symbiont-ruby
308
- unf (0.1.4)
309
- unf_ext
310
- unf_ext (0.0.8.2)
311
- unicode-display_width (2.4.2)
330
+ unicode-display_width (2.5.0)
331
+ webrick (1.8.1)
312
332
  websocket-driver (0.7.6)
313
333
  websocket-extensions (>= 0.1.0)
314
334
  websocket-extensions (0.1.5)
315
- yard (0.9.34)
316
- zeitwerk (2.6.11)
335
+ yard (0.9.36)
336
+ zeitwerk (2.6.13)
317
337
 
318
338
  PLATFORMS
319
339
  arm64-darwin-20
320
340
  arm64-darwin-21
341
+ arm64-darwin-23
321
342
  ruby
322
343
  x86_64-darwin-20
323
344
  x86_64-linux
@@ -325,10 +346,9 @@ PLATFORMS
325
346
  DEPENDENCIES
326
347
  activesupport
327
348
  bundler
328
- bundler-audit
329
349
  ci-helper
330
350
  http
331
- nokogiri
351
+ nokogiri (~> 1.15.0)
332
352
  nori
333
353
  pg
334
354
  pry
@@ -347,4 +367,4 @@ DEPENDENCIES
347
367
  yard
348
368
 
349
369
  BUNDLED WITH
350
- 2.4.5
370
+ 2.5.9
@@ -4,8 +4,8 @@ module UmbrellioUtils
4
4
  module Checks
5
5
  extend self
6
6
 
7
- EMAIL_REGEXP = /\A([\w+-].?)+@[a-z\d-]+(\.[a-z]+)*\.[a-z]+\z/i.freeze
8
- HOLDER_NAME_REGEXP = /\A([A-Za-z0-9.'-]+ ?)+\z/.freeze
7
+ EMAIL_REGEXP = /\A([\w+-].?)+@[a-z\d-]+(\.[a-z]+)*\.[a-z]+\z/i
8
+ HOLDER_NAME_REGEXP = /\A([A-Za-z0-9.'-]+ ?)+\z/
9
9
 
10
10
  def secure_compare(src, dest)
11
11
  ActiveSupport::SecurityUtils.secure_compare(
@@ -9,7 +9,7 @@ module UmbrellioUtils
9
9
  HTTP_X_HTTP_AUTHORIZATION
10
10
  HTTP_REDIRECT_X_HTTP_AUTHORIZATION
11
11
  ].freeze
12
- CARD_TRUNCATED_PAN_REGEX = /\A(\d{6}).*(\d{4})\z/.freeze
12
+ CARD_TRUNCATED_PAN_REGEX = /\A(\d{6}).*(\d{4})\z/
13
13
 
14
14
  def try_to_parse_as_json(data)
15
15
  JSON.parse(data) rescue data
@@ -4,6 +4,8 @@ module UmbrellioUtils
4
4
  module Rounding
5
5
  extend self
6
6
 
7
+ SUPER_ROUND_DEFAULT_TARGETS = [1.0, 1.5, 2.5, 5.0, 10.0].freeze
8
+
7
9
  def fancy_round(number, rounding_method: :round, ugliness_level: 1)
8
10
  return 0 unless number.positive?
9
11
  log = Math.log(number, 10).floor
@@ -11,7 +13,7 @@ module UmbrellioUtils
11
13
  (number * coef).public_send(rounding_method, -log) / coef.to_f
12
14
  end
13
15
 
14
- def super_round(number, rounding_method: :round)
16
+ def super_round(number, rounding_method: :round, targets: SUPER_ROUND_DEFAULT_TARGETS)
15
17
  return 0 unless number.positive?
16
18
 
17
19
  coef = 10**Math.log(number, 10).floor
@@ -19,7 +21,7 @@ module UmbrellioUtils
19
21
 
20
22
  best_diff = best_target = nil
21
23
 
22
- [1.0, 1.5, 2.5, 5.0, 10.0].each do |target|
24
+ targets.each do |target|
23
25
  diff = target - num
24
26
 
25
27
  next if rounding_method == :ceil && diff.negative?
@@ -21,7 +21,8 @@ module UmbrellioUtils
21
21
  }.freeze
22
22
 
23
23
  # Returns a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}.
24
- # @param [Hash] custom_names_mapping mapping from default field names to custom ones.
24
+ # @option [Integer] message_size_limit maximum number of characters in a log message
25
+ # @option [Hash] custom_names_mapping mapping from default field names to custom ones.
25
26
  # @option custom_names_mapping [Symbol] :severity custom name for the `severity` field.
26
27
  # @option custom_names_mapping [Symbol] :name custom name for the `name` field.
27
28
  # @option custom_names_mapping [Symbol] :thread_fingerprint
@@ -36,7 +37,8 @@ module UmbrellioUtils
36
37
  # ) #=> <UmbrellioUtils::SemanticLogger::TinyJsonFormatter:0x000>
37
38
  # @return [UmbrellioUtils::SemanticLogger::TinyJsonFormatter]
38
39
  # a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}
39
- def initialize(**custom_names_mapping)
40
+ def initialize(message_size_limit: 10_000, custom_names_mapping: {})
41
+ self.message_size_limit = message_size_limit
40
42
  self.field_names = { **DEFAULT_NAMES_MAPPING, **custom_names_mapping }.freeze
41
43
  end
42
44
 
@@ -53,7 +55,7 @@ module UmbrellioUtils
53
55
 
54
56
  # @!attribute field_names
55
57
  # @return [Hash<Symbol, Symbol>] the mapping from default field names to the new ones.
56
- attr_accessor :field_names
58
+ attr_accessor :message_size_limit, :field_names
57
59
 
58
60
  # Builds hash with data from log.
59
61
  # @return [Hash] the hash, which will be converted to the JSON later.
@@ -69,8 +71,8 @@ module UmbrellioUtils
69
71
  [
70
72
  log.level.upcase,
71
73
  log.name,
72
- thread_fingerprint_for(log),
73
- log_to_message(log),
74
+ thread_fingerprint,
75
+ truncate(log_to_message(log)),
74
76
  log.tags,
75
77
  log.named_tags,
76
78
  log.time.utc.iso8601(9),
@@ -79,8 +81,8 @@ module UmbrellioUtils
79
81
 
80
82
  # Calculates MD5 fingerprint for the thread in which the log was made.
81
83
  # @return [String] truncated `MD5` hash.
82
- def thread_fingerprint_for(log)
83
- Digest::MD5.hexdigest("#{log.thread_name}#{Process.pid}")[0...8]
84
+ def thread_fingerprint
85
+ Digest::MD5.hexdigest("#{Thread.current.object_id}-#{Process.pid}")[0...8]
84
86
  end
85
87
 
86
88
  # Renders either exception or message of the log.
@@ -91,9 +93,18 @@ module UmbrellioUtils
91
93
  msg << "\n#{e.backtrace.join("\n")}" if e.backtrace
92
94
  msg
93
95
  else
94
- log.message
96
+ log.message.to_s
95
97
  end
96
98
  end
99
+
100
+ def truncate(msg)
101
+ return msg unless msg.size > message_size_limit
102
+
103
+ suffix = "..."
104
+ msg = msg[0, message_size_limit - suffix.size]
105
+
106
+ "#{msg}#{suffix}"
107
+ end
97
108
  end
98
109
  end
99
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "0.7.4"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -5,14 +5,14 @@ require_relative "lib/umbrellio_utils/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "umbrellio-utils"
7
7
  spec.version = UmbrellioUtils::VERSION
8
- spec.authors = ["JustAnotherDude"]
9
- spec.email = ["VanyaZ158@gmail.com"]
8
+ spec.authors = ["Team Umbrellio"]
9
+ spec.email = ["oss@umbrellio.biz"]
10
10
 
11
11
  spec.summary = "A set of utilities that speed up development"
12
12
  spec.description = "UmbrellioUtils is collection of utility classes and helpers"
13
13
  spec.homepage = "https://github.com/umbrellio/utils"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/umbrellio/utils"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - JustAnotherDude
7
+ - Team Umbrellio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-12 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -26,7 +26,7 @@ dependencies:
26
26
  version: '1'
27
27
  description: UmbrellioUtils is collection of utility classes and helpers
28
28
  email:
29
- - VanyaZ158@gmail.com
29
+ - oss@umbrellio.biz
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
@@ -79,14 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.7.0
82
+ version: 3.0.0
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.4.21
89
+ rubygems_version: 3.5.7
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: A set of utilities that speed up development