getaround_utils 0.2.23 → 0.2.25

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: d0f45f64d93dc7e5b83b2ee8612dff306880d7953c3e9026edcafe40925e7127
4
- data.tar.gz: 5bcd057a886ff3a7423841f5bc29fb491501fa3c9226658a4b17801ae6eee189
3
+ metadata.gz: 2f6dd68f18739dcc00d036bb09895bd7a9ea55cafb8b75c7b27f0fb1b9d0c9ed
4
+ data.tar.gz: 76fd9e2acedc062898d72a3f86f08c892157f3e36db8a5839025c346cd1e324e
5
5
  SHA512:
6
- metadata.gz: 98f5f63856cc9319be1d3f04e69bcf8aa5a165c48ad982ebf058a9e0faf92e31bf6dbeb1b5311f8ea89512156e508a7d3e070fbf0cfc22897958bc7279d58c06
7
- data.tar.gz: ae985999bf28745645966d3108fd0dce14fba751f4a2e53aace72f5089515ddd94d6765ae3ae3349972b69cbcd72ac73b9f5083a4ec8acbf1a3c0d532938e8f7
6
+ metadata.gz: d885550f6cc2d3d7f829696457a6cc29cc08be3118b0ab8daf66d680942d26d5ac4242bc22277c87d694f4666c215f78ae4dbf8b2a0fbb692010d82694325180
7
+ data.tar.gz: 96a3ab41e81e981db9ed51288d9bccd7fbf4f21255e80832c2fa5c924d328a660f332975b602867a7e35e7dbd4259faa42e2f9d9e2ea092a4a05fb1e88f0005f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getaround_utils (0.2.23)
4
+ getaround_utils (0.2.25)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -71,11 +71,15 @@ GEM
71
71
  builder (3.2.4)
72
72
  coderay (1.1.3)
73
73
  concurrent-ruby (1.1.10)
74
- connection_pool (2.2.5)
74
+ connection_pool (2.3.0)
75
75
  crack (0.4.5)
76
76
  rexml
77
77
  crass (1.0.6)
78
78
  diff-lcs (1.5.0)
79
+ dotenv (2.7.6)
80
+ dotenv-rails (2.7.6)
81
+ dotenv (= 2.7.6)
82
+ railties (>= 3.2)
79
83
  erubi (1.10.0)
80
84
  getaround-rubocop (0.2.7)
81
85
  relaxed-rubocop (= 2.5)
@@ -116,7 +120,7 @@ GEM
116
120
  method_source (~> 1.0)
117
121
  public_suffix (4.0.6)
118
122
  racc (1.6.0)
119
- rack (2.2.3.1)
123
+ rack (2.2.5)
120
124
  rack-test (1.1.0)
121
125
  rack (>= 1.0, < 3)
122
126
  rails (6.1.4.6)
@@ -147,7 +151,8 @@ GEM
147
151
  thor (~> 1.0)
148
152
  rainbow (3.1.1)
149
153
  rake (13.0.6)
150
- redis (4.6.0)
154
+ redis-client (0.12.0)
155
+ connection_pool
151
156
  regexp_parser (2.2.1)
152
157
  relaxed-rubocop (2.5)
153
158
  request_store (1.5.1)
@@ -191,10 +196,11 @@ GEM
191
196
  rubocop (~> 1.0)
192
197
  rubocop-ast (>= 1.1.0)
193
198
  ruby-progressbar (1.11.0)
194
- sidekiq (6.5.0)
195
- connection_pool (>= 2.2.2)
196
- rack (~> 2.0)
197
- redis (>= 4.2.0)
199
+ sidekiq (7.0.3)
200
+ concurrent-ruby (< 2)
201
+ connection_pool (>= 2.3.0)
202
+ rack (>= 2.2.4)
203
+ redis-client (>= 0.11.0)
198
204
  sprockets (4.0.2)
199
205
  concurrent-ruby (~> 1.0)
200
206
  rack (> 1, < 3)
@@ -220,6 +226,7 @@ PLATFORMS
220
226
 
221
227
  DEPENDENCIES
222
228
  bundler (~> 2.0)
229
+ dotenv-rails (~> 2.7.6)
223
230
  getaround-rubocop (= 0.2.7)
224
231
  getaround_utils!
225
232
  lograge (~> 0.12.0)
@@ -231,7 +238,7 @@ DEPENDENCIES
231
238
  rspec (~> 3.9, >= 3.9.0)
232
239
  rspec-rails (~> 5.0)
233
240
  rubocop (= 1.25.1)
234
- sidekiq (~> 6.0)
241
+ sidekiq (> 6.0, < 8.0)
235
242
  webmock (~> 3.7)
236
243
 
237
244
  BUNDLED WITH
