infield 0.3.0 → 0.5.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/README.md +2 -3
- data/lib/infield/deprecation_warning.rb +17 -11
- data/lib/infield/rails.rb +21 -3
- 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: 706e3b8eb5b4a5eb812a3212a8c681021d35e0f3c5793a4ea41bbe0cf142cf9f
|
4
|
+
data.tar.gz: 142dc03b525827beb632755d9700f9f8d47542d094b1e5ae07d1b7858b8f3a36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa4027787cfbccc543b2bf8b662b59e522908926776a14ee4d5cb11e86acb41d643c87d37dabb353c9166c636418f7b1b469325825b72bb2f3f244979347ba0
|
7
|
+
data.tar.gz: ae9611ddc2352b8af6451b1842dec24d0e1487d1744c0b24d5aa29305aa59dd606fe146c33ad6ed29994d224e7de5f75a7317054150511aa2e55cc69df86d640
|
data/README.md
CHANGED
@@ -18,9 +18,8 @@ Then in `config/application.rb`:
|
|
18
18
|
repo_environment_id: ENV['INFIELD_REPO_ENVIRONMENT_ID'])
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
config.active_support.deprecation = :notify
|
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`
|
24
23
|
|
25
24
|
## Configuration options
|
26
25
|
|
@@ -44,6 +44,23 @@ module Infield
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def post_deprecation_warnings(tasks)
|
48
|
+
messages = tasks.map { |w| { message: w.message, callstack: w.callstack.map(&:to_s) } }
|
49
|
+
|
50
|
+
uri = infield_api_uri
|
51
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
52
|
+
http.post('/api/raw_deprecation_warnings',
|
53
|
+
{ raw_deprecation_warnings: {
|
54
|
+
repo_environment_id: Infield.repo_environment_id,
|
55
|
+
environment: Infield.environment,
|
56
|
+
messages: messages
|
57
|
+
}
|
58
|
+
}.to_json,
|
59
|
+
{ 'Content-Type' => 'application/json', 'Authorization' => "bearer #{Infield.api_key}" })
|
60
|
+
end
|
61
|
+
rescue *HTTP_ERRORS => e
|
62
|
+
end
|
63
|
+
|
47
64
|
private
|
48
65
|
|
49
66
|
def process_queue
|
@@ -62,17 +79,6 @@ module Infield
|
|
62
79
|
def infield_api_uri
|
63
80
|
URI.parse(Infield.infield_api_url)
|
64
81
|
end
|
65
|
-
|
66
|
-
def post_deprecation_warnings(tasks)
|
67
|
-
messages = tasks.map { |w| { message: w.message } }
|
68
|
-
uri = infield_api_uri
|
69
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
70
|
-
http.post('/api/raw_deprecation_warnings',
|
71
|
-
default_api_params.merge(messages: messages).to_json,
|
72
|
-
{ 'Content-Type' => 'application/json', 'Authorization' => "bearer #{Infield.api_key}" })
|
73
|
-
end
|
74
|
-
rescue *HTTP_ERRORS => e
|
75
|
-
end
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
data/lib/infield/rails.rb
CHANGED
@@ -2,9 +2,27 @@
|
|
2
2
|
|
3
3
|
module Infield
|
4
4
|
class Railtie < Rails::Railtie
|
5
|
-
initializer 'infield.
|
6
|
-
|
7
|
-
|
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|
|
14
|
+
Infield::DeprecationWarning.log(message, callstack: callstack, validated: true)
|
15
|
+
end
|
16
|
+
|
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
|
22
|
+
end
|
23
|
+
else
|
24
|
+
current_behaviors = Array(ActiveSupport::Deprecation.behavior)
|
25
|
+
ActiveSupport::Deprecation.behavior = [infield_logger, *current_behaviors].uniq
|
8
26
|
end
|
9
27
|
end
|
10
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.5.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-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|