faraday-decode_xml 0.1.0 → 0.2.1

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: 0f3cdd8b85bd65538e376adc19b33cc4bc050d06e8433a5591db529ca7400031
4
- data.tar.gz: d6103409bf9c1c364529cd4e9eb9c52e9e9328433f78b5f343c4d642043ed94a
3
+ metadata.gz: 19eb8264a85fb487fcae71461282bb1be3a0a229687676823d1768bc63c0dc62
4
+ data.tar.gz: 9f33786a3d4dff673cfbe3179e5181ed7d7e071763a7e4873beb6c66e960a197
5
5
  SHA512:
6
- metadata.gz: 97cf6349802faa8f89bf2d305efc396bf0be3778e3b02fd75f70404d536d59bc5ed7f9a0b0c7eb448d3a6c0ccab5e7e1def944ec1004ffd2c25d17d1f7febb68
7
- data.tar.gz: bcef664a14c72703d4c6c0dd6207193069b8a5adb9b90f25b310545e5fe86d25b7199f486d6adf0aad9aa252397fc692287b2f9b473e63c0d6a6e3feec90100f
6
+ metadata.gz: 3a7e90df89e223b8293316c528b76de88ad30bbaf799493dbb4a021beb2ec481982e1a450081d435a03835254cc64e7c0b4fb90a6bd54ca00ffc7a60c64d55ea
7
+ data.tar.gz: a77dd12dbb0c9a9ebac4dc3f0ced8f7621c7d69cee8aa0f4b5ccfa3cbac552f1b344097ed2877be2f81967740a293c7ac137aef3869b80692d43b63d7007e8ff
data/CHANGELOG.md CHANGED
@@ -2,4 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- * Initial release.
5
+ ## 0.2.1
6
+
7
+ - Fix handling no Content-Type header (#3)
8
+
9
+ ## 0.2.0
10
+
11
+ - Add support for specifying content types to attempt to parse (#2)
12
+
13
+ ## 0.1.1
14
+
15
+ - Relax faraday dependency (#1)
16
+
17
+ ## 0.1.0
18
+
19
+ - Initial release.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Faraday Decode XML
2
2
 
3
- [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/soberstadt/faraday-decode_xml/ci)](https://github.com/soberstadt/faraday-decode_xml/actions?query=branch%3Amain)
3
+ [![GitHub Workflow Status](https://github.com/soberstadt/faraday-decode_xml/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/soberstadt/faraday-decode_xml/actions?query=branch%3Amain)
4
4
  [![Gem](https://img.shields.io/gem/v/faraday-decode_xml.svg?style=flat-square)](https://rubygems.org/gems/faraday-decode_xml)
5
5
  [![License](https://img.shields.io/github/license/soberstadt/faraday-decode_xml.svg?style=flat-square)](LICENSE.md)
6
6
 
@@ -11,7 +11,7 @@ Faraday middleware for decoding XML requests.
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'faraday-decode_xml'
14
+ gem "faraday-decode_xml"
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -29,11 +29,9 @@ gem install faraday-decode_xml
29
29
  ## Usage
30
30
 
31
31
  ```ruby
32
- require 'faraday/decode_xml'
32
+ require "faraday/decode_xml"
33
33
 
34
- Faraday.new do |faraday|
35
- faraday.response :xml
36
- end
34
+ Faraday.new { |faraday| faraday.response :xml }
37
35
  ```
38
36
 
39
37
  ## Development
@@ -47,6 +45,8 @@ To install this gem onto your local machine, run `rake build`.
47
45
  To release a new version, make a commit with a message such as "Bumped to 0.0.2" and then run `rake release`.
48
46
  See how it works [here](https://bundler.io/guides/creating_gem.html#releasing-the-gem).
49
47
 
48
+ To run prettier, run `rake prettier`
49
+
50
50
  ## Contributing
51
51
 
52
52
  Bug reports and pull requests are welcome on [GitHub](https://github.com/soberstadt/faraday-decode_xml).
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'multi_xml'
3
+ require "multi_xml"
4
4
 
5
5
  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)
@@ -28,11 +33,12 @@ module Faraday
28
33
  end
29
34
 
30
35
  def response_type(env)
31
- env.response_headers['Content-Type'].to_s.split(';', 2).first
36
+ env.response_headers["Content-Type"].to_s.split(";", 2).first.to_s
32
37
  end
33
38
 
34
39
  def process_response_type?(type)
35
- type == 'application/xml'
40
+ @content_types.empty? ||
41
+ @content_types.any? { |pattern| pattern.is_a?(Regexp) ? type.match?(pattern) : type == pattern }
36
42
  end
37
43
 
38
44
  def parse_response?(env)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module DecodeXML
5
- VERSION = '0.1.0'
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'decode_xml/middleware'
4
- require_relative 'decode_xml/version'
3
+ require_relative "decode_xml/middleware"
4
+ require_relative "decode_xml/version"
5
5
 
6
6
  module Faraday
7
7
  # This will be your middleware main module, though the actual middleware implementation will go
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-decode_xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
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-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_xml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.21.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: prettier
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.1.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.1.2
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rubocop
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -170,8 +184,8 @@ licenses:
170
184
  - MIT
171
185
  metadata:
172
186
  bug_tracker_uri: https://github.com/soberstadt/faraday-decode_xml/issues
173
- changelog_uri: https://github.com/soberstadt/faraday-decode_xml/blob/v0.1.0/CHANGELOG.md
174
- documentation_uri: http://www.rubydoc.info/gems/faraday-decode_xml/0.1.0
187
+ changelog_uri: https://github.com/soberstadt/faraday-decode_xml/blob/v0.2.1/CHANGELOG.md
188
+ documentation_uri: http://www.rubydoc.info/gems/faraday-decode_xml/0.2.1
175
189
  homepage_uri: https://github.com/soberstadt/faraday-decode_xml
176
190
  rubygems_mfa_required: 'true'
177
191
  source_code_uri: https://github.com/soberstadt/faraday-decode_xml
@@ -184,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
186
200
  - !ruby/object:Gem::Version
187
- version: '2.5'
201
+ version: 2.7.3
188
202
  - - "<"
189
203
  - !ruby/object:Gem::Version
190
204
  version: '4'