lib/alexandria/book_providers/adlibris.rb in alexandria-book-collection-manager-0.7.2 vs lib/alexandria/book_providers/adlibris.rb in alexandria-book-collection-manager-0.7.3
- old
+ new
@@ -65,11 +65,11 @@
end
## url
def url(book)
create_search_uri(SEARCH_BY_ISBN, book.isbn)
- rescue => ex
+ rescue StandardError => ex
log.warn { "Cannot create url for book #{book}; #{ex.message}" }
nil
end
private
@@ -78,11 +78,11 @@
if search_type == SEARCH_BY_ISBN
PRODUCT_URL % Library.canonicalise_isbn(search_term)
else
(search_type_code = {
SEARCH_BY_AUTHORS => 'author',
- SEARCH_BY_TITLE => 'title',
+ SEARCH_BY_TITLE => 'title',
SEARCH_BY_KEYWORD => 'keyword'
}[search_type]) || 'keyword'
search_term_encoded = CGI.escape(search_term)
format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
end
@@ -183,10 +183,11 @@
isbn_tds = doc.search("li[@id *= 'liISBN'] td[text()]")
isbn_tds.each do |isbn_td|
isbn = isbn_td.inner_text
next unless isbn =~ /[0-9x]{10,13}/i
+
isbn.gsub(/(\n|\r)/, ' ')
isbn = Regexp.last_match[1] if isbn =~ /:[\s]*([0-9x]+)/i
isbns << isbn
end
isbn = isbns.first
@@ -209,11 +210,12 @@
end
book = Book.new(title, authors, isbn, publisher, year, binding)
return [book, image_url]
- rescue => ex
+ rescue StandardError => ex
raise ex if ex.instance_of? NoResultsError
+
trace = ex.backtrace.join("\n> ")
log.warn {
'Failed parsing search results for AdLibris ' \
"#{ex.message} #{trace}"
}