Sha256: 9217f1428dade0236e1a35f4973bb69bfac3ac2cd850e338ed276356abc51ad4

Contents?: true

Size: 1.05 KB

Versions: 59

Compression:

Stored size: 1.05 KB

Contents

# Link to BookFinder.com to compare online new and used prices for a book.
# Requires an ISBN.
# Does not a pre-check, just generates the link blind, but I think almost any
# ISBN will get results on BookFinder.
class BookFinder < Service
  require 'isbn'
  
  def initialize(config)
    @display_text = "Compare online prices"
    @display_name = "BookFinder.com"
    # %s is where the ISBN goes
    @url_template = 'http://www.bookfinder.com/search/?isbn=%s&st=xl&ac=qr'

    super(config)
  end

  def service_types_generated
    return [ServiceTypeValue['highlighted_link']]
  end

  def handle(umlaut_request)
    isbn = umlaut_request.referent.isbn

    # Unless we have a valid isbn, give up
    return request.dispatched(self, true) unless isbn && ISBN.valid?(isbn)

    # Okay, make a link
    url = @url_template.sub('%s', isbn)

    umlaut_request.add_service_response(
      :service=>self, 
      :url=> url, 
      :display_text=> @display_text, 
      :service_type_value => :highlighted_link
     )

    return request.dispatched(self, true)    
  end
  
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
umlaut-4.1.7 app/service_adaptors/book_finder.rb
umlaut-4.1.6 app/service_adaptors/book_finder.rb
umlaut-4.1.5 app/service_adaptors/book_finder.rb
umlaut-4.1.4 app/service_adaptors/book_finder.rb
umlaut-4.1.3 app/service_adaptors/book_finder.rb
umlaut-4.1.2 app/service_adaptors/book_finder.rb
umlaut-4.1.1 app/service_adaptors/book_finder.rb
umlaut-4.1.0 app/service_adaptors/book_finder.rb
umlaut-4.1.0.pre3 app/service_adaptors/book_finder.rb
umlaut-4.1.0.pre.2 app/service_adaptors/book_finder.rb
umlaut-4.1.0.pre.alpha.1 app/service_adaptors/book_finder.rb
umlaut-4.0.3 app/service_adaptors/book_finder.rb
umlaut-4.0.2 app/service_adaptors/book_finder.rb
umlaut-4.0.1 app/service_adaptors/book_finder.rb
umlaut-4.0.0 app/service_adaptors/book_finder.rb
umlaut-4.0.0.beta5 app/service_adaptors/book_finder.rb
umlaut-4.0.0.beta4 app/service_adaptors/book_finder.rb
umlaut-4.0.0.beta3 app/service_adaptors/book_finder.rb
umlaut-4.0.0.beta2 app/service_adaptors/book_finder.rb
umlaut-4.0.0.beta1 app/service_adaptors/book_finder.rb