borrow_direct 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/borrow_direct/error.rb +7 -1
- data/lib/borrow_direct/generate_query.rb +2 -2
- data/lib/borrow_direct/request.rb +1 -1
- data/lib/borrow_direct/version.rb +1 -1
- data/test/generate_query_test.rb +3 -0
- data/test/request_test.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjk4M2VkNzA1NWRmNjY5YmNkOTYyYTcyMmUxMzA5ZDkzZWQwNWU3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODVhYjgxMjhkZTA1MjhjYTNlOTE1OWEwN2Y5NDVlYmZmM2M3ZjQxOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTA0MTE0NWFjMTViZjgyMmU1MWI0MGQyZTdiYmNkY2RhNTkxNTE2OWY5ZGM3
|
10
|
+
ZjU2M2FhYzg3ODQzYmExNzViMTI0Y2UwYjQzYjJlYmNiYmYyMmI3NDBjYTIy
|
11
|
+
OWRiYzdiM2M5MGFjZDRmOTkxNWQ2ZWNhMjhkN2ZhYjQ4M2VmOTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTA4NzMxODE4OTgzMDg2ZmZjN2I0NTE0MmM1NjZlOGQwZjRiMmJkNDhjMzg3
|
14
|
+
Yjc0ZTg3N2I5OWYwMjQwNGRkNDc1YzIxMjk4YmRmMjcxZjY4YWNjNGM0MzIx
|
15
|
+
ZmVhYjc2OGU5NGY0NzBjMWY2ZDdhODU5MzM3NDU0NzUyMjBjZDE=
|
data/lib/borrow_direct/error.rb
CHANGED
@@ -13,5 +13,11 @@ module BorrowDirect
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class HttpError < Error ; end
|
16
|
-
class HttpTimeoutError < HttpError
|
16
|
+
class HttpTimeoutError < HttpError
|
17
|
+
attr_reader :timeout
|
18
|
+
def initialize(msg, timeout=nil)
|
19
|
+
@timeout = timeout
|
20
|
+
super(msg)
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
@@ -131,10 +131,10 @@ module BorrowDirect
|
|
131
131
|
return "" if author.nil? || author.empty?
|
132
132
|
|
133
133
|
author = author.downcase
|
134
|
-
# Just take everything before the comma if we have one --
|
134
|
+
# Just take everything before the comma/semicolon if we have one --
|
135
135
|
# or before an "and", for stripping individuals out of 245c
|
136
136
|
# multiples.
|
137
|
-
if author =~ /\A(
|
137
|
+
if author =~ /\A([^,;]*)(,|\sand\s|;)/
|
138
138
|
author = $1
|
139
139
|
end
|
140
140
|
|
@@ -102,7 +102,7 @@ module BorrowDirect
|
|
102
102
|
return response_hash
|
103
103
|
rescue HTTPClient::ReceiveTimeoutError, HTTPClient::ConnectTimeoutError, HTTPClient::SendTimeoutError => e
|
104
104
|
elapsed = Time.now - start_time
|
105
|
-
raise BorrowDirect::HttpTimeoutError.new("Timeout after #{elapsed.round(1)}s connecting to BorrowDirect server at #{@api_base}")
|
105
|
+
raise BorrowDirect::HttpTimeoutError.new("Timeout after #{elapsed.round(1)}s connecting to BorrowDirect server at #{@api_base}", self.timeout)
|
106
106
|
end
|
107
107
|
|
108
108
|
def http_client
|
data/test/generate_query_test.rb
CHANGED
@@ -162,6 +162,9 @@ describe "GenerateQuery" do
|
|
162
162
|
# Hmm, should we really be stripping those periods? Not sure, but seems
|
163
163
|
# to do okay in searching.
|
164
164
|
assert_equal "h a shapiro", @generator.normalized_author("edited by H.A. Shapiro.")
|
165
|
+
|
166
|
+
assert_equal "john smith", @generator.normalized_author("john smith, editor, mike brown, editor")
|
167
|
+
assert_equal "john smith", @generator.normalized_author("by john smith; with help from mike brown")
|
165
168
|
end
|
166
169
|
|
167
170
|
|
data/test/request_test.rb
CHANGED
@@ -93,16 +93,18 @@ describe "Request", :vcr => {:tag => :bd_request} do
|
|
93
93
|
bd = BorrowDirect::Request.new("/dws/item/available")
|
94
94
|
# tiny timeout, it'll def timeout, and on connect no less
|
95
95
|
bd.timeout = 0.00001
|
96
|
-
assert_raises(BorrowDirect::HttpTimeoutError) do
|
96
|
+
timeout_error = assert_raises(BorrowDirect::HttpTimeoutError) do
|
97
97
|
response = bd.request( request )
|
98
98
|
end
|
99
|
+
assert_equal bd.timeout, timeout_error.timeout
|
99
100
|
|
100
101
|
# little bit longer to get maybe a receive timeout instead
|
101
102
|
bd = BorrowDirect::Request.new("/dws/item/available")
|
102
103
|
bd.timeout = 0.10
|
103
|
-
assert_raises(BorrowDirect::HttpTimeoutError) do
|
104
|
+
timeout_error = assert_raises(BorrowDirect::HttpTimeoutError) do
|
104
105
|
response = bd.request( request )
|
105
106
|
end
|
107
|
+
assert_equal bd.timeout, timeout_error.timeout
|
106
108
|
end
|
107
109
|
|
108
110
|
describe "with expected errors" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: borrow_direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|