url_fetcher 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/url_fetcher/errors.rb +10 -0
- data/lib/url_fetcher.rb +1 -1
- data/spec/url_fetcher_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: 8c6eed420473ae21636daa796c36f23fb6dbea52
|
4
|
+
data.tar.gz: f5055142823e55cc5bb58dd1bdfa4d4c2e381e3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 082a8bf25261e514cb2f1bc41e5bf85063d0147689d3cb25b07239dd31839db54bad9774910683fb0ea9b44d8e9e78ce7cf51a92fab7c2d7ecfa64d265ea0d89
|
7
|
+
data.tar.gz: 54a1b9c69359f7e8886a3688200e8f24f18f96a35a7d9c09aa839e6b1b8896f63215043d3f08e13f4b16693b348a9877d613a488a588ee4a68b991dffcc471db
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/url_fetcher/errors.rb
CHANGED
@@ -13,6 +13,16 @@ class UrlFetcher
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
class FileTooBig < Error
|
17
|
+
attr_reader :size
|
18
|
+
def initialize(size)
|
19
|
+
@size = size
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
"File too big (#{size} bytes)"
|
24
|
+
end
|
25
|
+
end
|
16
26
|
|
17
27
|
class CircularRedirect < Error
|
18
28
|
attr_reader :url
|
data/lib/url_fetcher.rb
CHANGED
@@ -90,7 +90,7 @@ class UrlFetcher
|
|
90
90
|
end
|
91
91
|
if resp.is_a?(Net::HTTPSuccess) && resp.class.body_permitted?
|
92
92
|
content_length = resp["Content-Length"].to_i
|
93
|
-
raise
|
93
|
+
raise FileTooBig.new(content_length) if content_length > (options[:max_size] || 10 * MEGABYTE)
|
94
94
|
tempfile = Tempfile.new("url_fetcher", :encoding => 'ascii-8bit')
|
95
95
|
resp.read_body(tempfile)
|
96
96
|
tempfile.close
|
data/spec/url_fetcher_spec.rb
CHANGED
@@ -123,6 +123,6 @@ describe UrlFetcher do
|
|
123
123
|
WebMock.stub_request(:get, "http://example.com/test").to_return(:status => 200, :body => "Hello", :headers => {"Content-Length" => 1001})
|
124
124
|
expect do
|
125
125
|
UrlFetcher.new("http://example.com/test", :max_size => 1000)
|
126
|
-
end.to raise_error
|
126
|
+
end.to raise_error(UrlFetcher::FileTooBig)
|
127
127
|
end
|
128
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- weheartit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|