link_thumbnailer 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd2de89ee93a079ce228bbf77fd1362e359f5ce8
4
- data.tar.gz: db435fc9864ba56d81d16425802f625e2faeeaf7
3
+ metadata.gz: 42c12677181ae4f47f9809a31f3b857e90b6de3f
4
+ data.tar.gz: d6e394503da26997c9c5cf67c58f0d9c2bea62ea
5
5
  SHA512:
6
- metadata.gz: 32bf121c87417dfb69a716a3ebb912367b1eb107794d268f342b8eb9bda090b986faea21ff2d2e9db2a4546cca0d39e9d833ec75d719c08b89776ca98fbbfa05
7
- data.tar.gz: 5ece7aa51e0a7211e0ac92e15c364591497f622dbfdd09d1525bb5aeca1cd4f14f65d1e67d2c89c86ca5eb9ee737b4f878ccac59be95548ff0170191616b4018
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
- class Exceptions < StandardError; end
3
- class RedirectLimit < Exceptions; end
4
- class BadUriFormat < Exceptions; end
5
- class FormatNotSupported < Exceptions; end
6
- class ScraperInvalid < Exceptions; end
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
- @document ||= ::Nokogiri::HTML(source)
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
  )
@@ -44,7 +44,7 @@ module LinkThumbnailer
44
44
  end
45
45
 
46
46
  def needs_prefix?(uri)
47
- !uri.is_a?(::URI::HTTP)
47
+ !uri.host
48
48
  end
49
49
 
50
50
  def prefix_uri(uri)
@@ -1,3 +1,3 @@
1
1
  module LinkThumbnailer
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3'
3
3
  end
@@ -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(Net::HTTPFatalError) }
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.2
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-07-10 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport