faraday_middleware 1.0.0 → 1.1.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: f76d03406442ddda70b51f788761197c2c78073134a684acf4a99abf24f03eb5
4
- data.tar.gz: 0e2f92c6ea632aae478af7787dfbfc83765f80bbc78670be7e0e6d1b4706d721
3
+ metadata.gz: 8b061911e8925a657ce571d5d3a096e6a9b43e8abcca0bec121fc81edb3b65c7
4
+ data.tar.gz: 4722349158a61b9ee4789fc1046596ac80a44a7dd76eba178cb32330a5583a9b
5
5
  SHA512:
6
- metadata.gz: 6b4c9ac7430a3adca03f1911293ed6563be4d189b16b27d9096e77b6aae29c5cd634e0daf1667b69c222e427386da67be00e8eefbb9f0aeed749b146d1bc5187
7
- data.tar.gz: 8959ff3fc916216ba8cf2ef713f140a77400ca74b200e703557f2b09a091c40bdfc62e9457e956ce95cc7a99c0060d8e93407d77158e28a174f16d66a5ca3b74
6
+ metadata.gz: 3d331ca5a71fda7702da83967033355c6ad896ea6026af78e248bf21c027a7f4287ab117ae81cb9dad0c0dc2d50eaaba1ab1a02f6a54a15436970e9c4232306f
7
+ data.tar.gz: 49b8a45c1aa7e06764bc5433b83f469544c509c7c372bc986dadd497dd987054d5e02160d5019679b23acd068b32bd7c86c09498f2e29b9ccdca6376b316f634
data/README.md CHANGED
@@ -2,7 +2,6 @@ Faraday Middleware
2
2
  ==================