data/README.md CHANGED
@@ -4,6 +4,31 @@ Backend shared utility classes
4
4
 
5
5
  ## Railties
6
6
 
7
+ ### GetaroundUtils::Railties::Dotenv
8
+
9
+ Enable currated .env files loading
10
+ ```
11
+ # config/application.rb
12
+ require 'getaround_utils/railties/dotenv'
13
+
14
+ GetaroundUtils::Railties::Dotenv.load
15
+ ```
16
+
17
+ Additional files can be loaded with the highed precedence via the `DOTENVS` variable, ie:
18
+ ```
19
+ DOTENVS=custom1,custom2 rails c
20
+ # Will `load` .env files in the following order:
21
+ # - `.env.custom1.local`
22
+ # - `.env.custom1`
23
+ # - `.env.custom2.local`
24
+ # - `.env.custom2`
25
+ # - `.env.<RAILS_ENV>.local`
26
+ # - `.env.<RAILS_ENV>`
27
+ # - `.env.all.local`
28
+ # - `.env.all`
29
+ # - `.env.local`
30
+ ```
31
+
7
32
  ### GetaroundUtils::Railties::Lograge
8
33
 
9
34
  Enables lograge (http logs) with favored default.
@@ -28,9 +28,10 @@ Gem::Specification.new do |gem|
28
28
  gem.add_development_dependency 'webmock', '~> 3.7'
29
29
 
30
30
  # Functional (optional) dependencies
31
+ gem.add_development_dependency 'dotenv-rails', '~> 2.7.6'
31
32
  gem.add_development_dependency 'lograge', '~> 0.12.0'
32
33
  gem.add_development_dependency 'ougai', '~> 2.0'
33
34
  gem.add_development_dependency 'rails', '~> 6.0'
34
35
  gem.add_development_dependency 'request_store_rails', '~> 2.0'
35
- gem.add_development_dependency 'sidekiq', '~> 6.0'
36
+ gem.add_development_dependency 'sidekiq', '> 6.0', "< 8.0"
36
37
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/railtie'
4
+
5
+ module GetaroundUtils; end
6
+
7
+ module GetaroundUtils::Railties; end
8
+
9
+ class GetaroundUtils::Railties::Dotenv < Rails::Railtie
10
+ def load
11
+ if ENV['DOTENVS'].present?
12
+ overrides = ENV['DOTENVS'].split(',').map{ |n| [".env.#{n}.local", ".env.#{n}"] }.flatten
13
+ warn('=' * 100)
14
+ warn("⚠️ ENV is overriden with the following profiles: #{overrides}")
15
+ warn('=' * 100)
16
+ Dotenv.load(*overrides)
17
+ end
18
+ Dotenv::Railtie.load
19
+ Dotenv.load('.env.all', '.env.all.local')
20
+ nil
21
+ end
22
+ end
@@ -13,7 +13,12 @@ module GetaroundUtils::Railties; end
13
13
  # https://github.com/tilfin/ougai/wiki/Use-as-Rails-logger#define-a-custom-logger
14
14
  class OugaiRailsLogger < Ougai::Logger
15
15
  include ActiveSupport::LoggerThreadSafeLevel
16
- include Rails::VERSION::MAJOR < 6 ? LoggerSilence : ActiveSupport::LoggerSilence
16
+ include ActiveSupport::LoggerSilence
17
+
18
+ def initialize(*args)
19
+ super
20
+ after_initialize if respond_to?(:after_initialize) && ActiveSupport::VERSION::MAJOR < 6
21
+ end
17
22
  end
18
23
 
19
24
  # Patch for ActiveSupport::TaggedLogging
@@ -46,14 +51,14 @@ end
46
51
 
47
52
  class GetaroundUtils::Railties::Ougai < Rails::Railtie
48
53
  config.ougai_logger = OugaiRailsLogger.new($stdout)
49
- config.ougai_logger.after_initialize if Rails::VERSION::MAJOR < 6
50
54
  config.ougai_logger.formatter = GetaroundUtils::Ougai::JsonFormatter.new
55
+
51
56
  config.ougai_logger.before_log = lambda do |data|
52
- request_store = RequestStore.store[:ougai] || {}
53
- data.deep_merge!(request_store) if request_store&.any?
57
+ data.deep_merge!(RequestStore.store[:ougai]) \
58
+ if defined?(RequestStore) && RequestStore.store.key?(:ougai)
54
59
 
55
- sidekiq_context = Thread.current[:sidekiq_context] || {}
56
- data.merge!(sidekiq: sidekiq_context) if sidekiq_context&.any?
60
+ data.merge!(sidekiq: Thread.current[:sidekiq_context]) \
61
+ if defined?(Sidekiq) && Thread.current.key?(:sidekiq_context)
57
62
  end
