link_oracle 0.1.7 → 0.1.8

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: d19780fb7f9cd2688937b8cc94e32f3c82b514ac
4
- data.tar.gz: d4ebf911932fc368456526e26c19544b8e843762
3
+ metadata.gz: be327867cb2f7bb24b4f06cfd40d609fac3171c9
4
+ data.tar.gz: aeaea157fe4058f168e2130b50f286453afa97eb
5
5
  SHA512:
6
- metadata.gz: 36a66ac4d7f24a076fff08a21e892f365d8749da383cf3e006340c73fda2fb8f3ee4a0a626720561001850523c4e1dd3d176197656a5b0a9511279329ddb7d7c
7
- data.tar.gz: d30bbc6cbbd2abf2f2eb397b0648f6ee1921793d55e715ceb51cbeab4e751e413a7ec446c25b9a6e4e3426a8b6f86710b24f4f8e28d4fb7de0dcea54ac0c1f4e
6
+ metadata.gz: 37b17d27fc7f6ec1988cc75f1e0baebe92ec98775039740b7bddbbadabd3009a4fcc0db2b35abb8930645c91382c4f3cbdbd9af0495426bbab29f4717f375735
7
+ data.tar.gz: bc5f0db1a7cdfdc8abd5e0ba3e51dc62058239298441c62eaf3a49eeb96c889e468b0b62e79ed1da74fd4cfcdf9a52e48d4014d83ed4acf03ca9d8c3b9af3798
@@ -20,7 +20,7 @@ class LinkOracle
20
20
  end
21
21
 
22
22
  def images
23
- @images ||= valid_size_images
23
+ @images ||= first_valid_size_image ? [first_valid_size_image] : []
24
24
  end
25
25
 
26
26
  def parsed_images
@@ -30,11 +30,11 @@ class LinkOracle
30
30
  end
31
31
 
32
32
  def formatted_images
33
- parsed_images.map { |image_url| ::Utils::ImageUrlFormatter.new(url, image_url).perform }
33
+ @formatted_images ||= parsed_images.map { |image_url| ::Utils::ImageUrlFormatter.new(url, image_url).perform }
34
34
  end
35
35
 
36
- def valid_size_images
37
- formatted_images.select do |image|
36
+ def first_valid_size_image
37
+ @first_valid_size_image ||= formatted_images.find do |image|
38
38
  size = image_size(image)
39
39
  size[0] >= 100 && size[1] >= 100 if size
40
40
  end
@@ -1,3 +1,3 @@
1
1
  class LinkOracle
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -75,12 +75,9 @@ describe LinkOracle::Extractor::Body do
75
75
  FastImage.stub(:size).and_return([100, 121])
76
76
  end
77
77
 
78
- it 'should populate link_data image_urls' do
78
+ it 'should populate link_data image_urls with the first image of the right size' do
79
79
  expect(link_data.image_urls).to match_array([
80
- "http://berkin.com",
81
- "http://cherbin.com",
82
- "http://flerbin.com",
83
- "http://berkin.com/berkin/cherbin.jpg"
80
+ "http://berkin.com"
84
81
  ])
85
82
  end
86
83
  end
@@ -92,14 +89,13 @@ describe LinkOracle::Extractor::Body do
92
89
  end
93
90
 
94
91
  context 'some images are correct size and some are not' do
95
- it 'should populate link_data image_urls only with the correctly sized images' do
92
+ it 'should populate link_data image_urls only with the first correctly sized images' do
96
93
  FastImage.should_receive(:size).with("http://berkin.com").and_return([50, 60])
97
- FastImage.should_receive(:size).with("http://flerbin.com").and_return([60, 55])
98
- FastImage.should_receive(:size).with("http://cherbin.com").and_return([160, 155])
99
94
  FastImage.should_receive(:size).with("http://berkin.com/berkin/cherbin.jpg").and_return([160, 155])
95
+ FastImage.should_not_receive(:size).with("http://cherbin.com")
96
+ FastImage.should_not_receive(:size).with("http://flerbin.com")
100
97
 
101
98
  expect(link_data.image_urls).to match_array([
102
- "http://cherbin.com",
103
99
  "http://berkin.com/berkin/cherbin.jpg"
104
100
  ])
105
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_oracle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Cooper
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-11-11 00:00:00.000000000 Z
16
+ date: 2014-11-13 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: nokogiri