down 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/down.gemspec +1 -1
- data/lib/down.rb +8 -3
- 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: 404e5e406674a9f3edf5871d3769f865cf352e04
|
4
|
+
data.tar.gz: 10291cb0d07bb70e739118a7474bd18809fb16e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5353aac0da3393128585deb6571938e781e1907afc71bcd2555c450a9ed9c690df96d9f3b69ceaa9e91b29b1ca70d674b9058450fa0f03334c14de71aebfa2f9
|
7
|
+
data.tar.gz: 86151e26fa4ab4b8a82e6653022286fe48965fac21aa083712af22d17d6904d545b162038c101e481d7285939333a49fc4463aa86329017eaa3b973a8dbb0d07
|
data/down.gemspec
CHANGED
data/lib/down.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "open-uri"
|
2
2
|
require "tempfile"
|
3
3
|
require "uri"
|
4
|
+
require "fileutils"
|
4
5
|
|
5
6
|
module Down
|
6
7
|
class Error < StandardError; end
|
@@ -33,7 +34,6 @@ module Down
|
|
33
34
|
open_uri_file = downloaded_file
|
34
35
|
downloaded_file = copy_to_tempfile(URI(url).path, open_uri_file)
|
35
36
|
OpenURI::Meta.init downloaded_file, open_uri_file
|
36
|
-
open_uri_file.delete if open_uri_file.respond_to?(:delete)
|
37
37
|
|
38
38
|
downloaded_file.extend DownloadedFile
|
39
39
|
downloaded_file
|
@@ -45,8 +45,13 @@ module Down
|
|
45
45
|
|
46
46
|
def copy_to_tempfile(basename, io)
|
47
47
|
tempfile = Tempfile.new(["down", File.extname(basename)], binmode: true)
|
48
|
-
|
49
|
-
|
48
|
+
if io.is_a?(OpenURI::Meta) && io.is_a?(Tempfile)
|
49
|
+
FileUtils.mv io.path, tempfile.path
|
50
|
+
else
|
51
|
+
IO.copy_stream(io, tempfile.path)
|
52
|
+
io.rewind
|
53
|
+
end
|
54
|
+
tempfile.open
|
50
55
|
tempfile
|
51
56
|
end
|
52
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: down
|
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
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|