link_thumbnailer 3.0.2 → 3.0.3
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/CHANGELOG.md +6 -0
- data/lib/link_thumbnailer/exceptions.rb +7 -5
- data/lib/link_thumbnailer/parser.rb +3 -3
- data/lib/link_thumbnailer/processor.rb +3 -1
- data/lib/link_thumbnailer/scrapers/default/images.rb +1 -1
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/processor_spec.rb +1 -1
- 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: 42c12677181ae4f47f9809a31f3b857e90b6de3f
|
4
|
+
data.tar.gz: d6e394503da26997c9c5cf67c58f0d9c2bea62ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d29145f60542d6a5b7b8a8ba1fddc76587823348e78bf38830b3b6d75772c53e37bda89281a0586f2a56b1a0869df9ea964cc0f58d925e8d8ef2a3a067207d5
|
7
|
+
data.tar.gz: 1980e7240d0c7fbe42a652ac7c1e29feceb90579dd3a6e46526cfb12d381c67e4ef55bcfd13a6d55a37a00f20cc8b37647fef6595e1bd18ca26f10e2ea56d52b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 3.0.3
|
2
|
+
|
3
|
+
- Fix an issue when dealing with absolute urls. https://github.com/gottfrois/link_thumbnailer/issues/68
|
4
|
+
- Fix an issue with http redirection and location header not beeing present. https://github.com/gottfrois/link_thumbnailer/issues/70
|
5
|
+
- Rescue and raise custom LinkThumbnailer exceptions. https://github.com/gottfrois/link_thumbnailer/issues/71
|
6
|
+
|
1
7
|
# 3.0.2
|
2
8
|
|
3
9
|
- Replace FastImage gem dependency by [ImageInfo](https://github.com/gottfrois/image_info) to improve performances when
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module LinkThumbnailer
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
Exceptions = Class.new(StandardError)
|
3
|
+
RedirectLimit = Class.new(Exceptions)
|
4
|
+
BadUriFormat = Class.new(Exceptions)
|
5
|
+
FormatNotSupported = Class.new(Exceptions)
|
6
|
+
ScraperInvalid = Class.new(Exceptions)
|
7
|
+
HTTPError = Class.new(Exceptions)
|
8
|
+
SyntaxError = Class.new(Exceptions)
|
7
9
|
end
|
@@ -3,10 +3,10 @@ require 'nokogiri'
|
|
3
3
|
module LinkThumbnailer
|
4
4
|
class Parser
|
5
5
|
|
6
|
-
attr_reader :document
|
7
|
-
|
8
6
|
def call(source)
|
9
|
-
|
7
|
+
::Nokogiri::HTML(source)
|
8
|
+
rescue ::Nokogiri::XML::SyntaxError => e
|
9
|
+
raise ::LinkThumbnailer::SyntaxError.new(e.message)
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -26,6 +26,8 @@ module LinkThumbnailer
|
|
26
26
|
set_http_options
|
27
27
|
perform_request
|
28
28
|
end
|
29
|
+
rescue ::Net::HTTPExceptions, ::SocketError, ::Timeout::Error => e
|
30
|
+
raise ::LinkThumbnailer::HTTPError.new(e.message)
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -60,7 +62,7 @@ module LinkThumbnailer
|
|
60
62
|
response.body
|
61
63
|
when ::Net::HTTPRedirection
|
62
64
|
call(
|
63
|
-
resolve_relative_url(response['location']),
|
65
|
+
resolve_relative_url(response['location'].to_s),
|
64
66
|
redirect_count + 1,
|
65
67
|
headers
|
66
68
|
)
|
data/spec/processor_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe LinkThumbnailer::Processor do
|
|
38
38
|
stub_request(:get, url).to_return(status: 500, body: '', headers: {})
|
39
39
|
end
|
40
40
|
|
41
|
-
it { expect { action }.to raise_error(
|
41
|
+
it { expect { action }.to raise_error(LinkThumbnailer::HTTPError) }
|
42
42
|
|
43
43
|
end
|
44
44
|
|
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.0.
|
4
|
+
version: 3.0.3
|
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: 2015-
|
11
|
+
date: 2015-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|