infield 0.4.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -0
- data/lib/infield/deprecation_warning.rb +13 -0
- data/lib/infield/rails.rb +15 -8
- data/lib/infield/version.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: 40b2ea1440f22cf0a3903a0721877fb549af9d0e9b61e89a2e8d2661468e7054
|
4
|
+
data.tar.gz: 823480341aa7ff458e022d2cfb97f1be29f4506d9277032e97e26903d1c0da9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f082d9c16381d0bd11c70f96e88df49e840bcc255a7da8d484fb7217e63a18992c77aca10f4ac97429105421a558ce322a31b8cd07f279df12c17db9b9452fc
|
7
|
+
data.tar.gz: 774a4584663751d8dbf5cf6cbc8aed16606a4b2a497c4b660d808b0864acd43f6ab06903e1c87dd8b02c4581f2793e123f9734458d6ec3ed9ed3203bed182425
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,9 @@ Then in `config/application.rb`:
|
|
18
18
|
repo_environment_id: ENV['INFIELD_REPO_ENVIRONMENT_ID'])
|
19
19
|
end
|
20
20
|
|
21
|
+
Only call `Infield.run` in environments that you want deprecation warnings to print for, since it will bypass configurations such as `config.active_support.report_deprecations = false`
|
22
|
+
and `config.active_support.deprecation = :silence`
|
23
|
+
|
21
24
|
## Configuration options
|
22
25
|
|
23
26
|
The infield gem batches requests and sends them asyncronously. You can configure the following options to `Infield.run` (defaults shown here):
|
@@ -48,6 +48,15 @@ module Infield
|
|
48
48
|
messages = tasks.map { |w| { message: w.message, callstack: w.callstack.map(&:to_s) } }
|
49
49
|
|
50
50
|
uri = infield_api_uri
|
51
|
+
|
52
|
+
webmock_needs_re_enabling = false
|
53
|
+
if defined?(WebMock) && WebMock.respond_to?(:net_connect_allowed?) &&
|
54
|
+
!WebMock.net_connect_allowed?(Infield.infield_api_url)
|
55
|
+
webmock_needs_re_enabling = true
|
56
|
+
allowed = WebMock::Config.instance.allow
|
57
|
+
WebMock.disable_net_connect!(allow: Infield.infield_api_url)
|
58
|
+
end
|
59
|
+
|
51
60
|
Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
52
61
|
http.post('/api/raw_deprecation_warnings',
|
53
62
|
{ raw_deprecation_warnings: {
|
@@ -59,6 +68,10 @@ module Infield
|
|
59
68
|
{ 'Content-Type' => 'application/json', 'Authorization' => "bearer #{Infield.api_key}" })
|
60
69
|
end
|
61
70
|
rescue *HTTP_ERRORS => e
|
71
|
+
ensure
|
72
|
+
if webmock_needs_re_enabling
|
73
|
+
WebMock.disable_net_connect!(allow: allowed)
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
private
|
data/lib/infield/rails.rb
CHANGED
@@ -2,20 +2,27 @@
|
|
2
2
|
|
3
3
|
module Infield
|
4
4
|
class Railtie < Rails::Railtie
|
5
|
-
initializer 'infield.
|
6
|
-
|
5
|
+
initializer 'infield.enable_report_deprecations', before: 'active_support.deprecation_behavior' do |app|
|
6
|
+
app.config.active_support.report_deprecations = true
|
7
|
+
if defined?(ActiveSupport::Deprecation.silenced)
|
8
|
+
ActiveSupport::Deprecation.silenced = false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer 'infield.deprecation_warnings', after: 'active_support.deprecation_behavior' do |app|
|
13
|
+
infield_logger = lambda do |message, callstack, *_args|
|
7
14
|
Infield::DeprecationWarning.log(message, callstack: callstack, validated: true)
|
8
15
|
end
|
9
16
|
|
10
|
-
# Rails >= 7.
|
11
|
-
if
|
12
|
-
|
13
|
-
|
14
|
-
deprecator.behavior = [
|
17
|
+
# Rails >= 7.1 makes it so that there are named deprecators that can have their own behavior
|
18
|
+
if app.respond_to?(:deprecators)
|
19
|
+
app.deprecators.each do |deprecator|
|
20
|
+
current_behaviors = Array(deprecator.behavior)
|
21
|
+
deprecator.behavior = [infield_logger, *current_behaviors].uniq
|
15
22
|
end
|
16
23
|
else
|
17
24
|
current_behaviors = Array(ActiveSupport::Deprecation.behavior)
|
18
|
-
ActiveSupport::Deprecation.behavior = [
|
25
|
+
ActiveSupport::Deprecation.behavior = [infield_logger, *current_behaviors].uniq
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
data/lib/infield/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Infield
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|