infield 0.3.0 → 0.4.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 +0 -4
- data/lib/infield/deprecation_warning.rb +17 -11
- data/lib/infield/rails.rb +13 -2
- 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: bcc989dc4411ecacc35b71a9f831b51c7a985e550872393e68cbed78530b33cd
|
4
|
+
data.tar.gz: 9e681a218059596455a77728f371e30a016810eb3aaf608a6c0af8aa3236a9b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c361f23afc866c66338b633a7aefcf0714a0e4ec2ef5f8cccf568105751379207840eca47224ab1bf2339c16fa53e7038536ff97fba6822db9a5ed35622b57b5
|
7
|
+
data.tar.gz: 8010fcb20eb0c8f1168c1405f6f37f6e1cf8f6aaad08053cbffa493b0e43f8989f0aef0de1082f5377f9cbec823308f8672fc3cf291a37dcb155e79033b740e5
|
data/README.md
CHANGED
@@ -18,10 +18,6 @@ Then in `config/application.rb`:
|
|
18
18
|
repo_environment_id: ENV['INFIELD_REPO_ENVIRONMENT_ID'])
|
19
19
|
end
|
20
20
|
|
21
|
-
And in any environment you want to profile from:
|
22
|
-
|
23
|
-
config.active_support.deprecation = :notify
|
24
|
-
|
25
21
|
## Configuration options
|
26
22
|
|
27
23
|
The infield gem batches requests and sends them asyncronously. You can configure the following options to `Infield.run` (defaults shown here):
|
@@ -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
@@ -3,8 +3,19 @@
|
|
3
3
|
module Infield
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
initializer 'infield.deprecation_warnings', after: 'active_support.deprecation_behavior' do |_app|
|
6
|
-
|
7
|
-
Infield::DeprecationWarning.log(
|
6
|
+
infield_lambda = lambda do |message, callstack, *args|
|
7
|
+
Infield::DeprecationWarning.log(message, callstack: callstack, validated: true)
|
8
|
+
end
|
9
|
+
|
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
|
15
|
+
end
|
16
|
+
else
|
17
|
+
current_behaviors = Array(ActiveSupport::Deprecation.behavior)
|
18
|
+
ActiveSupport::Deprecation.behavior = [infield_lambda, *current_behaviors].uniq
|
8
19
|
end
|
9
20
|
end
|
10
21
|
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.4.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|