better-faraday 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +4 -0
- data/better-faraday.gemspec +1 -1
- data/lib/better-faraday.rb +14 -11
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c10f80bd720f60bad4cef31fa82b7eb35eff291c7375c6b16afecaeeea768b
|
4
|
+
data.tar.gz: f22d48fb3b8f72bce97751e66562e7bc5afe16ccc4236a4d1ac2b02dce214bc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ced29c94068d38cc9e648639af9e1f41522527fdae7374042b6e61316b935410d0d5231e720957f260fd53f07e92d0c99575e330a9888438ace0e8c15960051
|
7
|
+
data.tar.gz: dc784bf72977b0e0e5591e5b01f33833235619c261a2d12a5424b37e81180355f215bb354e0a0a897b6b904f94cd476649eb578ca9f00d0e83d31472dc89b929
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.1
|
data/README.md
CHANGED
data/better-faraday.gemspec
CHANGED
data/lib/better-faraday.rb
CHANGED
@@ -7,6 +7,7 @@ require "faraday/error"
|
|
7
7
|
require "faraday/options"
|
8
8
|
require "faraday/response"
|
9
9
|
require "active_support/core_ext/object/deep_dup"
|
10
|
+
require "active_support/core_ext/string/filters"
|
10
11
|
|
11
12
|
Module.new do
|
12
13
|
def run_request(method, url, body, headers, &block)
|
@@ -46,7 +47,7 @@ module Faraday
|
|
46
47
|
request_json = parse_json(env.request_body)
|
47
48
|
response_headers = ::Hash === env.response_headers ? env.response_headers.deep_dup : {}
|
48
49
|
response_json = parse_json(env.body)
|
49
|
-
[request_headers, request_json, response_headers, response_json].compact.each
|
50
|
+
[request_headers, request_json, response_headers, response_json].compact.each(&method(:protect!))
|
50
51
|
|
51
52
|
[ "",
|
52
53
|
"-- #{status} #{reason_phrase} --",
|
@@ -58,16 +59,16 @@ module Faraday
|
|
58
59
|
env.method.to_s.upcase,
|
59
60
|
"",
|
60
61
|
"-- Request headers --",
|
61
|
-
::JSON.generate(request_headers),
|
62
|
+
::JSON.generate(request_headers).yield_self { |t| t.truncate(1024, omission: "... (truncated, full length: #{t.length})") },
|
62
63
|
"",
|
63
64
|
"-- Request body --",
|
64
|
-
request_json ? ::JSON.generate(request_json) : env.request_body.to_s,
|
65
|
+
(request_json ? ::JSON.generate(request_json) : env.request_body.to_s).yield_self { |t| t.truncate(1024, omission: "... (truncated, full length: #{t.length})") },
|
65
66
|
"",
|
66
67
|
"-- Response headers --",
|
67
|
-
response_headers ? ::JSON.generate(response_headers) : env.response_headers.to_s,
|
68
|
+
(response_headers ? ::JSON.generate(response_headers) : env.response_headers.to_s).yield_self { |t| t.truncate(1024, omission: "... (truncated, full length: #{t.length})") },
|
68
69
|
"",
|
69
70
|
"-- Response body --",
|
70
|
-
response_json ? ::JSON.generate(response_json) : env.body.to_s,
|
71
|
+
(response_json ? ::JSON.generate(response_json) : env.body.to_s).yield_self { |t| t.truncate(1024, omission: "... (truncated, full length: #{t.length})") },
|
71
72
|
""
|
72
73
|
].join("\n")
|
73
74
|
end
|
@@ -75,15 +76,17 @@ module Faraday
|
|
75
76
|
private
|
76
77
|
|
77
78
|
def parse_json(json)
|
78
|
-
::JSON.parse(::String === json ? json : json.to_s
|
79
|
+
data = ::JSON.parse(::String === json ? json : json.to_s)
|
80
|
+
data if ::Hash === data || ::Array === data
|
79
81
|
rescue ::JSON::ParserError
|
80
82
|
nil
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
def protect!(x)
|
86
|
+
return x.map!(&method(:protect!)) if ::Array === x
|
87
|
+
x.keys.each do |k|
|
88
|
+
x[k] = "SECRET" if k.respond_to?(:=~) && Faraday.secrets.any? { |s| k =~ s }
|
89
|
+
protect!(x[k]) if ::Hash === x[k]
|
87
90
|
end
|
88
91
|
end
|
89
92
|
end
|
@@ -100,5 +103,5 @@ module Faraday
|
|
100
103
|
attr_accessor :secrets
|
101
104
|
end
|
102
105
|
|
103
|
-
self.secrets = [
|
106
|
+
self.secrets = [/\bpass(?:word|phrase)\b/i, /\bauthorization\b/i, /\bsecret\b/i, /\b(:?access?)token\b/i]
|
104
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better-faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -76,8 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.7.6
|
79
|
+
rubygems_version: 3.0.1
|
81
80
|
signing_key:
|
82
81
|
specification_version: 4
|
83
82
|
summary: Extends Faraday with useful features.
|