kosher 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/kosher/offer.rb CHANGED
@@ -5,7 +5,8 @@ module Kosher
5
5
  :description,
6
6
  :ships_in,
7
7
  :ships_free,
8
- :cents)
8
+ :cents,
9
+ :listing_id)
9
10
 
10
11
  def self.build(doc)
11
12
  offer = new
@@ -19,6 +20,7 @@ module Kosher
19
20
  offer.ships_in = listing['AvailabilityAttributes']['MaximumHours'].to_i
20
21
  offer.ships_free = listing['IsEligibleForSuperSaverShipping'] == '1'
21
22
  offer.cents = listing['Price']['Amount'].to_i
23
+ offer.listing_id = listing['OfferListingId']
22
24
 
23
25
  offer
24
26
  end
data/lib/kosher/seller.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  module Kosher
2
- class Seller < Struct.new(:merchant_id, :average_rating)
2
+ class Seller < Struct.new(:merchant_id, :name, :average_rating)
3
3
  class << self
4
4
  attr_accessor :blacklist
5
5
 
6
6
  def build(doc)
7
7
  merchant_id = doc['MerchantId']
8
+ name = doc['Name']
8
9
  average_rating = doc['AverageFeedbackRating'].to_f
9
10
 
10
- new(merchant_id, average_rating)
11
+ new(merchant_id, name, average_rating)
11
12
  end
12
13
  end
13
14
 
@@ -1,3 +1,3 @@
1
1
  module Kosher
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -28,6 +28,11 @@ module Kosher
28
28
  end.should_not raise_error
29
29
  end
30
30
 
31
+ it "populates the offer listing ID" do
32
+ offer = Offer.build(doc)
33
+ offer.listing_id.should_not be_nil
34
+ end
35
+
31
36
  it "should handle blank descriptions" do
32
37
  doc['OfferAttributes']['ConditionNote'] = ''
33
38
  offer = Offer.build(doc)
@@ -16,19 +16,25 @@ module Kosher
16
16
  algorithm.instance_variable_get(:@response)
17
17
  end
18
18
 
19
- let(:sellers) do
20
- response.find("Merchant")
19
+ let(:seller) do
20
+ docs = response.find('Merchant')
21
+ Seller.build(docs.first)
21
22
  end
22
23
 
23
- it "builds a seller" do
24
- seller = Seller.build(sellers.first)
25
-
24
+ it "populates the merchant ID of a seller" do
26
25
  seller.merchant_id.should match /^[0-9A-Z]{13,14}$/
26
+ end
27
+
28
+ it "populates the name of a seller" do
29
+ seller.name.should_not be_nil
30
+ end
31
+
32
+ it "populates the average rating of a seller" do
27
33
  seller.average_rating.should be_an_instance_of Float
28
34
  end
29
35
 
30
36
  it "builds a newly-launched seller" do
31
- doc = sellers.detect { |doc| doc["AverageFeedbackRating"] == "0.0" }
37
+ doc = response.find('Merchant').detect { |doc| doc["AverageFeedbackRating"] == "0.0" }
32
38
  new_seller = Seller.build(doc)
33
39
 
34
40
  new_seller.average_rating.should eql 0.0
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kosher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.6
5
+ version: 0.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paper Cavalier
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-04 00:00:00 +00:00
13
+ date: 2011-03-07 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency