maremma 4.9.2 → 4.9.6

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: 2a9c0b30f4fe07434f05de62e4b64c54028ed22cebb285e8bee34850e34514f8
4
- data.tar.gz: 18f09ec414eafd45610d458917787ca22bdd4db5bc286494634cdd5d80dac562
3
+ metadata.gz: c8c7478b41d06a371b6515a8dd41c7abeb3a4a046eb9cd12376873823fcbe349
4
+ data.tar.gz: c35e08881191261ca2510c1c9012cb2cd0a239723fdac43bf3ecd9a20519c822
5
5
  SHA512:
6
- metadata.gz: 25aa844992e5aeebcdd5b0f127244e6546060f2de7fac3250f384641f060d616e1e448a6d8ae6eb8c27b2668299eef5d2ed5cd6d0375c6bae9f9ef68fc9602b3
7
- data.tar.gz: 5e47a8f2d32e8f1380584c462e28221b19aebe285dff004253230ee98e502c909ceea85526854c513bd8321a7be2f550266590c2eac1f431ba119f6be9f6a809
6
+ metadata.gz: 5f305c308e7a204fcaae3bfcd61433cac0418dad757addf6944c3c800b90c659076460e680866c01c0937e44d9ed064c20654f1d64041910ec1ddbe692e64b54
7
+ data.tar.gz: 4d64ab236db26628380a259a85b42ed0c5f0540f992a70e184821146b7c29d9f441349b89c2322c826c009f69c2e641737d02f1940fa4aca0652d3864b60cbf3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/datacite/maremma/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/datacite/maremma/compare/4.9.5...HEAD)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Add option to skip the encoding of the response body. [\#16](https://github.com/datacite/maremma/pull/16) ([jrhoads](https://github.com/jrhoads))
10
+
11
+ ## [4.9.5](https://github.com/datacite/maremma/tree/4.9.5) (2021-07-20)
12
+
13
+ [Full Changelog](https://github.com/datacite/maremma/compare/4.9.4...4.9.5)
14
+
15
+ ## [4.9.4](https://github.com/datacite/maremma/tree/4.9.4) (2021-06-07)
16
+
17
+ [Full Changelog](https://github.com/datacite/maremma/compare/4.9.3...4.9.4)
18
+
19
+ ## [4.9.3](https://github.com/datacite/maremma/tree/4.9.3) (2021-06-07)
20
+
21
+ [Full Changelog](https://github.com/datacite/maremma/compare/4.9.2...4.9.3)
22
+
23
+ ## [4.9.2](https://github.com/datacite/maremma/tree/4.9.2) (2021-06-07)
24
+
25
+ [Full Changelog](https://github.com/datacite/maremma/compare/4.9.1...4.9.2)
26
+
3
27
  ## [4.9.1](https://github.com/datacite/maremma/tree/4.9.1) (2021-06-06)
4
28
 
5
29
  [Full Changelog](https://github.com/datacite/maremma/compare/4.9...4.9.1)
@@ -271,15 +295,15 @@
271
295
 
272
296
  ## [v.3.0](https://github.com/datacite/maremma/tree/v.3.0) (2016-11-25)
273
297
 
274
- [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.4...v.3.0)
298
+ [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.5...v.3.0)
275
299
 
276
- ## [v.2.5.4](https://github.com/datacite/maremma/tree/v.2.5.4) (2016-11-23)
300
+ ## [v.2.5.5](https://github.com/datacite/maremma/tree/v.2.5.5) (2016-11-23)
277
301
 
278
- [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.5...v.2.5.4)
302
+ [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.4...v.2.5.5)
279
303
 
280
- ## [v.2.5.5](https://github.com/datacite/maremma/tree/v.2.5.5) (2016-11-23)
304
+ ## [v.2.5.4](https://github.com/datacite/maremma/tree/v.2.5.4) (2016-11-23)
281
305
 
282
- [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.3...v.2.5.5)
306
+ [Full Changelog](https://github.com/datacite/maremma/compare/v.2.5.3...v.2.5.4)
283
307
 
284
308
  ## [v.2.5.3](https://github.com/datacite/maremma/tree/v.2.5.3) (2016-11-18)
285
309
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (4.9.2)
4
+ maremma (4.9.6)
5
5
  activesupport (>= 4.2.5)
6
6
  addressable (>= 2.3.6)
7
7
  builder (~> 3.2, >= 3.2.2)
@@ -16,13 +16,13 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- activesupport (6.1.3.2)
19
+ activesupport (6.1.4.1)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
23
23
  tzinfo (~> 2.0)
24
24
  zeitwerk (~> 2.3)
25
- addressable (2.7.0)
25
+ addressable (2.8.0)
26
26
  public_suffix (>= 2.0.2, < 5.0)
27
27
  ast (2.4.2)
28
28
  builder (3.2.4)
@@ -48,18 +48,18 @@ GEM
48
48
  nokogiri (1.11.7)
49
49
  mini_portile2 (~> 2.5.0)
50
50
  racc (~> 1.4)
51
- oj (3.11.5)
51
+ oj (3.13.9)
52
52
  oj_mimic_json (1.0.1)
53
53
  parallel (1.20.1)
54
- parser (3.0.1.1)
54
+ parser (3.0.2.0)
55
55
  ast (~> 2.4.1)
56
56
  public_suffix (4.0.6)
57
- racc (1.5.2)
57
+ racc (1.6.0)
58
58
  rack (2.2.3)
59
59
  rack-test (0.8.3)
60
60
  rack (>= 1.0, < 3)
61
61
  rainbow (3.0.0)
62
- rake (13.0.3)
62
+ rake (13.0.6)
63
63
  rexml (3.2.5)
64
64
  rspec (3.10.0)
65
65
  rspec-core (~> 3.10.0)
@@ -98,7 +98,7 @@ GEM
98
98
  addressable (>= 2.3.6)
99
99
  crack (>= 0.3.2)
100
100
  hashdiff (>= 0.4.0, < 2.0.0)
101
- zeitwerk (2.4.2)
101
+ zeitwerk (2.5.1)
102
102
 
103
103
  PLATFORMS
104
104
  ruby
@@ -116,4 +116,4 @@ DEPENDENCIES
116
116
  webmock (~> 3.0, >= 3.0.1)
117
117
 
118
118
  BUNDLED WITH
119
- 2.2.19
119
+ 2.2.30
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "4.9.2".freeze
2
+ VERSION = "4.9.6".freeze
3
3
  end
data/lib/maremma.rb CHANGED
@@ -130,7 +130,7 @@ module Maremma
130
130
  c.headers["Accept"] = options[:headers]["Accept"]
131
131
  c.headers["User-Agent"] = options[:headers]["User-Agent"]
132
132
  c.use FaradayMiddleware::FollowRedirects, limit: limit, cookie: :all if limit > 0
133
- # c.use FaradayMiddleware::Gzip
133
+ c.use FaradayMiddleware::Gzip
134
134
  c.request :multipart
135
135
  c.request :json if options[:headers]["Accept"] == "application/json"
136
136
  c.response :encoding
@@ -229,7 +229,18 @@ module Maremma
229
229
  end
230
230
 
231
231
  def self.parse_response(string, options = {})
232
- string = string.dup.encode(Encoding.find("UTF-8"), invalid: :replace, undef: :replace, replace: "")
232
+ string = string.dup
233
+ string =
234
+ if options[:skip_encoding]
235
+ string
236
+ else
237
+ string.encode(
238
+ Encoding.find("UTF-8"),
239
+ invalid: :replace,
240
+ undef: :replace,
241
+ replace: "?"
242
+ )
243
+ end
233
244
  return string if options[:raw]
234
245
 
235
246
  from_json(string) || from_xml(string) || from_string(string)
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pub.sandbox.orcid.org/v3.0/0000-0002-5721-4355
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Mozilla/5.0 (compatible; Maremma/4.9.5; +https://github.com/datacite/maremma)
12
+ Accept:
13
+ - application/json;charset=UTF-8
14
+ Accept-Encoding:
15
+ - gzip,deflate
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Date:
22
+ - Wed, 27 Oct 2021 13:46:08 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Connection:
26
+ - keep-alive
27
+ Access-Control-Allow-Origin:
28
+ - "*"
29
+ Cache-Control:
30
+ - no-cache, no-store, max-age=0, must-revalidate
31
+ Pragma:
32
+ - no-cache
33
+ Expires:
34
+ - '0'
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ Vary:
42
+ - accept-encoding
43
+ Content-Encoding:
44
+ - gzip
45
+ Cf-Cache-Status:
46
+ - DYNAMIC
47
+ Expect-Ct:
48
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
49
+ Server:
50
+ - cloudflare
51
+ Cf-Ray:
52
+ - 6a4c5e658b6919e7-EWR
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: !binary |-
56
+ H4sIAAAAAAAAALRVy27bMBD8FYOnFrDiWH77mqRFr0V6KnqgxbW1DUWqJKXECPJBOeTQb/CPdemnHKumW9gGLAjicGZ3uBo9M20SFBEKUA6nCIaNn1lhkI1Z6lxux62W5UpM9NPVEknXWeuafhH946g3iNtRt9PrsSbLuUtpW/1iqq2jxQMu9kIbDUzBgErAenWpEy6BwKD8aorWaTP3K4kB7lCrKAOXakGQ2y9f727uiT/RWS5huSi4o92qkLLJbDHJ0Nrd42dWclnQTbvf6Q66o+F13Bt0SEZy66JMC2+CqAOPOnGn0437AwInkmMGVIAzBZCKLkyy1RTAE4clPyimBLNih4yj3GzePs0NZtzMq6veHDBWq6UvNRWuiBXPYOtPffXLVjvX7f6/tBoTeIYlqMgr2AqK3XLHbxZvbvHqz2jKM5TzaFPHBvTt/tOwcb94paP3phkQ6Nag9fHsGVeixQlKdHTYLC8mEpPjY0Wk2qVgduX93aMdkI2//9jS1s1yq0pKGhPUM8PzdH6Cx0O6dE/xmHCj/iCOR94ZrRy9f1TOnU0M0rg3Gz/pJbSONxuoSrAOZ1xo0/jwmV6gxRs9vrM5X/ymm/Zo2P54xQL21fa5a4yKMGCBm8R3XhgZcHMfHHb0PTnpLcc8ILN+FULsKxhxciFIyYZmYQ0LE2+ARP0A80dtRIB5jQozb+m8E08OjOKyksIhXw53nOBSnczL8T3r9PHW+kxDh2AjW2Q+qI6XKGh6USU+BEOnMZ3S1K7icmZ0kYdb2SP3Dooi4ZeRqlAvhzaXep6RfxdQqnD7TC2UQDUL6JzIvSUjYgoU9AmWa4uX8exQgWQzyCY0TSnm5xesci+/mZQzBkqEx/PYt0dIAr8KLonsUjP3jr4SzlTE6pt5nr5qaEnMgikxKPEffW2JSYTS7+E8TayYAkG2i68Akr38AQAA//8DAEWCRUMUCwAA
57
+ http_version:
58
+ recorded_at: Wed, 27 Oct 2021 13:46:00 GMT
59
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pub.sandbox.orcid.org/v3.0/0000-0002-5721-4355
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Mozilla/5.0 (compatible; Maremma/4.9.5; +https://github.com/datacite/maremma)
12
+ Accept:
13
+ - application/json;charset=UTF-8
14
+ Accept-Encoding:
15
+ - gzip,deflate
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Date:
22
+ - Wed, 27 Oct 2021 13:46:08 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Connection:
26
+ - keep-alive
27
+ Access-Control-Allow-Origin:
28
+ - "*"
29
+ Cache-Control:
30
+ - no-cache, no-store, max-age=0, must-revalidate
31
+ Pragma:
32
+ - no-cache
33
+ Expires:
34
+ - '0'
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ Vary:
42
+ - accept-encoding
43
+ Content-Encoding:
44
+ - gzip
45
+ Cf-Cache-Status:
46
+ - DYNAMIC
47
+ Expect-Ct:
48
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
49
+ Server:
50
+ - cloudflare
51
+ Cf-Ray:
52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GMT
59
+ recorded_with: VCR 3.0.3
data/spec/maremma_spec.rb CHANGED
@@ -78,20 +78,34 @@ describe Maremma do
78
78
  expect(stub).to have_been_requested
79
79
  end
80
80
 
81
- # it "get json compressed", vcr: true do
82
- # response = subject.get("https://api.datacite.org/works", :headers => { "Content-Type" => "application/json", "Accept-Encoding" => "gzip"})
83
- # expect(response.body["data"].length).to eq(25)
84
- # end
81
+ it "get json compressed", vcr: true do
82
+ response = subject.get("https://api.datacite.org/works", headers: { "Content-Type" => "application/json", "Accept-Encoding" => "gzip" })
83
+ expect(response.body["data"].length).to eq(25)
84
+ end
85
85
 
86
- # it "get html compressed", vcr: true do
87
- # response = subject.get("https://datacite.org/", :headers => {"Accept-Encoding" => "gzip"})
88
- # expect(response.body["data"]).to include("html")
89
- # end
86
+ it "get html compressed", vcr: true do
87
+ response = subject.get("https://datacite.org/", headers: { "Accept-Encoding" => "gzip" })
88
+ expect(response.body["data"]).to include("html")
89
+ end
90
90
 
91
- # it "get xml compressed", vcr: true do
92
- # response = subject.get("https://data.crosscite.org/application/vnd.datacite.datacite+xml/10.5061/dryad.8515", :headers => { "Accept-Encoding" => "gzip"})
93
- # expect(response.body["data"]).to be_a(Hash)
94
- # end
91
+ it "get xml compressed", vcr: true do
92
+ response = subject.get("https://data.crosscite.org/application/vnd.datacite.datacite+xml/10.5061/dryad.8515", headers: { "Accept-Encoding" => "gzip" })
93
+ expect(response.body["data"]).to be_a(Hash)
94
+ end
95
+
96
+ it "get utf8 bad encoding", vcr: true do
97
+ response = subject.get("https://pub.sandbox.orcid.org/v3.0/0000-0002-5721-4355", accept: "json")
98
+ expect(response.body["data"]).to be_a(Hash)
99
+ expect(response.body["data"]["person"]["name"]["given-names"]["value"]).to eq("DataC??t??")
100
+ expect(response.body["data"]["person"]["name"]["family-name"]["value"]).to eq("UTF8 T??st")
101
+ end
102
+
103
+ it "get utf8 skip encoding", vcr: true do
104
+ response = subject.get("https://pub.sandbox.orcid.org/v3.0/0000-0002-5721-4355", accept: "json", skip_encoding: true)
105
+ expect(response.body["data"]).to be_a(Hash)
106
+ expect(response.body["data"]["person"]["name"]["given-names"]["value"]).to eq("DataCíté")
107
+ expect(response.body["data"]["person"]["name"]["family-name"]["value"]).to eq("UTF8 Tést")
108
+ end
95
109
  end
96
110
 
97
111
  context "head" do
@@ -99,7 +113,7 @@ describe Maremma do
99
113
  stub = stub_request(:head, url).to_return(status: 200, headers: { "Content-Type" => "text/html" })
100
114
  response = subject.head(url, accept: "html")
101
115
  expect(response.body).to be_nil
102
- expect(response.headers).to eq("Content-Type" => "text/html")
116
+ expect(response.headers).to eq("Content-Length" => 0, "Content-Type" => "text/html")
103
117
  expect(stub).to have_been_requested
104
118
  end
105
119
  end
@@ -151,7 +165,7 @@ describe Maremma do
151
165
  stub = stub_request(:get, url).to_return(body: nil, status: 200, headers: { "Content-Type" => "application/json" })
152
166
  response = subject.get(url)
153
167
  expect(response.body).to eq("data" => nil)
154
- expect(response.headers).to eq("Content-Type" => "application/json")
168
+ expect(response.headers).to eq("Content-Length" => 0, "Content-Type" => "application/json")
155
169
  expect(stub).to have_been_requested
156
170
  end
157
171
 
@@ -159,7 +173,7 @@ describe Maremma do
159
173
  stub = stub_request(:get, url).to_return(body: nil, status: 200, headers: { "Content-Type" => "application/xml" })
160
174
  response = subject.get(url, accept: "xml")
161
175
  expect(response.body).to eq("data" => nil)
162
- expect(response.headers).to eq("Content-Type" => "application/xml")
176
+ expect(response.headers).to eq("Content-Length" => 0, "Content-Type" => "application/xml")
163
177
  expect(stub).to have_been_requested
164
178
  end
165
179
 
@@ -167,7 +181,7 @@ describe Maremma do
167
181
  stub = stub_request(:get, url).to_return(body: nil, status: 200, headers: { "Content-Type" => "text/html" })
168
182
  response = subject.get(url, accept: "html")
169
183
  expect(response.body).to eq("data" => nil)
170
- expect(response.headers).to eq("Content-Type" => "text/html")
184
+ expect(response.headers).to eq("Content-Length" => 0, "Content-Type" => "text/html")
171
185
  expect(stub).to have_been_requested
172
186
  end
173
187
 
@@ -319,7 +333,7 @@ describe Maremma do
319
333
  stub = stub_request(:delete, url).to_return(status: 204, headers: { "Content-Type" => "text/html" })
320
334
  response = subject.delete(url)
321
335
  expect(response.body).to eq("data" => nil)
322
- expect(response.headers).to eq("Content-Type" => "text/html")
336
+ expect(response.headers).to eq("Content-Length" => 0, "Content-Type" => "text/html")
323
337
  expect(response.status).to eq(204)
324
338
  expect(stub).to have_been_requested
325
339
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.2
4
+ version: 4.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -344,6 +344,8 @@ files:
344
344
  - spec/fixtures/vcr_cassettes/Maremma/get/get_html_compressed.yml
345
345
  - spec/fixtures/vcr_cassettes/Maremma/get/get_json_compressed.yml
346
346
  - spec/fixtures/vcr_cassettes/Maremma/get/get_json_with_params.yml
347
+ - spec/fixtures/vcr_cassettes/Maremma/get/get_utf8_bad_encoding.yml
348
+ - spec/fixtures/vcr_cassettes/Maremma/get/get_utf8_skip_encoding.yml
347
349
  - spec/fixtures/vcr_cassettes/Maremma/get/get_xml_compressed.yml
348
350
  - spec/fixtures/vcr_cassettes/Maremma/link_headers/parses_link_headers.yml
349
351
  - spec/fixtures/vcr_cassettes/Maremma/set_host/crossref.yml