trawler 0.0.1 → 0.0.2

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: f2215c97872959bff772658f412a924f9d4f6357
4
- data.tar.gz: 5ed5422791ad8fe45a668984c17ad84dba60d924
3
+ metadata.gz: 933f90b39be83ae7cf959157b7a0ee98d69f3b86
4
+ data.tar.gz: ebb64ed51ebbd8618b714db0e60d833a10be0756
5
5
  SHA512:
6
- metadata.gz: 1fe1b9aa090d52b281b38b1e948613eb37192c4872a0de922c8335ca9b6757c53ffa839ad462c083f9f31a6fcbc568412d8f414c57ea47f10854459002e4fdfe
7
- data.tar.gz: b082e3234696d8bb0cd99346fa71816eb98e4062973e94e4e3cf7c2e6b42154200382507da7ef058348faf8c52a9baea8a0133be67be451766236c3dbe287e93
6
+ metadata.gz: e5a0d1b0bc1cae4f46614c288e608534d4e18cd4052bcebe05541e5562aeedabff01033055a5038bb7f0a332639ecc0957120f638d1a5c7d6592a4b3f3e7a745
7
+ data.tar.gz: 0018ce6c9fb18886bc5f3038657b58473634e0aa1c2742471bd1522f3e7664eec2dff8b127da04c3a185cbcdce81a49905cb783677f2545a8f91fc4fe48fa8bb
@@ -22,10 +22,22 @@ module Trawler
22
22
  end
23
23
 
24
24
  def images
25
- images = []
26
- images << meta_image
25
+ images = [meta_image]
27
26
  images << find_images
28
- images.flatten.compact.map { |i| i.strip }.uniq
27
+ images.flatten!
28
+ images = images.select { |img| !img.nil? }.select { |s| !s.empty? }
29
+ images.flatten.map! { |img| img.strip }.uniq
30
+ images.map { |img| normalize_url(img) }
31
+ end
32
+
33
+ def normalize_url(uri)
34
+ if uri =~ /^\w*\:/i
35
+ return uri
36
+ else
37
+ Addressable::URI.join(url, uri).normalize.to_s
38
+ end
39
+ rescue URI::InvalidURIError, Addressable::URI::InvalidURIError => e
40
+ add_fatal_error "Link parsing exception: #{e.message}" and nil
29
41
  end
30
42
 
31
43
  def video
@@ -53,7 +65,11 @@ module Trawler
53
65
  images.reject! { |img| img[:alt] =~ /(loading|spinner)/i }
54
66
  images.reject! { |img| img[:class] =~ /(loading|spinner|icon)/i }
55
67
  images.reject! { |img| img[:width] && img[:width] < @min_image_size }
56
- images.map { |img| img[:src] }
68
+ buzzfeed_images = images.map { |i| i["rel:bf_image_src"].to_s }
69
+ images.reject! { |img| img[:src] =~ /(background|icons|icon)/i }
70
+ images.map! { |img| img[:src] }
71
+ images << buzzfeed_images
72
+ # images
57
73
  end
58
74
 
59
75
  def meta_title
@@ -1,3 +1,3 @@
1
1
  module Trawler
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end