lib/service_adaptors/internet_archive.rb in umlaut-3.0.0beta5 vs lib/service_adaptors/internet_archive.rb in umlaut-3.0.0beta6

- old
+ new

@@ -102,29 +102,20 @@ # create one link that searches all configured mediatypes link = @url + ia_params(search_terms) # using open() conveniently follows the redirect for us. Alas, it # doesn't give us access to the IA http status code response though. - begin - response = nil - timeout(@http_timeout.to_i) { - response = open(link).read - } - rescue Exception => e - # Log more info for exception, and then just forward exception on, - # we don't have any way to handle it. - Rails.logger.error("InternetArchive exception, for url[[#{link}]] , Exception #{e.class}") - raise e - end - + response = nil + timeout(@http_timeout.to_i) { + response = open(link).read + } if response.blank? - Rails.logger.warn("InternetArchive returned empty response for #{link}") - return nil + raise Exception.new("InternetArchive returned empty response for #{link}") end - doc = MultiJson.decode(response) + doc = MultiJson.load(response) results = doc['response']['docs'] @mediatypes.each do |type| type_results = get_results_by_type(results, type) @@ -256,18 +247,18 @@ # Downcase params to avoid weird misconfiguration in IA's SOLR # installation, where it's interpreting uppercase words as # commands even within quotes. output = string.downcase - # Remove parens, semi-colons, and brackets -- they all mess + # Remove parens, semi-colons, brackets, hyphens -- they all mess # up IA, which thinks they are special chars. Remove double quote, # special char, which sometimes we want to use ourselves. Replace # all with spaces to avoid accidentally conjoining words. # (could be # escaping instead? Not worth it, we don't want to search # on these anyway. Remove ALL punctuation? Not sure.) - output.gsub!(/[)(\]\[;"\=]/, ' ') + output.gsub!(/[)(\]\[;"\=\-]/, ' ') return output end @@ -483,6 +474,6 @@ # needed apostrophe to succeed # Goody Two-Shoes: http://www.worldcat.org/oclc/32678428 # The Snow-Image: http://www.worldcat.org/oclc/5020610 # Les Canadiens-Français: http://www.worldcat.org/oclc/186641188 # FIXME should match 1 record and doesn't. character encoding problems? -# John L. Stoddard's Lectures: http://www.worldcat.org/oclc/2181690 \ No newline at end of file +# John L. Stoddard's Lectures: http://www.worldcat.org/oclc/2181690