dragonfly 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.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +6 -0
- data/README.md +1 -1
- data/lib/dragonfly/job/fetch_url.rb +11 -4
- data/lib/dragonfly/version.rb +1 -1
- data/spec/dragonfly/job/fetch_url_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: f4447e48d0b8ae55e37417b745ad6b41874460e3
|
4
|
+
data.tar.gz: eec72c3113796cfb2350b92d2f423f74c09c08a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b603153fca561242e794bf14dbbc2f5aa189d89d1bb61a680cc8592147f5f42742057dbc2a3817e1015b864876d9282a3b2407bd7525a779e44217b74ab17fd
|
7
|
+
data.tar.gz: e963b8c1b8791262b823d1b2af24f862cd799567da45cdd2676797c4822caa8c0ab5949596743032b95ac7486cc240698f88c982101f45d8570549d635406dbc
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -42,19 +42,19 @@ module Dragonfly
|
|
42
42
|
if data_uri?
|
43
43
|
update_from_data_uri
|
44
44
|
else
|
45
|
-
data =
|
45
|
+
data = get_following_redirects(url)
|
46
46
|
job.content.update(data, 'name' => filename)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
def
|
52
|
+
def get_following_redirects(url, redirect_limit=10)
|
53
53
|
raise TooManyRedirects, "url #{url} redirected too many times" if redirect_limit == 0
|
54
|
-
response =
|
54
|
+
response = get(url)
|
55
55
|
case response
|
56
56
|
when Net::HTTPSuccess then response.body || ""
|
57
|
-
when Net::HTTPRedirection then
|
57
|
+
when Net::HTTPRedirection then get_following_redirects(response['location'], redirect_limit-1)
|
58
58
|
else
|
59
59
|
response.error!
|
60
60
|
end
|
@@ -62,6 +62,13 @@ module Dragonfly
|
|
62
62
|
raise ErrorResponse.new(e.response.code.to_i, e.response.body)
|
63
63
|
end
|
64
64
|
|
65
|
+
def get(url)
|
66
|
+
url = parse_url(url)
|
67
|
+
http = Net::HTTP.new(url.host, url.port)
|
68
|
+
http.use_ssl = true if url.scheme == 'https'
|
69
|
+
response = http.get(url.request_uri)
|
70
|
+
end
|
71
|
+
|
65
72
|
def update_from_data_uri
|
66
73
|
mime_type, b64_data = uri.scan(/^data:([^;]+);base64,(.*)$/)[0]
|
67
74
|
if mime_type && b64_data
|
data/lib/dragonfly/version.rb
CHANGED
@@ -25,7 +25,7 @@ describe Dragonfly::Job::FetchUrl do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should also work with https" do
|
28
|
-
stub_request(:get,
|
28
|
+
stub_request(:get, 'https://place.com').to_return(:body => 'secure result!')
|
29
29
|
job.fetch_url!('https://place.com')
|
30
30
|
job.data.should == "secure result!"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|