umbrellio-utils 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b63180fc355a29f6d9890b540e8fadfbc572070865b7309990de0bd0fc094ec
4
- data.tar.gz: 801fc30c7238f126b9fe705471be9d8d66f9b575e1789bd239d1868df323dfa8
3
+ metadata.gz: 85dd7dea4f1dee04c26507a0196e6a0520e99ef08db6b880ff5238c09980472a
4
+ data.tar.gz: 1377376c2ca11c16c1df7ac09dd64c4c7851d3a0e068b73b69d8701d31362488
5
5
  SHA512:
6
- metadata.gz: 1187dc1b14d139bb723e11be25e7a35412cc794618913272c10b9aeff8e5a98392525fc75bbfead6b6a59e7c8c37c305c7d27164eb2148da28540fad19ea1aac
7
- data.tar.gz: b4c696407bc41fb6ce2df840cb4476e99cdf68016e50a28545a33dcba615bc1dfd5b9c8822e5d357454207758538cd89b370b2efdf94ab950bfab74355ed5309
6
+ metadata.gz: 272cc4be8c75bb75a63c0ad649feda6da475aada4ec411a03e74fd404533d68087095781b965e1ac4d1ed2f6f5fa515ec40e9977d3a5da8f094ac05c9d34d259
7
+ data.tar.gz: 1ac80ccf3221cb5c4a5461fa949b6bc7e858d554e1dafe3781041d6146b6807b00e97b86649973900a14812715bed4ecf6735bd8f5d06e21094b02cf1e707444
@@ -32,7 +32,6 @@ jobs:
32
32
  github-token: ${{ secrets.GITHUB_TOKEN }}
33
33
  specs:
34
34
  runs-on: ubuntu-latest
35
- continue-on-error: ${{ matrix.experimental }}
36
35
 
37
36
  env:
38
37
  FULL_TEST_COVERAGE_CHECK: false
@@ -44,10 +43,6 @@ jobs:
44
43
  fail-fast: false
45
44
  matrix:
46
45
  ruby: [2.6, 2.7]
47
- experimental: [false]
48
- include:
49
- - ruby: head
50
- experimental: true
51
46
 
52
47
 
53
48
  steps:
data/Gemfile.lock CHANGED
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-utils (0.3.2)
4
+ umbrellio-utils (0.4.0)
5
5
  memery (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.3.1)
