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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcc989dc4411ecacc35b71a9f831b51c7a985e550872393e68cbed78530b33cd
4
- data.tar.gz: 9e681a218059596455a77728f371e30a016810eb3aaf608a6c0af8aa3236a9b2
3
+ metadata.gz: 40b2ea1440f22cf0a3903a0721877fb549af9d0e9b61e89a2e8d2661468e7054
4
+ data.tar.gz: 823480341aa7ff458e022d2cfb97f1be29f4506d9277032e97e26903d1c0da9c
5
5
  SHA512:
6
- metadata.gz: c361f23afc866c66338b633a7aefcf0714a0e4ec2ef5f8cccf568105751379207840eca47224ab1bf2339c16fa53e7038536ff97fba6822db9a5ed35622b57b5
7
- data.tar.gz: 8010fcb20eb0c8f1168c1405f6f37f6e1cf8f6aaad08053cbffa493b0e43f8989f0aef0de1082f5377f9cbec823308f8672fc3cf291a37dcb155e79033b740e5
6
+ metadata.gz: 1f082d9c16381d0bd11c70f96e88df49e840bcc255a7da8d484fb7217e63a18992c77aca10f4ac97429105421a558ce322a31b8cd07f279df12c17db9b9452fc
7
+ data.tar.gz: 774a4584663751d8dbf5cf6cbc8aed16606a4b2a497c4b660d808b0864acd43f6ab06903e1c87dd8b02c4581f2793e123f9734458d6ec3ed9ed3203bed182425
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2025-04-10
4
+
5
+ - Bypass Webmock in test environments.
6
+
3
7
  ## [0.1.0] - 2023-11-14
4
8
 
5
9
  - Initial release
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.deprecation_warnings', after: 'active_support.deprecation_behavior' do |_app|
6
- infield_lambda = lambda do |message, callstack, *args|
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.0 makes it so that there are named deprecators that can have their own behavior
11
- if Rails.application.respond_to?(:deprecators)
12
- Rails.application.deprecators.each do |deprecator|
13
- current = Array(deprecator.behavior)
14
- deprecator.behavior = [infield_lambda, *current].uniq
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 = [infield_lambda, *current_behaviors].uniq
25
+ ActiveSupport::Deprecation.behavior = [infield_logger, *current_behaviors].uniq
19
26
  end
20
27
  end
21
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Infield
4
- VERSION = '0.4.0'
4
+ VERSION = '0.6.0'
5
5
  end
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.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-02-14 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock