umbrellio-utils 0.3.1 → 0.4.2

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: e701149e2cc866576a584afb0ce4f0260def90172435574b54a76fa360cccc6f
4
- data.tar.gz: 3ade3ca53aeb50fcab231798611f1810875e483e55eacdbfd31d111b161977b7
3
+ metadata.gz: 0f1da3d7102c650b1eab97c3bcd0e1b591ce801cd6d059fd587d08973584caec
4
+ data.tar.gz: a0c872a73093def0f6619ef4470483246509b1354ae9b2d18cef072b57468de7
5
5
  SHA512:
6
- metadata.gz: 66a5e895a307e11876af84245aa5efd02c8826643bf4ef15ef897222e47c26bbc44acfc33d8f174e776656a41389257eb7aceaa9efdbe243067db0b3fa7638d7
7
- data.tar.gz: 2e7a2a4a186c4d4f5772bafced3d3486b97fbe25a75316ca473f901798eecba57e9b8c2170f23b4a868b2f77ac233b1de946df7b1d23ab7fa260764de8375835
6
+ metadata.gz: 152ec5b9c0664c3c25726f94f9feac298465ed8d779057d27ad19e58cd5b18f614871857467cf5452ca5aa904a640ed84789a9442feef2924807943f0bf9b692
7
+ data.tar.gz: f6d80689b65a50b82bdadc32d3a4ee391e4c18be22111e5e20204cf5401d91ebcabdfd358520d04201d405835bb79debee639ed0fb8e034e2845f1599cdcce92
@@ -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.1)
4
+ umbrellio-utils (0.4.2)
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,25 +24,34 @@ 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)
32
- memery (1.4.0)
33
+ json (2.6.1)
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
- parallel (1.20.1)
37
- parser (3.0.1.0)
38
+ nokogiri (1.12.5-arm64-darwin)
39
+ racc (~> 1.4)
40
+ nokogiri (1.12.5-x86_64-darwin)
41
+ racc (~> 1.4)
42
+ nokogiri (1.12.5-x86_64-linux)
43
+ racc (~> 1.4)
44
+ nori (2.6.0)
45
+ parallel (1.21.0)
46
+ parser (3.0.2.0)
38
47
  ast (~> 2.4.1)
39
- pry (0.14.0)
48
+ pry (0.14.1)
40
49
  coderay (~> 1.1)
41
50
  method_source (~> 1.0)
51
+ racc (1.6.0)
42
52
  rack (2.2.3)
43
53
  rainbow (3.0.0)
44
- rake (13.0.3)
54
+ rake (13.0.6)
45
55
  regexp_parser (2.1.1)
46
56
  rexml (3.2.5)
47
57
  rspec (3.10.0)
@@ -53,23 +63,26 @@ GEM
53
63
  rspec-expectations (3.10.1)
54
64
  diff-lcs (>= 1.2.0, < 2.0)
55
65
  rspec-support (~> 3.10.0)
66
+ rspec-json_matcher (0.1.6)
67
+ awesome_print
68
+ json
56
69
  rspec-mocks (3.10.2)
57
70
  diff-lcs (>= 1.2.0, < 2.0)
58
71
  rspec-support (~> 3.10.0)
59
72
  rspec-support (3.10.2)
60
- rubocop (1.11.0)
73
+ rubocop (1.17.0)
61
74
  parallel (~> 1.10)
62
75
  parser (>= 3.0.0.0)
63
76
  rainbow (>= 2.2.2, < 4.0)
64
77
  regexp_parser (>= 1.8, < 3.0)
65
78
  rexml
66
- rubocop-ast (>= 1.2.0, < 2.0)
79
+ rubocop-ast (>= 1.7.0, < 2.0)
67
80
  ruby-progressbar (~> 1.7)
68
81
  unicode-display_width (>= 1.4.0, < 3.0)
69
- rubocop-ast (1.4.1)
70
- parser (>= 2.7.1.5)
71
- rubocop-config-umbrellio (1.11.0.40)
72
- rubocop (= 1.11.0)
82
+ rubocop-ast (1.12.0)
83
+ parser (>= 3.0.1.1)
84
+ rubocop-config-umbrellio (1.17.0.53)
85
+ rubocop (= 1.17.0)
73
86
  rubocop-performance (= 1.10.0)
74
87
  rubocop-rails (= 2.9.1)
75
88
  rubocop-rake (= 0.5.1)
@@ -90,27 +103,32 @@ GEM
90
103
  rubocop-sequel (0.2.0)
91
104
  rubocop (~> 1.0)
