faraday 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/faraday.rb +1 -1
- data/lib/faraday/deprecated_constant.rb +53 -0
- data/lib/faraday/error.rb +14 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23562bbe34d7ac60c8cc99bbebd129ef82a007fd58427e9f55150d7dd0bc62d4
|
4
|
+
data.tar.gz: ec487ada8a75259f37a33615826112abe255186ee313467145361f3d42c65fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37fe1268b37bb7841a0cf46175ff819fadcdb88d776ccb0ce67d1fa7c9527c29e3896d30960ed75da02df73a5ec6f93af32aaf2d959fe9546f37110988a03cb8
|
7
|
+
data.tar.gz: 200da4c8d47cbbd9635e326d062d3be7c25f68451bc8fb82463f0b5803a42682d08cec4891c5910013723a3b57c2dc517103d2b6424706cf7f5bcf73810706b7
|
data/lib/faraday.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faraday
|
4
|
+
# Allows for the deprecation of constants between versions of Faraday
|
5
|
+
#
|
6
|
+
# rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
7
|
+
class DeprecatedConstant < Module
|
8
|
+
def self.new(*args, &block)
|
9
|
+
object = args.first
|
10
|
+
return object unless object
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(old_const, new_const)
|
16
|
+
@old_const = old_const
|
17
|
+
@new_const = new_const
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO: use match? once Faraday drops Ruby 2.3 support
|
21
|
+
instance_methods.each do |method_name|
|
22
|
+
undef_method method_name if /^__|^object_id$/.match(method_name).nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def inspect
|
26
|
+
@new_const.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
def class
|
30
|
+
@new_const.class
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def const_missing(name)
|
36
|
+
warn
|
37
|
+
@new_const.const_get(name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def method_missing(method_name, *args, &block)
|
41
|
+
warn
|
42
|
+
@new_const.__send__(method_name, *args, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def warn
|
46
|
+
puts(
|
47
|
+
"DEPRECATION WARNING: #{@old_const} is deprecated! " \
|
48
|
+
"Use #{@new_const} instead."
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
# rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
53
|
+
end
|
data/lib/faraday/error.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'faraday/deprecated_constant'
|
4
|
+
|
5
|
+
# Faraday namespace.
|
3
6
|
module Faraday
|
4
7
|
# Faraday error base class.
|
5
8
|
class Error < StandardError
|
@@ -97,4 +100,15 @@ module Faraday
|
|
97
100
|
# @see Faraday::Request::Retry
|
98
101
|
class RetriableResponse < Error
|
99
102
|
end
|
103
|
+
|
104
|
+
%i[ClientError ConnectionFailed ResourceNotFound
|
105
|
+
ParsingError TimeoutError SSLError RetriableResponse].each do |const|
|
106
|
+
Error.const_set(
|
107
|
+
const,
|
108
|
+
Faraday::DeprecatedConstant.new(
|
109
|
+
"Faraday::Error::#{const}",
|
110
|
+
Faraday.const_get(const)
|
111
|
+
)
|
112
|
+
)
|
113
|
+
end
|
100
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olson
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/faraday/autoload.rb
|
57
57
|
- lib/faraday/connection.rb
|
58
58
|
- lib/faraday/dependency_loader.rb
|
59
|
+
- lib/faraday/deprecated_constant.rb
|
59
60
|
- lib/faraday/encoders/flat_params_encoder.rb
|
60
61
|
- lib/faraday/encoders/nested_params_encoder.rb
|
61
62
|
- lib/faraday/error.rb
|