berkeley_library-util 0.1.0 → 0.1.1
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 +4 -4
- data/.idea/inspectionProfiles/Project_Default.xml +4 -0
- data/CHANGES.md +6 -1
- data/README.md +3 -3
- data/lib/berkeley_library/util/module_info.rb +1 -1
- data/lib/berkeley_library/util/paths.rb +8 -0
- data/lib/berkeley_library/util/uris/appender.rb +2 -1
- data/lib/berkeley_library/util/uris/requester.rb +2 -0
- data/spec/berkeley_library/util/uris/requester_spec.rb +8 -11
- data/spec/berkeley_library/util/uris_spec.rb +23 -0
- 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: 8f8cd7e16b30baef3d05f38a78b698dfbc3a603b67f3573c8a2bbec9e2cac9b3
|
4
|
+
data.tar.gz: ebf19dd8fee5fe57a78942432d3f08e8bc486ac1ae69ba7a7ebad070ece90331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ec9705be8f0b44019205a2bc72b5d24b982ddf463f88676e395de277cb6ff20687d3c4a5efc88de6f450a862e4351558dd9409bd35971970034c6b8e85ecea1
|
7
|
+
data.tar.gz: 0e77b5e7d5221ee6498ffba856d01ffa2faf216f3838bdd41db724e4207191cd97919bc1e24ba0ea5e483cc6ba83dea3672b258465ebe136bad1e5e3bd296b35
|
@@ -11,6 +11,10 @@
|
|
11
11
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
12
12
|
<inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
|
13
13
|
<inspection_tool class="RubyCaseWithoutElseBlockInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
14
|
+
<inspection_tool class="RubyMismatchedReturnType" enabled="true" level="WARNING" enabled_by_default="true">
|
15
|
+
<option name="myCheckNilability" value="false" />
|
16
|
+
</inspection_tool>
|
17
|
+
<inspection_tool class="RubyNilAnalysis" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
14
18
|
<inspection_tool class="RubyStringKeysInHashInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
15
19
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
16
20
|
<option name="processCode" value="true" />
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.1.1 (2021-09-23)
|
2
|
+
|
3
|
+
- `URIs.append` now handles bare URLs with empty paths, with the caveat that
|
4
|
+
a root path `/` will always be added, even if there are no path elements to append.
|
5
|
+
|
1
6
|
# 0.1.0 (2021-09-23)
|
2
7
|
|
3
|
-
Initial extraction of code from [`berkeley_library/tind`](https://github.com/BerkeleyLibrary/tind).
|
8
|
+
- Initial extraction of code from [`berkeley_library/tind`](https://github.com/BerkeleyLibrary/tind).
|
data/README.md
CHANGED
@@ -7,15 +7,15 @@ Miscellaneous utility code for the UC Berkeley Library.
|
|
7
7
|
|
8
8
|
### Notable modules
|
9
9
|
|
10
|
-
## [BerkeleyLibrary::Util::Arrays](lib/berkeley_library/util/arrays.rb)
|
10
|
+
## [BerkeleyLibrary::Util::Arrays](lib/berkeley_library/util/arrays.rb)
|
11
11
|
|
12
12
|
Routines for comparing, merging, and examining the contents of arrays.
|
13
13
|
|
14
|
-
## [BerkeleyLibrary::Util::Paths](lib/berkeley_library/util/paths.rb)
|
14
|
+
## [BerkeleyLibrary::Util::Paths](lib/berkeley_library/util/paths.rb)
|
15
15
|
|
16
16
|
Routines for modifying paths separated by forward slashes,
|
17
17
|
(such as URL paths), modeled on the [Go `path` package](https://golang.org/pkg/path/).
|
18
18
|
|
19
|
-
## [BerkeleyLibrary::Util::URIs](lib/berkeley_library/util/uris.rb)
|
19
|
+
## [BerkeleyLibrary::Util::URIs](lib/berkeley_library/util/uris.rb)
|
20
20
|
|
21
21
|
Routines for constructing, validating, and retrieving the content from URIs.
|
@@ -9,7 +9,7 @@ module BerkeleyLibrary
|
|
9
9
|
A collection of miscellaneous Ruby routines for the UC Berkeley Library.
|
10
10
|
DESC
|
11
11
|
LICENSE = 'MIT'.freeze
|
12
|
-
VERSION = '0.1.
|
12
|
+
VERSION = '0.1.1'.freeze
|
13
13
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/util'.freeze
|
14
14
|
end
|
15
15
|
end
|
@@ -35,7 +35,8 @@ module BerkeleyLibrary
|
|
35
35
|
# @raise URI::InvalidComponentError if appending the specified elements would create an invalid URI
|
36
36
|
def to_uri
|
37
37
|
original_uri.dup.tap do |new_uri|
|
38
|
-
|
38
|
+
new_path = Paths.join(new_uri.path, *path_elements)
|
39
|
+
new_uri.path = Paths.ensure_abs(new_path)
|
39
40
|
new_uri.query = query unless query_elements.empty?
|
40
41
|
new_uri.fragment = fragment unless fragment_elements.empty?
|
41
42
|
end
|
@@ -44,18 +44,15 @@ module BerkeleyLibrary
|
|
44
44
|
expect(result).to eq(expected_body)
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'raises an error for a weird non-failure status' do
|
55
|
-
url = 'https://example.org/'
|
56
|
-
stub_request(:get, url).to_return(status: 207)
|
47
|
+
it "raises #{RestClient::Exception} in the event of an invalid response" do
|
48
|
+
aggregate_failures 'responses' do
|
49
|
+
[207, 400, 401, 403, 404, 405, 418, 451, 500, 503].each do |code|
|
50
|
+
url = "http://example.edu/#{code}"
|
51
|
+
stub_request(:get, url).to_return(status: code)
|
57
52
|
|
58
|
-
|
53
|
+
expect { Requester.get(url) }.to raise_error(RestClient::Exception)
|
54
|
+
end
|
55
|
+
end
|
59
56
|
end
|
60
57
|
|
61
58
|
it 'handles redirects' do
|
@@ -9,6 +9,29 @@ module BerkeleyLibrary::Util
|
|
9
9
|
expect(new_uri).to eq(URI('https://example.org/foo/bar/qux/corge/garply'))
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'appends paths to bare URIs without root' do
|
13
|
+
original_url = 'https://example.org'
|
14
|
+
new_uri = URIs.append(original_url, 'foo', 'bar')
|
15
|
+
expected_uri = URI('https://example.org/foo/bar')
|
16
|
+
expect(new_uri).to eq(expected_uri)
|
17
|
+
end
|
18
|
+
|
19
|
+
# TODO: make this work
|
20
|
+
xit "doesn't append to a bare URI when there's nothing to append" do
|
21
|
+
original_url = 'https://example.org'
|
22
|
+
new_uri = URIs.append(original_url)
|
23
|
+
expected_uri = URI(original_url)
|
24
|
+
expect(new_uri).to eq(expected_uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
# TODO: make this work
|
28
|
+
xit "doesn't append to a bare URI when there's only a query string" do
|
29
|
+
original_url = 'https://example.org'
|
30
|
+
new_uri = URIs.append(original_url, '?foo=bar')
|
31
|
+
expected_uri = URI("#{original_url}?foo=bar")
|
32
|
+
expect(new_uri).to eq(expected_uri)
|
33
|
+
end
|
34
|
+
|
12
35
|
it 'does not modify the original URI' do
|
13
36
|
original_uri = URI('https://example.org/foo/bar')
|
14
37
|
original_url = original_uri.to_s
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Moles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: berkeley_library-logging
|