wedding_registry_scraper 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a465ddaeee431049efa8067c9d06e261c0f8a0be
4
- data.tar.gz: c552ff0e195de60c8e921b4d8735b9fa5590d0ba
3
+ metadata.gz: 5d8773e57fa2aff9cfceea050e4ee16713cb75f9
4
+ data.tar.gz: 373b3abffa0e75eebb28234c08f4ae29d19d36c6
5
5
  SHA512:
6
- metadata.gz: 8a2acb4103b4958ad7e1a6df069d726cbc3c33bf03f96cfaf39e1a420a5bf4ed0648ef4230f6672942de5072d2d0021dd23f31515097da5adf923b122482aaa6
7
- data.tar.gz: cceef06629a982910be1aae58af295ad290a9b500ef6dce31a95ba4658042b81ee38449a97762ef134fd350f5abac80ed68ffcbd1a5ae146d13973c885646c04
6
+ metadata.gz: 52f046314cabb11d5251e82e37b8f9d7cfadf63804f696cc65f3f3375daa2cde8e19e00a3c80caefd36db36bc92be77349476110bf745fca93acd140dc6f8822
7
+ data.tar.gz: 0841a1975c3fc383e48af6d8b1bf0d1e603258233e64c9f940bd56db00dbe554c2fb5f314bddf97542ea7f97b2ae8580aebbcc0f996632206f6473d3bd5bb03d
@@ -3,8 +3,9 @@ class WeddingRegistryScraper::Registries::Rei < WeddingRegistryScraper::Registry
3
3
  @domain = "rei.com"
4
4
  private
5
5
  def get_product_details_url(product)
6
- href = product.css('a[name=prod]')[0]['href'].sub(/^\/?/, '')
7
- "https://www.rei.com/#{href.sub(/^\//, '')}"
6
+ link = product.css('a[name=prod]')
7
+ return if link.empty?
8
+ "https://www.rei.com/#{link[0]['href'].sub(/^\/?/, '')}"
8
9
  end
9
10
 
10
11
  def get_products(doc)
@@ -12,11 +13,11 @@ private
12
13
  end
13
14
 
14
15
  def get_name(product)
15
- product.css('a[name=prod]').text.strip
16
+ product.css('td')[1].children.first.text.strip
16
17
  end
17
18
 
18
19
  def get_sku(product)
19
- sku = get_product_details_url(product).match(/\/product\/(\d+)/)[1].to_i
20
+ sku = product.css('td')[1].children.last.text.strip
20
21
  "rei-#{sku}"
21
22
  end
22
23
 
@@ -26,6 +27,7 @@ private
26
27
 
27
28
  def get_image_url(product)
28
29
  details_url = get_product_details_url(product)
30
+ return "" if details_url.blank?
29
31
 
30
32
  puts "GET #{details_url.inspect}" if @debug
31
33
  result = Unirest.get(details_url)
@@ -1,5 +1,5 @@
1
1
  module WeddingRegistryScraper
2
- VERSION = Gem::Version.new("0.0.5")
2
+ VERSION = Gem::Version.new("0.0.6")
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wedding_registry_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Pariser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unirest