down 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/down.gemspec +1 -1
  3. data/lib/down.rb +8 -3
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 308e9ad61508c3ff017fc00268b10bf7940e127c
4
- data.tar.gz: 2aaaa11f72a058efa83efbe173989a9bf48ee0f7
3
+ metadata.gz: 404e5e406674a9f3edf5871d3769f865cf352e04
4
+ data.tar.gz: 10291cb0d07bb70e739118a7474bd18809fb16e9
5
5
  SHA512:
6
- metadata.gz: e109c11f4ca94c98c8d7863f00265166e410dfb30feb0717b072016dc93d66b744d8699b1409fc418e7050f44f4592cfebbcbac5b6c8b4f76e54868744cb0af4
7
- data.tar.gz: b9e42b21509b659338853831724199124f520cfc7f25d55be0d9d0c7422efd715a783966e3528ccda9a5ce9be6365f9e47abf5526ace76b5b7e9471936a88db6
6
+ metadata.gz: 5353aac0da3393128585deb6571938e781e1907afc71bcd2555c450a9ed9c690df96d9f3b69ceaa9e91b29b1ca70d674b9058450fa0f03334c14de71aebfa2f9
7
+ data.tar.gz: 86151e26fa4ab4b8a82e6653022286fe48965fac21aa083712af22d17d6904d545b162038c101e481d7285939333a49fc4463aa86329017eaa3b973a8dbb0d07
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "down"
3
- spec.version = "1.0.4"
3
+ spec.version = "1.0.5"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko.marohnic@gmail.com"]
6
6
 
@@ -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
- IO.copy_stream(io, tempfile.path)
49
- io.rewind
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
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-19 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake