link_thumbnailer 1.0.4 → 1.0.5

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.5
2
+
3
+ - Thanks to [phlegx](https://github.com/phlegx), support for timeout http connection through configurations.
4
+
1
5
  # 1.0.4
2
6
 
3
7
  - Fix issue #7: nil img was returned when exception is raised. Now skiping nil images in results.
data/README.md CHANGED
@@ -143,6 +143,9 @@ In `config/initializers/link_thumbnailer.rb`
143
143
 
144
144
  # Enable or disable SSL verification
145
145
  # config.verify_ssl = true
146
+
147
+ # HTTP open_timeout: The amount of time in seconds to wait for a connection to be opened.
148
+ # config.http_timeout = 5
146
149
  end
147
150
 
148
151
  ## Features
@@ -35,4 +35,7 @@ LinkThumbnailer.configure do |config|
35
35
 
36
36
  # Enable or disable SSL verification
37
37
  # config.verify_ssl = true
38
+
39
+ # HTTP open_timeout: The amount of time in seconds to wait for a connection to be opened.
40
+ # config.http_timeout = 5
38
41
  end
@@ -37,7 +37,8 @@ module LinkThumbnailer
37
37
  :limit => 10,
38
38
  :top => 5,
39
39
  :user_agent => 'linkthumbnailer',
40
- :verify_ssl => true
40
+ :verify_ssl => true,
41
+ :http_timeout => 5
41
42
  )
42
43
  end
43
44
 
@@ -18,6 +18,7 @@ module LinkThumbnailer
18
18
  http = Net::HTTP::Persistent.new('linkthumbnailer')
19
19
  http.headers['User-Agent'] = LinkThumbnailer.configuration.user_agent
20
20
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless LinkThumbnailer.configuration.verify_ssl
21
+ http.open_timeout = LinkThumbnailer.configuration.http_timeout
21
22
  resp = http.request(self.url)
22
23
  case resp
23
24
  when Net::HTTPSuccess; resp.body
@@ -1,3 +1,3 @@
1
1
  module LinkThumbnailer
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -29,6 +29,7 @@ describe LinkThumbnailer do
29
29
  config.top = 10
30
30
  config.user_agent = 'linkthumbnailer'
31
31
  config.verify_ssl = true
32
+ config.http_timeout = 5
32
33
  }
33
34
  end
34
35
 
@@ -45,6 +46,7 @@ describe LinkThumbnailer do
45
46
  specify { LinkThumbnailer.configuration.top.should eq(10) }
46
47
  specify { LinkThumbnailer.configuration.user_agent.should eq('linkthumbnailer') }
47
48
  specify { LinkThumbnailer.configuration.verify_ssl.should be_true }
49
+ specify { LinkThumbnailer.configuration.http_timeout.should eq(5) }
48
50
 
49
51
  end
50
52
 
@@ -68,6 +70,7 @@ describe LinkThumbnailer do
68
70
  specify { LinkThumbnailer.configuration.top.should eq(5) }
69
71
  specify { LinkThumbnailer.configuration.user_agent.should eq('linkthumbnailer') }
70
72
  specify { LinkThumbnailer.configuration.verify_ssl.should be_true }
73
+ specify { LinkThumbnailer.configuration.http_timeout.should eq(5) }
71
74
 
72
75
  end
73
76
 
@@ -117,6 +120,11 @@ describe LinkThumbnailer do
117
120
  it "should set verify_ssl option" do
118
121
  expect { LinkThumbnailer.generate('foo', verify_ssl: false).to change(LinkThumbnailer.configuration.verify_ssl).from(true).to(false) }
119
122
  end
123
+
124
+ it "should set http_timeout option" do
125
+ expect { LinkThumbnailer.generate('foo', http_timeout: 2).to change(LinkThumbnailer.configuration.http_timeout).from(5).to(2) }
126
+ end
127
+
120
128
  end
121
129
 
122
130
  context "when strict" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_thumbnailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-01 00:00:00.000000000 Z
12
+ date: 2013-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri