link_thumbnailer 3.2.0 → 3.2.1
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 +4 -4
- data/.travis.yml +1 -3
- data/CHANGELOG.md +7 -0
- data/lib/link_thumbnailer/image_parser.rb +1 -1
- data/lib/link_thumbnailer/processor.rb +1 -1
- data/lib/link_thumbnailer/scrapers/base.rb +1 -1
- data/lib/link_thumbnailer/scrapers/opengraph/image.rb +5 -1
- data/lib/link_thumbnailer/uri.rb +18 -0
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/processor_spec.rb +1 -1
- data/spec/uri_spec.rb +42 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f99697da11cef790d10eddde8f79ad1dd4a2e1e6
|
4
|
+
data.tar.gz: c113e7b8c50dda3e4ead33dde327b0beec15435d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4f15babf9656fa90eae2cd10c9634011e766f02319e8d80ed03bb47149e30770420c6e17b3d4b91488022b7df4c1ed1cbc2f41b7d5b850f55d514708aed74fa
|
7
|
+
data.tar.gz: 1572e848bf83ae6eba3bef808474b2ca466b13d8b6ce467c73f0768cd0f57247083400a9a05823cd247a45fe5765438ae242bb2731804c2a6b2e64391896c554
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,7 @@ module LinkThumbnailer
|
|
6
6
|
attr_reader :images
|
7
7
|
|
8
8
|
def initialize(urls)
|
9
|
-
@images = perform? ? ::ImageInfo.from(urls, max_concurrency: max_concurrency) : Array(urls).map(&method(:build_default_image))
|
9
|
+
@images = perform? ? ::ImageInfo.from(urls, max_concurrency: max_concurrency) : Array(urls).compact.map(&method(:build_default_image))
|
10
10
|
end
|
11
11
|
|
12
12
|
def size
|
@@ -39,7 +39,7 @@ module LinkThumbnailer
|
|
39
39
|
|
40
40
|
def set_http_headers(headers = {})
|
41
41
|
headers.each { |k, v| http.headers[k] = v }
|
42
|
-
http.
|
42
|
+
http.override_headers['User-Agent'] = user_agent
|
43
43
|
http.override_headers['Accept-Encoding'] = 'none'
|
44
44
|
end
|
45
45
|
|
@@ -47,7 +47,7 @@ module LinkThumbnailer
|
|
47
47
|
value = options.fetch(:value, :content)
|
48
48
|
attribute = options.fetch(:attribute, attribute_name)
|
49
49
|
|
50
|
-
document.xpath("//meta[translate(@#{key},'#{abc.upcase}','#{abc}') = '#{attribute}' and @#{value}]")
|
50
|
+
document.xpath("//meta[translate(@#{key},'#{abc.upcase}','#{abc}') = '#{attribute}' and string-length(@#{value}) > 0]")
|
51
51
|
end
|
52
52
|
|
53
53
|
def abc
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'link_thumbnailer/scrapers/opengraph/base'
|
2
|
+
require 'link_thumbnailer/uri'
|
2
3
|
|
3
4
|
module LinkThumbnailer
|
4
5
|
module Scrapers
|
@@ -20,7 +21,10 @@ module LinkThumbnailer
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def model
|
23
|
-
nodes.map
|
24
|
+
nodes.map do |n|
|
25
|
+
uri = LinkThumbnailer::URI.new(n.attributes['content'])
|
26
|
+
modelize(n, uri.to_s) if uri.valid?
|
27
|
+
end.compact
|
24
28
|
end
|
25
29
|
|
26
30
|
def modelize(node, text = nil)
|
data/spec/processor_spec.rb
CHANGED
@@ -106,7 +106,7 @@ describe LinkThumbnailer::Processor do
|
|
106
106
|
describe '#set_http_headers' do
|
107
107
|
|
108
108
|
let(:user_agent) { 'foo' }
|
109
|
-
let(:headers) { instance.send(:http).
|
109
|
+
let(:headers) { instance.send(:http).override_headers }
|
110
110
|
let(:action) { instance.send(:set_http_headers) }
|
111
111
|
|
112
112
|
before do
|
data/spec/uri_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinkThumbnailer::URI do
|
4
|
+
|
5
|
+
let(:uri) { 'http://foo.com' }
|
6
|
+
let(:instance) { described_class.new(uri) }
|
7
|
+
|
8
|
+
describe '#valid?' do
|
9
|
+
|
10
|
+
let(:action) { instance.send(:valid?) }
|
11
|
+
|
12
|
+
context 'when bad format' do
|
13
|
+
|
14
|
+
before do
|
15
|
+
instance.stub(:attribute).and_return("/invalid/path")
|
16
|
+
end
|
17
|
+
|
18
|
+
it { expect(action).to be_falsey }
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when valid format' do
|
23
|
+
|
24
|
+
before do
|
25
|
+
instance.stub(:attribute).and_return("http://foo.com")
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect(action).to be_truthy }
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#to_s' do
|
35
|
+
|
36
|
+
let(:action) { instance.to_s }
|
37
|
+
|
38
|
+
it { expect(action).to eq(uri) }
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_thumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Louis Gottfrois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/link_thumbnailer/scrapers/opengraph/title.rb
|
173
173
|
- lib/link_thumbnailer/scrapers/opengraph/video.rb
|
174
174
|
- lib/link_thumbnailer/scrapers/opengraph/videos.rb
|
175
|
+
- lib/link_thumbnailer/uri.rb
|
175
176
|
- lib/link_thumbnailer/version.rb
|
176
177
|
- lib/link_thumbnailer/video_parser.rb
|
177
178
|
- link_thumbnailer.gemspec
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- spec/scrapers/base_spec.rb
|
207
208
|
- spec/scrapers/opengraph/base_spec.rb
|
208
209
|
- spec/spec_helper.rb
|
210
|
+
- spec/uri_spec.rb
|
209
211
|
- spec/video_parser_spec.rb
|
210
212
|
homepage: https://github.com/gottfrois/link_thumbnailer
|
211
213
|
licenses: []
|
@@ -263,4 +265,5 @@ test_files:
|
|
263
265
|
- spec/scrapers/base_spec.rb
|
264
266
|
- spec/scrapers/opengraph/base_spec.rb
|
265
267
|
- spec/spec_helper.rb
|
268
|
+
- spec/uri_spec.rb
|
266
269
|
- spec/video_parser_spec.rb
|