bazaar_sources 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. data/lib/api_helpers/amazon.rb +11 -5
  2. metadata +4 -4
@@ -376,8 +376,8 @@ module Amazon
376
376
  rating_block = seller_info.at("div.rating")
377
377
  unless rating_block.nil?
378
378
  rating_text = rating_block.inner_text
379
- if rating_text =~ /\((\d+) ratings\)/
380
- num_merchant_reviews = $1.to_i
379
+ if rating_text =~ /\(([\d,]+).+? ratings\)/
380
+ num_merchant_reviews = $1.gsub!(/\D/,'').to_i
381
381
  end
382
382
  end
383
383
  rating_link = seller_info.at("div.rating/a")
@@ -424,7 +424,7 @@ module Amazon
424
424
  name = safe_strip(seller_label_link.inner_text)
425
425
  merchant_type = 'seller'
426
426
  end
427
-
427
+
428
428
  # Availability
429
429
  in_stock = true
430
430
  availability_element = seller_info.at("div.availability")
@@ -597,8 +597,14 @@ module Amazon
597
597
 
598
598
  query = "GET\n#{host}\n#{path}\n#{params_string}"
599
599
  # hmac = Digest::HMAC.new(AMAZON_SECRET_ACCESS_KEY, Digest::SHA256).digest(query)
600
- digest = OpenSSL::Digest::Digest.new("sha256")
601
- hmac = OpenSSL::HMAC.digest(digest, AMAZON_SECRET_ACCESS_KEY, query)
600
+ begin
601
+ digest = OpenSSL::Digest::Digest.new("sha256")
602
+ hmac = OpenSSL::HMAC.digest(digest, AMAZON_SECRET_ACCESS_KEY, query)
603
+ rescue RuntimeError => e
604
+ # ruby 1.9
605
+ require 'digest/sha2'
606
+ hmac = Digest::HMAC.new(AMAZON_SECRET_ACCESS_KEY, Digest::SHA256).digest(query)
607
+ end
602
608
 
603
609
  base64_hmac = Base64.encode64(hmac).chomp
604
610
  signature = CGI::escape(base64_hmac)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bazaar_sources
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - chris mcc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-13 00:00:00 +00:00
18
+ date: 2010-08-31 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency