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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTY4MWZjYWFkNWZlM2UyNzQxMWQ3M2E0OTcwZGY2MjBlMTlkZDI5ZQ==
4
+ Zjk4M2VkNzA1NWRmNjY5YmNkOTYyYTcyMmUxMzA5ZDkzZWQwNWU3OA==
5
5
  data.tar.gz: !binary |-
6
- YjQ5OTI1N2NjNGQzZjQ3Njc4NGQ0ZmE0MTlmNzY1NjA0ODlmNmIzYw==
6
+ ODVhYjgxMjhkZTA1MjhjYTNlOTE1OWEwN2Y5NDVlYmZmM2M3ZjQxOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzVhYmY2OTg2ZDg1ZmI5ZjMwOTIwYWNiYmQ1MzUwZDBiZWZhZjhmNjAxOWQ5
10
- OWNkYWFjZWY3ZDNlN2ZhMmYyNDI0OWFkMzQwMmE4MWQ0NTZhY2IxNjg2ZTBk
11
- OGE4M2RhYmM2MGRjMmNlNzQ2ZjA4ZTEyNjhjNDllN2UxOWRlMjQ=
9
+ MTA0MTE0NWFjMTViZjgyMmU1MWI0MGQyZTdiYmNkY2RhNTkxNTE2OWY5ZGM3
10
+ ZjU2M2FhYzg3ODQzYmExNzViMTI0Y2UwYjQzYjJlYmNiYmYyMmI3NDBjYTIy
11
+ OWRiYzdiM2M5MGFjZDRmOTkxNWQ2ZWNhMjhkN2ZhYjQ4M2VmOTc=
12
12
  data.tar.gz: !binary |-
13
- OGU0YTdiMDY3ZGE5ZDI3MjQxNjJiNTFlZjgxMzcwZjc3OWExN2UyYzAwNTVl
14
- NzM0NmM5ZWI0Y2EyZjVjMTliMDg3MjAxZDkxY2FhMDFkMzc0NTNhNjhkMTlh
15
- MzcyNzVlMjdiZDU3ZmE4NDRhMjY5ZTZjZjAyZjBkYmNiOTg3OGQ=
13
+ YTA4NzMxODE4OTgzMDg2ZmZjN2I0NTE0MmM1NjZlOGQwZjRiMmJkNDhjMzg3
14
+ Yjc0ZTg3N2I5OWYwMjQwNGRkNDc1YzIxMjk4YmRmMjcxZjY4YWNjNGM0MzIx
15
+ ZmVhYjc2OGU5NGY0NzBjMWY2ZDdhODU5MzM3NDU0NzUyMjBjZDE=
@@ -13,5 +13,11 @@ module BorrowDirect
13
13
  end
14
14
 
15
15
  class HttpError < Error ; end
16
- class HttpTimeoutError < HttpError ; end
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(.*)(,|\sand\s)/
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
@@ -1,3 +1,3 @@
1
1
  module BorrowDirect
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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
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-26 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient