kosher 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kosher/item.rb +6 -5
- data/lib/kosher/version.rb +1 -1
- data/spec/kosher/item_spec.rb +1 -3
- metadata +1 -1
data/lib/kosher/item.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Kosher
|
2
|
-
class Item < Struct.new(:asin, :offers, :sales_rank)
|
2
|
+
class Item < Struct.new(:asin, :offers, :offers_count, :sales_rank)
|
3
3
|
|
4
4
|
class << self
|
5
5
|
def build(doc)
|
6
|
-
asin
|
7
|
-
sales_rank
|
8
|
-
|
6
|
+
asin = doc['ASIN']
|
7
|
+
sales_rank = doc['SalesRank'].to_i
|
8
|
+
offers_count = doc['Offers']['TotalOffers'].to_i
|
9
|
+
offers = build_offers(doc['Offers']['Offer'])
|
9
10
|
|
10
|
-
new(asin, offers, sales_rank)
|
11
|
+
new(asin, offers, offers_count, sales_rank)
|
11
12
|
end
|
12
13
|
|
13
14
|
private
|
data/lib/kosher/version.rb
CHANGED
data/spec/kosher/item_spec.rb
CHANGED
@@ -24,10 +24,8 @@ module Kosher
|
|
24
24
|
it "should build an item" do
|
25
25
|
item.should be_a Item
|
26
26
|
item.asin.should eql asin
|
27
|
+
item.offers_count.should be > 0
|
27
28
|
item.sales_rank.should be > 0
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should build the offers of an item" do
|
31
29
|
item.offers.count.should > 0
|
32
30
|
item.offers.first.should be_a Offer
|
33
31
|
end
|