README.md in sucker-0.5.0 vs README.md in sucker-0.6.0

- old
+ new

@@ -1,9 +1,9 @@ Sucker ====== -Sucker is a thin Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on Curb and XmlSimple and supports __everything__ in the API. +Sucker is a paper-thin Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on cURL and Nokogiri and supports __everything__ in the API. ![Sucker](http://upload.wikimedia.org/wikipedia/en/7/71/Vacuum_cleaner_1910.JPG) Examples -------- @@ -22,46 +22,49 @@ Set up a request. worker << { "Operation" => "ItemLookup", "IdType" => "ASIN", - "ItemId" => ["0816614024", "0143105825"] } + "ItemId" => asin_batch Hit Amazon and do something with the response. response = worker.get p response.code p response.time p response.body - response.to_h["Items"]["Item"].each { ... } + response.to_h["ItemLookupResponse"]["Items"]["Item"].each { ... } Hit Amazon again. - worker << { - "ItemId" => 10.more.asins } + worker << { "ItemId" => another_asin_batch } response = worker.get Check the integration specs for more examples. Testing ------- -To fake web requests, I do the following: +To fake web requests, create `spec/support/sucker.rb` and: -In a file such as `spec/support/sucker.rb`, I prep: - require "sucker/stub" Sucker.fixtures_path = File.dirname(__FILE__) + "/../fixtures" -In the spec, I set up a worker and then stub it: +Then, in your spec, stub the worker: + @worker = Sucker.new(some_hash) Sucker.stub(@worker) -The first time you run the spec, the worker will perform the actual web request and cache the response. Subsequent requests are then mocked with the cached response. +The first time you run the spec, Sucker will perform the actual web request and cache the response. Then, it will stub subsequent requests with the cached response. Notes ----- * The unit specs should run out of the box after you `bundle install`, but the integration specs require you to create [an amazon.yml file with valid credentials](http://github.com/papercavalier/sucker/blob/master/spec/support/amazon.yml.example) in `spec/support`. -* Version 0.5.0 replaces Crack with XmlSimple, which results in a slightly different hash output. Fix up your code accordingly. +* Version 0.6.0 now has Active Support's Nokogiri-based `to_hash` under the hood. After some meddling, it does what it's supposed to do and is blazing fast. Fix up your code accordingly. + + user system total real + Crack 0.830000 0.010000 0.840000 ( 0.871951) + SimpleXml 2.470000 0.050000 2.520000 ( 2.560045) + AS + Nokogiri 0.440000 0.010000 0.450000 ( 0.450201)