faraday-decode_xml 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5e8f93f1f209d40769df5d7e4640fb0404f93bd5bad1fb3328adb881cc39287
4
- data.tar.gz: ba7f2175421923848d07b7e771b8b7b43b65143fb7d469e76eef1b11fba924e3
3
+ metadata.gz: 8bdc97af12131dc407e82f530448e9445f5e45664df4f9775c67160850d8265b
4
+ data.tar.gz: 9dec632278e082e185b81033a1eba5164ce1776c6ae7d048ea0917dcf3c7cc71
5
5
  SHA512:
6
- metadata.gz: 1aa64a17b8375e53d56bfb7aa473ce299b3242a4a41244a4d482f30b38d79f4610de66488a95b2d821c593797dc14460814d42dd0c45cb286212b353b5d135b3
7
- data.tar.gz: 26f732f6529bd5df02c58f71f841a97532f13ff97b9e15d9c3b65478463aaa3946e197593ac719ae8d0333c59778aaf747d6daea0337a9fca15960e4daf3d30e
6
+ metadata.gz: d94975a292401e7e66ae6f08d16ff79628a51ebb37f0c69f370aa1b85fb4857a11fdea9da08a35fb76d84e73b5bdaef39d8582493495a4b1cc1ed33ae360fb08
7
+ data.tar.gz: d5798b5564f3bbfa9956953ac17eadfc138809a8f400c1909e9b904f03ed84a2dfd7a3c56480152693e52554fb7cdbef96ffc19ee6e5480ff372c2e1a9f28ffb
data/CHANGELOG.md CHANGED
@@ -2,4 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- * Initial release.
5
+ ## 0.2.0
6
+
7
+ - Add support for specifying content types to attempt to parse (#2)
8
+
9
+ ## 0.1.1
10
+
11
+ - Relax faraday dependency (#1)
12
+
13
+ ## 0.1.0
14
+
15
+ - Initial release.
@@ -6,6 +6,11 @@ module Faraday
6
6
  module DecodeXML
7
7
  # Faraday middleware for decoding XML requests.
8
8
  class Middleware < Faraday::Middleware
9
+ def initialize(app = nil, content_type: /\bxml$/)
10
+ super(app)
11
+ @content_types = Array(content_type)
12
+ end
13
+
9
14
  # @param env [Faraday::Env] the environment of the response being processed.
10
15
  def on_complete(env)
11
16
  process_response(env) if process_response_type?(response_type(env)) && parse_response?(env)
@@ -32,7 +37,9 @@ module Faraday
32
37
  end
33
38
 
34
39
  def process_response_type?(type)
35
- type == 'application/xml'
40
+ @content_types.empty? || @content_types.any? do |pattern|
41
+ pattern.is_a?(Regexp) ? type.match?(pattern) : type == pattern
42
+ end
36
43
  end
37
44
 
38
45
  def parse_response?(env)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module DecodeXML
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-decode_xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spencer Oberstadt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-13 00:00:00.000000000 Z
11
+ date: 2022-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -170,8 +170,8 @@ licenses:
170
170
  - MIT
171
171
  metadata:
172
172
  bug_tracker_uri: https://github.com/soberstadt/faraday-decode_xml/issues
173
- changelog_uri: https://github.com/soberstadt/faraday-decode_xml/blob/v0.1.1/CHANGELOG.md
174
- documentation_uri: http://www.rubydoc.info/gems/faraday-decode_xml/0.1.1
173
+ changelog_uri: https://github.com/soberstadt/faraday-decode_xml/blob/v0.2.0/CHANGELOG.md
174
+ documentation_uri: http://www.rubydoc.info/gems/faraday-decode_xml/0.2.0
175
175
  homepage_uri: https://github.com/soberstadt/faraday-decode_xml
176
176
  rubygems_mfa_required: 'true'
177
177
  source_code_uri: https://github.com/soberstadt/faraday-decode_xml