3
3
  [![Gem Version](https://badge.fury.io/rb/faraday_middleware.svg)](https://rubygems.org/gems/faraday_middleware)
4
4
  ![GitHub Actions CI](https://github.com/lostisland/faraday_middleware/workflows/CI/badge.svg)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/a971ee5025b269c39d93/maintainability)](https://codeclimate.com/github/lostisland/faraday_middleware/maintainability)
6
5
 
7
6
  A collection of useful [Faraday][] middleware. [See the documentation][docs].
8
7
 
@@ -19,12 +18,12 @@ Some dependent libraries are needed only when using specific middleware:
19
18
 
20
19
  | Middleware | Library | Notes |
21
20
  | --------------------------- | -------------- | ----- |
22
- | [FaradayMiddleware::Instrumentation](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/instrumentation.rb) | [`activesupport`](https://rubygems.org/gems/activesupport) | |
23
- | [FaradayMiddleware::OAuth](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/request/oauth.rb) | [`simple_oauth`](https://rubygems.org/gems/simple_oauth) | |
24
- | [FaradayMiddleware::ParseXml](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/parse_xml.rb) | [`multi_xml`](https://rubygems.org/gems/multi_xml) | |
25
- | [FaradayMiddleware::ParseYaml](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/parse_yaml.rb) | [`safe_yaml`](https://rubygems.org/gems/safe_yaml) | Not backwards compatible with versions of this middleware prior to `faraday_middleware` v0.12. See code comments for alternatives. |
26
- | [FaradayMiddleware::Mashify](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/mashify.rb) | [`hashie`](https://rubygems.org/gems/hashie) | |
27
- | [FaradayMiddleware::Rashify](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/rashify.rb) | [`rash_alt`](https://rubygems.org/gems/rash_alt) | Make sure to uninstall original `rash` gem to avoid conflict. |
21
+ | [FaradayMiddleware::Instrumentation](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/instrumentation.rb) | [`activesupport`](https://rubygems.org/gems/activesupport) | |
22
+ | [FaradayMiddleware::OAuth](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/request/oauth.rb) | [`simple_oauth`](https://rubygems.org/gems/simple_oauth) | |
23
+ | [FaradayMiddleware::ParseXml](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/parse_xml.rb) | [`multi_xml`](https://rubygems.org/gems/multi_xml) | |
24
+ | [FaradayMiddleware::ParseYaml](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/parse_yaml.rb) | [`safe_yaml`](https://rubygems.org/gems/safe_yaml) | Not backwards compatible with versions of this middleware prior to `faraday_middleware` v0.12. See code comments for alternatives. |
25
+ | [FaradayMiddleware::Mashify](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/mashify.rb) | [`hashie`](https://rubygems.org/gems/hashie) | |
26
+ | [FaradayMiddleware::Rashify](https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/rashify.rb) | [`rash_alt`](https://rubygems.org/gems/rash_alt) | Make sure to uninstall original `rash` gem to avoid conflict. |
28
27
 
29
28
  Examples
30
29
  --------
@@ -80,9 +80,7 @@ module FaradayMiddleware
80
80
  def finalize_response(env, rack_response)
81
81
  status, headers, body = rack_response
82
82
  body = body.inject { |str, part| str << part }
83
- unless headers.is_a?(Faraday::Utils::Headers)
84
- headers = Faraday::Utils::Headers.new(headers)
85
- end
83
+ headers = Faraday::Utils::Headers.new(headers) unless headers.is_a?(Faraday::Utils::Headers)
86
84
 
87
85
  env.update status: status.to_i,
88
86
  body: body,
@@ -27,7 +27,7 @@ module FaradayMiddleware
27
27
  end
28
28
 
29
29
  def encode(data)
30
- ::JSON.dump data
30
+ ::JSON.generate data
31
31
  end
32
32
 
33
33
  def match_content_type(env)
@@ -38,9 +38,7 @@ module FaradayMiddleware
38
38
  end
39
39
 
40
40
  def call(env)
41
- if sign_request?(env)
42
- env[:request_headers][AUTH_HEADER] ||= oauth_header(env).to_s
43
- end
41
+ env[:request_headers][AUTH_HEADER] ||= oauth_header(env).to_s if sign_request?(env)
44
42
  @app.call(env)
45
43
  end
46
44
 
@@ -63,9 +63,7 @@ module FaradayMiddleware
63
63
  @param_name = options.fetch(:param_name, PARAM_NAME).to_s
64
64
  @token_type = options.fetch(:token_type, TOKEN_TYPE).to_s
65
65
 
66
- if @token_type == 'param' && @param_name.empty?
67
- raise ArgumentError, ":param_name can't be blank"
68
- end
66
+ raise ArgumentError, ":param_name can't be blank" if @token_type == 'param' && @param_name.empty?
69
67
 
70
68
  return unless options[:token_type].nil?
71
69
 
@@ -8,6 +8,7 @@ module FaradayMiddleware
8
8
  # Public: Caches GET responses and pulls subsequent ones from the cache.
9
9
  class Caching < Faraday::Middleware
10
10
  attr_reader :cache
11
+
11
12
  # Internal: List of status codes that can be cached:
12
13
  # * 200 - 'OK'
13
14
  # * 203 - 'Non-Authoritative Information'
@@ -133,7 +133,7 @@ module FaradayMiddleware
133
133
  def safe_escape(uri)
134
134
  uri = uri.split('#')[0] # we want to remove the fragment if present
135
135
  uri.to_s.gsub(URI_UNSAFE) do |match|
136
- '%' + match.unpack('H2' * match.bytesize).join('%').upcase
136
+ "%#{match.unpack('H2' * match.bytesize).join('%').upcase}"
137
137
  end
138
138
  end
139
139
 
@@ -34,9 +34,7 @@ module FaradayMiddleware
34
34
 
35
35
  def call(environment)
36
36
  @app.call(environment).on_complete do |env|
37
- if process_response_type?(response_type(env)) && parse_response?(env)
38
- process_response(env)
39
- end
37
+ process_response(env) if process_response_type?(response_type(env)) && parse_response?(env)
40
38
  end
41
39
  end
42
40
 
@@ -44,7 +42,7 @@ module FaradayMiddleware
44
42
  env[:raw_body] = env[:body] if preserve_raw?(env)
45
43
  env[:body] = parse(env[:body])
46
44
  rescue Faraday::ParsingError => e
47
- raise Faraday::ParsingError.new(e, env[:response])
45
+ raise Faraday::ParsingError.new(e.wrapped_exception, env[:response])
48
46
  end
49
47
 
50
48
  # Parse the response body.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Main FaradayMiddleware module.
4
4
  module FaradayMiddleware
5
- VERSION = '1.0.0' unless defined?(FaradayMiddleware::VERSION)
5
+ VERSION = '1.1.0' unless defined?(FaradayMiddleware::VERSION)
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-29 00:00:00.000000000 Z
12
+ date: 2021-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.0.3
79
+ rubygems_version: 3.0.3.1
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Various middleware for Faraday