link_oracle 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/link_oracle/extractor/body.rb +4 -4
- data/lib/link_oracle/version.rb +1 -1
- data/spec/link_oracle/extractor/body_spec.rb +5 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be327867cb2f7bb24b4f06cfd40d609fac3171c9
|
4
|
+
data.tar.gz: aeaea157fe4058f168e2130b50f286453afa97eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 ||=
|
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
|
37
|
-
formatted_images.
|
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
|
data/lib/link_oracle/version.rb
CHANGED
@@ -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.
|
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-
|
16
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: nokogiri
|