58
63
 
59
64
  initializer :getaround_utils_ougai, before: :initialize_logger do |app|
@@ -61,16 +66,17 @@ class GetaroundUtils::Railties::Ougai < Rails::Railtie
61
66
  end
62
67
 
63
68
  initializer :getaround_utils_ougai_middleware do |app|
64
- app.config.app_middleware.insert_after ActionDispatch::RequestId, OugaiRequestStoreMiddleware
69
+ app.config.app_middleware.insert_after(ActionDispatch::RequestId, OugaiRequestStoreMiddleware)
65
70
  end
66
71
 
67
72
  initializer :getaround_utils_ougai_activesupport do
68
- ActiveSupport::TaggedLogging::Formatter.prepend OugaiTaggedLoggingFormatter
73
+ ActiveSupport::TaggedLogging::Formatter.prepend(OugaiTaggedLoggingFormatter)
69
74
  end
70
75
 
71
76
  initializer :getaround_utils_ougai_lograge do |app|
72
77
  next unless defined?(Lograge)
73
78
 
79
+ # https://github.com/tilfin/ougai/wiki/Use-as-Rails-logger#with-lograge
74
80
  app.config.lograge.logger = app.config.logger
75
81
  app.config.lograge.formatter = Lograge::Formatters::Raw.new
76
82
  end
@@ -79,9 +85,13 @@ class GetaroundUtils::Railties::Ougai < Rails::Railtie
79
85
  next unless defined?(Sidekiq)
80
86
 
81
87
  # https://github.com/tilfin/ougai/wiki/Customize-Sidekiq-logger
82
- Sidekiq.logger = config.ougai_logger
88
+ Sidekiq.configure_client do |config|
89
+ config.logger = Rails.application.config.logger
90
+ end
83
91
 
84
92
  Sidekiq.configure_server do |config|
93
+ config.logger = Rails.application.config.logger
94
+
85
95
  original_handler = config.error_handlers.shift
86
96
  config.error_handlers << lambda do |ex, ctx|
87
97
  if Sidekiq.logger.is_a?(Ougai::Logger)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GetaroundUtils
4
- VERSION = '0.2.23'
4
+ VERSION = '0.2.25'
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getaround_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.23
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy
8
8
  - Laurent Humez
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-14 00:00:00.000000000 Z
12
+ date: 2023-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -129,6 +129,20 @@ dependencies:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '3.7'
132
+ - !ruby/object:Gem::Dependency
133
+ name: dotenv-rails
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.7.6
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.7.6
132
146
  - !ruby/object:Gem::Dependency
133
147
  name: lograge
134
148
  requirement: !ruby/object:Gem::Requirement
@@ -189,16 +203,22 @@ dependencies:
189
203
  name: sidekiq
190
204
  requirement: !ruby/object:Gem::Requirement
191
205
  requirements:
192
- - - "~>"
206
+ - - ">"
193
207
  - !ruby/object:Gem::Version
194
208
  version: '6.0'
209
+ - - "<"
210
+ - !ruby/object:Gem::Version
211
+ version: '8.0'
195
212
  type: :development
196
213
  prerelease: false
197
214
  version_requirements: !ruby/object:Gem::Requirement
198
215
  requirements:
199
- - - "~>"
216
+ - - ">"
200
217
  - !ruby/object:Gem::Version
201
218
  version: '6.0'
219
+ - - "<"
220
+ - !ruby/object:Gem::Version
221
+ version: '8.0'
202
222
  description: Shared base utility classes for Getaround Backend Applications.
203
223
  email:
204
224
  - oss@drivy.com
@@ -218,6 +238,7 @@ files:
218
238
  - lib/getaround_utils/ougai.rb
219
239
  - lib/getaround_utils/ougai/deep_key_value_formatter.rb
220
240
  - lib/getaround_utils/ougai/json_formatter.rb
241
+ - lib/getaround_utils/railties/dotenv.rb
221
242
  - lib/getaround_utils/railties/lograge.rb
222
243
  - lib/getaround_utils/railties/ougai.rb
223
244
  - lib/getaround_utils/utils.rb
@@ -227,7 +248,7 @@ homepage: https://github.com/drivy
227
248
  licenses:
228
249
  - MIT
229
250
  metadata: {}
230
- post_install_message:
251
+ post_install_message:
231
252
  rdoc_options: []
232
253
  require_paths:
233
254
  - lib
@@ -243,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
264
  version: '0'
244
265
  requirements: []
245
266
  rubygems_version: 3.1.6
246
- signing_key:
267
+ signing_key:
247
268
  specification_version: 4
248
269
  summary: Backend shared utility classes
249
270
  test_files: []