anyfetch 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/anyfetch.rb +1 -2
- data/lib/anyfetch/ftp.rb +2 -7
- data/lib/anyfetch/http.rb +2 -8
- data/lib/anyfetch/open_uri.rb +33 -0
- data/lib/anyfetch/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29264ad4fdfd44d9a845fdba58e65c5a208b5419
|
4
|
+
data.tar.gz: 5de3fa9d7eb26bc116aae3da86234f2dd2a7ec99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f7793a98e193b1be087c8eabc7f6407cea71dcbe0597c2b694b56ab79de592685bfdc265793ce99fb75cb28ed3dc4c00041a291ff45cd0f58f88f066bae844
|
7
|
+
data.tar.gz: f42a89850d2425adc1c9e797186ec0cc18d0d30e9bae5269e0bc403355182baa89d390ff6ce64cef96aecacae1e5e5fcc254cfab81c61fe76e4d56b53e8001e3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Anyfetch Changelog
|
2
2
|
|
3
|
+
## 0.1.3
|
4
|
+
|
5
|
+
* Remove automating URI-encoding altogether as it probably should not be responsibility of the library.
|
6
|
+
* Always return `Tempfile` from HTTP and FTP handlers.
|
7
|
+
|
8
|
+
## 0.1.2
|
9
|
+
|
10
|
+
* Prepare URI for parsing by decoding and re-encoding
|
11
|
+
|
3
12
|
## 0.1.1
|
4
13
|
|
5
14
|
* Use old hash notation to support ruby 1.8
|
data/lib/anyfetch.rb
CHANGED
data/lib/anyfetch/ftp.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
+
require "anyfetch/open_uri"
|
1
2
|
require "anyfetch/original_filename/content_type"
|
2
3
|
|
3
4
|
module Anyfetch
|
4
|
-
class FTP
|
5
|
+
class FTP < OpenURI
|
5
6
|
def initialize(uri, options = {})
|
6
7
|
@uri = uri
|
7
8
|
@options = options
|
8
9
|
setup_auth
|
9
10
|
end
|
10
11
|
|
11
|
-
def open
|
12
|
-
file = super(@uri)
|
13
|
-
file.extend(OriginalFilename::ContentType)
|
14
|
-
file
|
15
|
-
end
|
16
|
-
|
17
12
|
private
|
18
13
|
|
19
14
|
def setup_auth
|
data/lib/anyfetch/http.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "anyfetch/
|
1
|
+
require "anyfetch/open_uri"
|
2
2
|
|
3
3
|
module Anyfetch
|
4
|
-
class HTTP
|
4
|
+
class HTTP < OpenURI
|
5
5
|
OPTIONS = {
|
6
6
|
"User-Agent" => "Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0",
|
7
7
|
:allow_redirections => :safe,
|
@@ -13,12 +13,6 @@ module Anyfetch
|
|
13
13
|
setup_basic_auth
|
14
14
|
end
|
15
15
|
|
16
|
-
def open
|
17
|
-
file = super(@uri, @options)
|
18
|
-
file.extend(OriginalFilename::ContentType)
|
19
|
-
file
|
20
|
-
end
|
21
|
-
|
22
16
|
private
|
23
17
|
|
24
18
|
def setup_basic_auth
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
require "anyfetch/original_filename/content_type"
|
3
|
+
|
4
|
+
module Anyfetch
|
5
|
+
class OpenURI
|
6
|
+
def initialize(*args)
|
7
|
+
raise NotImplementedError
|
8
|
+
end
|
9
|
+
|
10
|
+
def open
|
11
|
+
file = super(@uri, @options)
|
12
|
+
|
13
|
+
if file.is_a?(StringIO)
|
14
|
+
file = to_tempfile(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
file.extend(OriginalFilename::ContentType)
|
18
|
+
file
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# OpenURI returns either Tempfile or StringIO depending of the size of
|
24
|
+
# the response. We want to unify this and always return Tempfile.
|
25
|
+
def to_tempfile(io)
|
26
|
+
tempfile = Tempfile.new('open-uri')
|
27
|
+
tempfile.binmode
|
28
|
+
::OpenURI::Meta.init(tempfile, io)
|
29
|
+
tempfile << io.string
|
30
|
+
tempfile
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/anyfetch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyfetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Szajbe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocaine
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/anyfetch/file.rb
|
118
118
|
- lib/anyfetch/ftp.rb
|
119
119
|
- lib/anyfetch/http.rb
|
120
|
+
- lib/anyfetch/open_uri.rb
|
120
121
|
- lib/anyfetch/original_filename/content_type.rb
|
121
122
|
- lib/anyfetch/original_filename/path.rb
|
122
123
|
- lib/anyfetch/version.rb
|