92
105
  ruby-progressbar (1.11.0)
93
- ruby2_keywords (0.0.4)
94
- sequel (5.43.0)
106
+ ruby2_keywords (0.0.5)
107
+ semantic_logger (4.8.2)
108
+ concurrent-ruby (~> 1.0)
109
+ sequel (5.49.0)
95
110
  simplecov (0.21.2)
96
111
  docile (~> 1.1)
97
112
  simplecov-html (~> 0.11)
98
113
  simplecov_json_formatter (~> 0.1)
99
114
  simplecov-html (0.12.3)
100
115
  simplecov-lcov (0.8.0)
101
- simplecov_json_formatter (0.1.2)
102
- symbiont-ruby (0.6.0)
116
+ simplecov_json_formatter (0.1.3)
117
+ symbiont-ruby (0.7.0)
103
118
  thor (1.1.0)
119
+ timecop (0.9.4)
104
120
  tzinfo (2.0.4)
105
121
  concurrent-ruby (~> 1.0)
106
- umbrellio-sequel-plugins (0.4.0.164)
122
+ umbrellio-sequel-plugins (0.5.1.27)
107
123
  sequel
108
- symbiont-ruby (>= 0.6)
109
- unicode-display_width (2.0.0)
124
+ symbiont-ruby
125
+ unicode-display_width (2.1.0)
110
126
  yard (0.9.26)
111
- zeitwerk (2.4.2)
127
+ zeitwerk (2.5.1)
112
128
 
113
129
  PLATFORMS
130
+ arm64-darwin-20
131
+ x86_64-darwin-20
114
132
  x86_64-linux
115
133
 
116
134
  DEPENDENCIES
@@ -118,14 +136,19 @@ DEPENDENCIES
118
136
  bundler
119
137
  bundler-audit
120
138
  ci-helper
139
+ nokogiri
140
+ nori
121
141
  pry
122
142
  rake
123
143
  rspec
144
+ rspec-json_matcher
124
145
  rubocop-config-umbrellio
146
+ semantic_logger
125
147
  simplecov
126
148
  simplecov-lcov
149
+ timecop
127
150
  umbrellio-utils!
128
151
  yard
129
152
 
130
153
  BUNDLED WITH
131
- 2.2.15
154
+ 2.2.31
@@ -67,7 +67,9 @@ module UmbrellioUtils
67
67
  type = model.db_schema[primary_key][:db_type]
68
68
 
69
69
  DB.drop_table?(temp_table_name)
70
- DB.create_table(temp_table_name) { column primary_key, type, primary_key: true }
70
+ DB.create_table(temp_table_name, unlogged: true) do
71
+ column primary_key, type, primary_key: true
72
+ end
71
73
 
72
74
  insert_ds = dataset.select(Sequel[model.table_name][primary_key])
73
75
  DB[temp_table_name].insert(insert_ds)
@@ -21,7 +21,7 @@ module UmbrellioUtils
21
21
  xml.xpath("//@*").remove if remove_attributes
22
22
 
23
23
  tags_converter = snakecase ? -> (tag) { tag.snakecase.to_sym } : -> (tag) { tag.to_sym }
24
- nori = Nori.new(convert_tags_to: tags_converter)
24
+ nori = Nori.new(convert_tags_to: tags_converter, convert_dashes_to_underscores: false)
25
25
  nori.parse(xml.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION))
26
26
  end
27
27
 