10
+ activesupport (6.1.4.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  zeitwerk (~> 2.3)
16
16
  ast (2.4.2)
17
- bundler-audit (0.8.0)
17
+ awesome_print (1.9.2)
18
+ bundler-audit (0.9.0.1)
18
19
  bundler (>= 1.2.0, < 3)
19
20
  thor (~> 1.0)
20
21
  ci-helper (0.4.2)
@@ -23,31 +24,32 @@ GEM
23
24
  umbrellio-sequel-plugins (~> 0.4)
24
25
  coderay (1.1.3)
25
26
  colorize (0.8.1)
26
- concurrent-ruby (1.1.8)
27
+ concurrent-ruby (1.1.9)
27
28
  diff-lcs (1.4.4)
28
- docile (1.3.5)
29
- dry-inflector (0.2.0)
29
+ docile (1.4.0)
30
+ dry-inflector (0.2.1)
30
31
  i18n (1.8.10)
31
32
  concurrent-ruby (~> 1.0)
33
+ json (2.6.1)
32
34
  memery (1.4.1)
33
35
  ruby2_keywords (~> 0.0.2)
34
36
  method_source (1.0.0)
35
37
  minitest (5.14.4)
36
- nokogiri (1.12.2-x86_64-darwin)
38
+ nokogiri (1.12.5-x86_64-darwin)
37
39
  racc (~> 1.4)
38
- nokogiri (1.12.2-x86_64-linux)
40
+ nokogiri (1.12.5-x86_64-linux)
39
41
  racc (~> 1.4)
40
42
  nori (2.6.0)
41
- parallel (1.20.1)
42
- parser (3.0.1.0)
43
+ parallel (1.21.0)
44
+ parser (3.0.2.0)
43
45
  ast (~> 2.4.1)
44
- pry (0.14.0)
46
+ pry (0.14.1)
45
47
  coderay (~> 1.1)
46
48
  method_source (~> 1.0)
47
- racc (1.5.2)
49
+ racc (1.6.0)
48
50
  rack (2.2.3)
49
51
  rainbow (3.0.0)
50
- rake (13.0.3)
52
+ rake (13.0.6)
51
53
  regexp_parser (2.1.1)
52
54
  rexml (3.2.5)
53
55
  rspec (3.10.0)
@@ -59,23 +61,26 @@ GEM
59
61
  rspec-expectations (3.10.1)
60
62
  diff-lcs (>= 1.2.0, < 2.0)
61
63
  rspec-support (~> 3.10.0)
64
+ rspec-json_matcher (0.1.6)
65
+ awesome_print
66
+ json
62
67
  rspec-mocks (3.10.2)
63
68
  diff-lcs (>= 1.2.0, < 2.0)
64
69
  rspec-support (~> 3.10.0)
65
70
  rspec-support (3.10.2)
66
- rubocop (1.11.0)
71
+ rubocop (1.17.0)
67
72
  parallel (~> 1.10)
68
73
  parser (>= 3.0.0.0)
69
74
  rainbow (>= 2.2.2, < 4.0)
70
75
  regexp_parser (>= 1.8, < 3.0)
71
76
  rexml
72
- rubocop-ast (>= 1.2.0, < 2.0)
77
+ rubocop-ast (>= 1.7.0, < 2.0)
73
78
  ruby-progressbar (~> 1.7)
74
79
  unicode-display_width (>= 1.4.0, < 3.0)
75
- rubocop-ast (1.4.1)
76
- parser (>= 2.7.1.5)
77
- rubocop-config-umbrellio (1.11.0.40)
78
- rubocop (= 1.11.0)
80
+ rubocop-ast (1.12.0)
81
+ parser (>= 3.0.1.1)
82
+ rubocop-config-umbrellio (1.17.0.53)
83
+ rubocop (= 1.17.0)
79
84
  rubocop-performance (= 1.10.0)
80
85
  rubocop-rails (= 2.9.1)
81
86
  rubocop-rake (= 0.5.1)
@@ -97,24 +102,26 @@ GEM
97
102
  rubocop (~> 1.0)
98
103
  ruby-progressbar (1.11.0)
99
104
  ruby2_keywords (0.0.5)
100
- sequel (5.43.0)
105
+ semantic_logger (4.8.2)
106
+ concurrent-ruby (~> 1.0)
107
+ sequel (5.49.0)
101
108
  simplecov (0.21.2)
102
109
  docile (~> 1.1)
103
110
  simplecov-html (~> 0.11)
104
111
  simplecov_json_formatter (~> 0.1)
105
112
  simplecov-html (0.12.3)
106
113
  simplecov-lcov (0.8.0)
107
- simplecov_json_formatter (0.1.2)
108
- symbiont-ruby (0.6.0)
114
+ simplecov_json_formatter (0.1.3)
115
+ symbiont-ruby (0.7.0)
109
116
  thor (1.1.0)
110
117
  tzinfo (2.0.4)
111
118
  concurrent-ruby (~> 1.0)
112
- umbrellio-sequel-plugins (0.4.0.164)
119
+ umbrellio-sequel-plugins (0.5.1.27)
113
120
  sequel
114
- symbiont-ruby (>= 0.6)
115
- unicode-display_width (2.0.0)
121
+ symbiont-ruby
122
+ unicode-display_width (2.1.0)
116
123
  yard (0.9.26)
117
- zeitwerk (2.4.2)
124
+ zeitwerk (2.5.1)
118
125
 
119
126
  PLATFORMS
120
127
  x86_64-darwin-20
@@ -130,11 +137,13 @@ DEPENDENCIES
130
137
  pry
131
138
  rake
132
139
  rspec
140
+ rspec-json_matcher
133
141
  rubocop-config-umbrellio
142
+ semantic_logger
134
143
  simplecov
135
144
  simplecov-lcov
136
145
  umbrellio-utils!
137
146
  yard
138
147
 
139
148
  BUNDLED WITH
140
- 2.2.22
149
+ 2.2.29
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UmbrellioUtils
4
+ # Namespace for the differrent appenders and formatters for the SemanticLogger library.
5
+ # @see https://logger.rocketjob.io/ Semantic Logger documentation.
6
+ module SemanticLogger
7
+ # Simple JSON formatter, represented as callable object.
8
+ # @example Using of formatter
9
+ # formatter = UmbrellioUtils::SemanticLogger::TinyJsonFormatter.new
10
+ # SemanticLogger.add_appender(io: $stdout, formatter: formatter)
11
+ class TinyJsonFormatter
12
+ # Hash with default field names in the output JSON.
13
+ DEFAULT_NAMES_MAPPING = {
14
+ severity: :severity,
15
+ name: :name,
16
+ thread_fingerprint: :thread_fingerprint,
17
+ message: :message,
18
+ app_tags: :app_tags,
19
+ time: :time,
20
+ }.freeze
21
+
22
+ # Returns a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}.
23
+ # @param [Hash] custom_names_mapping mapping from default field names to custom ones.
24
+ # @option custom_names_mapping [Symbol] :severity custom name for the `severity` field.
25
+ # @option custom_names_mapping [Symbol] :name custom name for the `name` field.
26
+ # @option custom_names_mapping [Symbol] :thread_fingerprint
27
+ # custom name for the thread_fingerprint field.
28
+ # @option custom_names_mapping [Symbol] :message custom name for the `message` field.
29
+ # @option custom_names_mapping [Symbol] :app_tags custom name for the `app_tags` field.
30
+ # @option custom_names_mapping [Symbol] :time custom name for the `time` field.
31
+ # @example Use custom name for the `message` and `time` fields
32
+ # UmbrellioUtils::SemanticLogger::TinyJsonFormatter.new(
33
+ # time: :timestamp, message: :note,
34
+ # ) #=> <UmbrellioUtils::SemanticLogger::TinyJsonFormatter:0x000>
35
+ # @return [UmbrellioUtils::SemanticLogger::TinyJsonFormatter]
36
+ # a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}
37
+ def initialize(**custom_names_mapping)
38
+ self.field_names = { **DEFAULT_NAMES_MAPPING, **custom_names_mapping }.freeze
39
+ end
40
+
41
+ # Formats log structure into the JSON string.
42
+ # @param log [SemanticLogger::Log] log's data structure.
43
+ # @param logger [SemanticLogger::Logger] active logger.
44
+ # @return [String] data
45
+ def call(log, _logger)
46
+ data = build_data_for(log)
47
+ data.to_json
48
+ end
49
+
50
+ private
51
+
52
+ # @!attribute field_names
53
+ # @return [Hash<Symbol, Symbol>] the mapping from default field names to the new ones.
54
+ attr_accessor :field_names
55
+
56
+ # Builds hash with data from log.
57
+ # @return [Hash] the hash, which will be converted to the JSON later.
58
+ def build_data_for(log)
59
+ field_names.values_at(*DEFAULT_NAMES_MAPPING.keys).zip(pack_data(log)).to_h
60
+ end
61
+
62
+ # Builds an [Array] with all the required fields, which are arranged
63
+ # in the order of the declaration of keys
64
+ # in the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter::DEFAULT_NAMES_MAPPING}.
65
+ # @return [Array] an array with serialized data.
66
+ def pack_data(log)
67
+ [
68
+ log.level.upcase,
69
+ log.name,
70
+ thread_fingerprint_for(log),
71
+ log.message,
72
+ log.named_tags,
73
+ log.time.utc.iso8601(3),
74
+ ]
75
+ end
76
+
77
+ # Calculates MD5 fingerprint for the thread, in which the log was made.
78
+ # @return [String] truncated `MD5` hash.
79
+ def thread_fingerprint_for(log)
80
+ Digest::MD5.hexdigest("#{log.thread_name}#{Process.pid}")[0...8]
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -5,8 +5,6 @@ require "memery"
5
5
  module UmbrellioUtils
6
6
  GLOBAL_MUTEX = Mutex.new
7
7
 
8
- Dir["#{__dir__}/*/*.rb"].each { |file_path| require_relative(file_path) }
9
-
10
8
  extend self
11
9
 
12
10
  def included(othermod)
@@ -47,3 +45,21 @@ module UmbrellioUtils
47
45
  GLOBAL_MUTEX.owned? ? yield : GLOBAL_MUTEX.synchronize(&block)
48
46
  end
49
47
  end
48
+
49
+ require_relative "umbrellio_utils/cards"
50
+ require_relative "umbrellio_utils/checks"
51
+ require_relative "umbrellio_utils/constants"
52
+ require_relative "umbrellio_utils/control"
53
+ require_relative "umbrellio_utils/database"
54
+ require_relative "umbrellio_utils/formatting"
55
+ require_relative "umbrellio_utils/http_client"
56
+ require_relative "umbrellio_utils/misc"
57
+ require_relative "umbrellio_utils/parsing"
58
+ require_relative "umbrellio_utils/passwords"
59
+ require_relative "umbrellio_utils/random"
60
+ require_relative "umbrellio_utils/request_wrapper"
61
+ require_relative "umbrellio_utils/rounding"
62
+ require_relative "umbrellio_utils/semantic_logger/tiny_json_formatter"
63
+ require_relative "umbrellio_utils/store"
64
+ require_relative "umbrellio_utils/vault"
65
+ require_relative "umbrellio_utils/version"
@@ -38,7 +38,9 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "pry"
39
39
  spec.add_development_dependency "rake"
40
40
  spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "rspec-json_matcher"
41
42
  spec.add_development_dependency "rubocop-config-umbrellio"
43
+ spec.add_development_dependency "semantic_logger"
42
44
  spec.add_development_dependency "simplecov"
43
45
  spec.add_development_dependency "simplecov-lcov"
44
46
  spec.add_development_dependency "yard"
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustAnotherDude
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-09 00:00:00.000000000 Z
11
+ date: 2021-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-json_matcher
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: rubocop-config-umbrellio
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +178,20 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: semantic_logger
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
167
195
  - !ruby/object:Gem::Dependency
168
196
  name: simplecov
169
197
  requirement: !ruby/object:Gem::Requirement
@@ -240,6 +268,7 @@ files:
240
268
  - lib/umbrellio_utils/random.rb
241
269
  - lib/umbrellio_utils/request_wrapper.rb
242
270
  - lib/umbrellio_utils/rounding.rb
271
+ - lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb
243
272
  - lib/umbrellio_utils/store.rb
244
273
  - lib/umbrellio_utils/vault.rb
245
274
  - lib/umbrellio_utils/version.rb
@@ -266,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
295
  - !ruby/object:Gem::Version
267
296
  version: '0'
268
297
  requirements: []
269
- rubygems_version: 3.2.22
298
+ rubygems_version: 3.2.30
270
299
  signing_key:
271
300
  specification_version: 4
272
301
  summary: A set of utilities that speed up development