berkeley_library-util 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/CHANGES.md +5 -0
- data/lib/berkeley_library/util/module_info.rb +1 -1
- data/lib/berkeley_library/util/uris.rb +1 -1
- data/spec/berkeley_library/util/uris/requester_spec.rb +4 -4
- data/spec/berkeley_library/util/uris_spec.rb +8 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc84acc6adb94fcfbbcf7d18b9a6bead8ef484ef40028f139b07964b565b4e2
|
4
|
+
data.tar.gz: 43e850e1ee541d777c07f546f789e576b45a44580734206c44cd2dce4d3293a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc47ba39cee501522db01aceeba7060f51ee4270ca03a2d4263e836190eddc2e953fd83eb292379ce4fcdbd5a9bac3831ec76c750cb2ecd9a375c86a60533079
|
7
|
+
data.tar.gz: 0dc4190292083d68066528c6a7efa815667ccc6ba79fb75ba0d0fa5e5f1ab354465447d1d7b53bbf825426e010bd4954b0ada17f3b935ae68095d8d0795940c1
|
data/.github/workflows/build.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.1.9 (2023-06-01)
|
2
|
+
|
3
|
+
- `URIs#path_escape` now attempts to convert non-UTF-8 strings to UTF-8 rather than immediately
|
4
|
+
raising an error.
|
5
|
+
|
1
6
|
# 0.1.8 (2023-03-20)
|
2
7
|
|
3
8
|
- Add `Retry-After` support to `Requester` for `429 Too Many Requests` and `503 Service Unavailable`.
|
@@ -7,7 +7,7 @@ module BerkeleyLibrary
|
|
7
7
|
SUMMARY = 'Miscellaneous Ruby utilities for the UC Berkeley Library'.freeze
|
8
8
|
DESCRIPTION = 'A collection of miscellaneous Ruby routines for the UC Berkeley Library.'.freeze
|
9
9
|
LICENSE = 'MIT'.freeze
|
10
|
-
VERSION = '0.1.
|
10
|
+
VERSION = '0.1.9'.freeze
|
11
11
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/util'.freeze
|
12
12
|
end
|
13
13
|
end
|
@@ -88,8 +88,8 @@ module BerkeleyLibrary
|
|
88
88
|
# replacing disallowed characters (including /) with percent-encodings as needed.
|
89
89
|
def path_escape(s)
|
90
90
|
raise ArgumentError, "Can't escape #{s.inspect}: not a string" unless s.respond_to?(:encoding)
|
91
|
-
raise ArgumentError, "Can't escape #{s.inspect}: expected #{UTF_8}, was #{s.encoding}" unless s.encoding == UTF_8
|
92
91
|
|
92
|
+
s = s.encode(UTF_8) unless s.encoding == UTF_8
|
93
93
|
''.tap do |escaped|
|
94
94
|
s.bytes.each do |b|
|
95
95
|
escaped << (should_escape?(b, :path_segment) ? '%%%02X' % b : b.chr)
|
@@ -101,7 +101,7 @@ module BerkeleyLibrary
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'raises RetryDelayTooLarge if the delay is too large' do
|
104
|
-
retry_after_seconds =
|
104
|
+
retry_after_seconds = 10 + BerkeleyLibrary::Util::URIs::Requester::MAX_RETRY_DELAY_SECONDS
|
105
105
|
|
106
106
|
stub_request(:get, url)
|
107
107
|
.to_return(status: 429, headers: { 'Retry-After' => retry_after_seconds.to_s })
|
@@ -163,7 +163,7 @@ module BerkeleyLibrary
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'raises RetryDelayTooLarge if the delay is too large' do
|
166
|
-
retry_after_seconds =
|
166
|
+
retry_after_seconds = 10 + BerkeleyLibrary::Util::URIs::Requester::MAX_RETRY_DELAY_SECONDS
|
167
167
|
retry_after_datetime = (Time.now + retry_after_seconds)
|
168
168
|
|
169
169
|
stub_request(:get, url)
|
@@ -236,7 +236,7 @@ module BerkeleyLibrary
|
|
236
236
|
end
|
237
237
|
|
238
238
|
it 'raises RetryDelayTooLarge if the delay is too large' do
|
239
|
-
retry_after_seconds =
|
239
|
+
retry_after_seconds = 10 + BerkeleyLibrary::Util::URIs::Requester::MAX_RETRY_DELAY_SECONDS
|
240
240
|
|
241
241
|
stub_request(:get, url)
|
242
242
|
.to_return(status: 503, headers: { 'Retry-After' => retry_after_seconds.to_s })
|
@@ -283,7 +283,7 @@ module BerkeleyLibrary
|
|
283
283
|
end
|
284
284
|
|
285
285
|
it 'raises RetryDelayTooLarge if the delay is too large' do
|
286
|
-
retry_after_seconds =
|
286
|
+
retry_after_seconds = 10 + BerkeleyLibrary::Util::URIs::Requester::MAX_RETRY_DELAY_SECONDS
|
287
287
|
retry_after_datetime = (Time.now + retry_after_seconds)
|
288
288
|
|
289
289
|
stub_request(:get, url)
|
@@ -337,20 +337,14 @@ module BerkeleyLibrary::Util
|
|
337
337
|
expect { URIs.path_escape(str.bytes) }.to raise_error(ArgumentError)
|
338
338
|
end
|
339
339
|
|
340
|
-
it '
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
# OK, we're really just testing String#encode here, but
|
350
|
-
# it's useful for documentation
|
351
|
-
in_str_sjis = in_str.encode(Encoding::Shift_JIS)
|
352
|
-
in_str_utf8 = in_str_sjis.encode(Encoding::UTF_8)
|
353
|
-
expect(URIs.path_escape(in_str_utf8)).to eq(out_str)
|
340
|
+
it 'converts non-UTF-8 strings to UTF-8' do
|
341
|
+
utf_16_be = Encoding.find('UTF-16BE')
|
342
|
+
aggregate_failures do
|
343
|
+
in_out.each do |in_str, out_str|
|
344
|
+
encoded = in_str.encode(utf_16_be)
|
345
|
+
expect(URIs.path_escape(encoded)).to eq(out_str)
|
346
|
+
end
|
347
|
+
end
|
354
348
|
end
|
355
349
|
end
|
356
350
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkeley_library-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Moles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: berkeley_library-logging
|