@@ -0,0 +1,87 @@
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
+ tags: :tags,
19
+ named_tags: :named_tags,
20
+ time: :time,
21
+ }.freeze
22
+
23
+ # Returns a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}.
24
+ # @param [Hash] custom_names_mapping mapping from default field names to custom ones.
25
+ # @option custom_names_mapping [Symbol] :severity custom name for the `severity` field.
26
+ # @option custom_names_mapping [Symbol] :name custom name for the `name` field.
27
+ # @option custom_names_mapping [Symbol] :thread_fingerprint
28
+ # custom name for the thread_fingerprint field.
29
+ # @option custom_names_mapping [Symbol] :message custom name for the `message` field.
30
+ # @option custom_names_mapping [Symbol] :tags custom name for the `tags` field.
31
+ # @option custom_names_mapping [Symbol] :named_tags custom name for the `named_tags` field.
32
+ # @option custom_names_mapping [Symbol] :time custom name for the `time` field.
33
+ # @example Use custom name for the `message` and `time` fields
34
+ # UmbrellioUtils::SemanticLogger::TinyJsonFormatter.new(
35
+ # time: :timestamp, message: :note,
36
+ # ) #=> <UmbrellioUtils::SemanticLogger::TinyJsonFormatter:0x000>
37
+ # @return [UmbrellioUtils::SemanticLogger::TinyJsonFormatter]
38
+ # a new instance of the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter}
39
+ def initialize(**custom_names_mapping)
40
+ self.field_names = { **DEFAULT_NAMES_MAPPING, **custom_names_mapping }.freeze
41
+ end
42
+
43
+ # Formats log structure into the JSON string.
44
+ # @param log [SemanticLogger::Log] log's data structure.
45
+ # @param logger [SemanticLogger::Logger] active logger.
46
+ # @return [String] data
47
+ def call(log, _logger)
48
+ data = build_data_for(log)
49
+ data.to_json
50
+ end
51
+
52
+ private
53
+
54
+ # @!attribute field_names
55
+ # @return [Hash<Symbol, Symbol>] the mapping from default field names to the new ones.
56
+ attr_accessor :field_names
57
+
58
+ # Builds hash with data from log.
59
+ # @return [Hash] the hash, which will be converted to the JSON later.
60
+ def build_data_for(log)
61
+ field_names.values_at(*DEFAULT_NAMES_MAPPING.keys).zip(pack_data(log)).to_h
62
+ end
63
+
64
+ # Builds an [Array] with all the required fields, which are arranged
65
+ # in the order of the declaration of keys
66
+ # in the {UmbrellioUtils::SemanticLogger::TinyJsonFormatter::DEFAULT_NAMES_MAPPING}.
67
+ # @return [Array] an array with serialized data.
68
+ def pack_data(log)
69
+ [
70
+ log.level.upcase,
71
+ log.name,
72
+ thread_fingerprint_for(log),
73
+ log.message,
74
+ log.tags,
75
+ log.named_tags,
76
+ log.time.utc.iso8601(3),
77
+ ]
78
+ end
79
+
80
+ # Calculates MD5 fingerprint for the thread, in which the log was made.
81
+ # @return [String] truncated `MD5` hash.
82
+ def thread_fingerprint_for(log)
83
+ Digest::MD5.hexdigest("#{log.thread_name}#{Process.pid}")[0...8]
84
+ end
85
+ end
86
+ end
87
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.2"
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"
@@ -33,11 +33,16 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler"
34
34
  spec.add_development_dependency "bundler-audit"
35
35
  spec.add_development_dependency "ci-helper"
36
+ spec.add_development_dependency "nokogiri"
37
+ spec.add_development_dependency "nori"
36
38
  spec.add_development_dependency "pry"
37
39
  spec.add_development_dependency "rake"
38
40
  spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "rspec-json_matcher"
39
42
  spec.add_development_dependency "rubocop-config-umbrellio"
43
+ spec.add_development_dependency "semantic_logger"
40
44
  spec.add_development_dependency "simplecov"
41
45
  spec.add_development_dependency "simplecov-lcov"
46
+ spec.add_development_dependency "timecop"
42
47
  spec.add_development_dependency "yard"
43
48
  end
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.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustAnotherDude
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: nori
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: pry
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +150,20 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
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'
125
167
  - !ruby/object:Gem::Dependency
126
168
  name: rubocop-config-umbrellio
127
169
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +178,20 @@ dependencies:
136
178
  - - ">="
137
179
  - !ruby/object:Gem::Version
138
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'
139
195
  - !ruby/object:Gem::Dependency
140
196
  name: simplecov
141
197
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +220,20 @@ dependencies:
164
220
  - - ">="
165
221
  - !ruby/object:Gem::Version
166
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: timecop
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
167
237
  - !ruby/object:Gem::Dependency
168
238
  name: yard
169
239
  requirement: !ruby/object:Gem::Requirement
@@ -212,6 +282,7 @@ files:
212
282
  - lib/umbrellio_utils/random.rb
213
283
  - lib/umbrellio_utils/request_wrapper.rb
214
284
  - lib/umbrellio_utils/rounding.rb
285
+ - lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb
215
286
  - lib/umbrellio_utils/store.rb
216
287
  - lib/umbrellio_utils/vault.rb
217
288
  - lib/umbrellio_utils/version.rb
@@ -238,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
309
  - !ruby/object:Gem::Version
239
310
  version: '0'
240
311
  requirements: []
241
- rubygems_version: 3.2.18
312
+ rubygems_version: 3.2.31
242
313
  signing_key:
243
314
  specification_version: 4
244
315
  summary: A set of utilities that speed up development