down 2.2.0 → 2.2.1

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 +6 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a8a682287353edfab10f1e5f6850b7e0dc2266f
4
- data.tar.gz: a2ad18a8a32409594fb3918fa5e4dff851872d18
3
+ metadata.gz: 1d8c92123cb9fa3a46484b51840f8363c74cdd6b
4
+ data.tar.gz: 05d06a93dbe891dfe90332acfb0dd06bfd98e6da
5
5
  SHA512:
6
- metadata.gz: f50514a9c905dab165f460e114be9bee93815306394fcaf6a4be4e530979e97114b772293f1e38dcc0fc9f9f10c0b2d79cecf854143c0c1b0f13ebb9c8a91c1b
7
- data.tar.gz: 55ee7597729abb451f06a579c4978a882b958023c737232a4858b8f6d0fd1d6dc794874dd8b80ab56e33e79afd612fe69f4f21842b602b26e9580737f3422073
6
+ metadata.gz: 67f3abe4b028843b738d3e1e0cd4642664831dd3d4240a8cf0c7197b14bcbb8a5de0f1e9f982a90f651c82cb783ea09f83ac25a9713948d4d7f4f8ffc2b3ba3c
7
+ data.tar.gz: cc63303532e1e748a997051d1349335c63ebf5f56d9725ffafa04eea2b4f36679e4f29830c889f2f6c483eec96c805a44cf06932fbe1aa44d2ae0809d17fff4a
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "down"
3
- spec.version = "2.2.0"
3
+ spec.version = "2.2.1"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko.marohnic@gmail.com"]
6
6
 
@@ -20,7 +20,7 @@ module Down
20
20
  content_length_proc = options.delete(:content_length_proc)
21
21
  timeout = options.delete(:timeout)
22
22
 
23
- requests_left = max_redirects + 1
23
+ tries = max_redirects + 1
24
24
 
25
25
  begin
26
26
  uri = URI.parse(url)
@@ -41,9 +41,9 @@ module Down
41
41
  read_timeout: timeout,
42
42
  redirect: false,
43
43
  }.merge(options))
44
- rescue OpenURI::HTTPRedirect => error
45
- url = error.uri.to_s
46
- retry if (requests_left -= 1) > 0
44
+ rescue OpenURI::HTTPRedirect => redirect
45
+ url = redirect.uri.to_s
46
+ retry if (tries -= 1) > 0
47
47
  raise Down::NotFound, "too many redirects"
48
48
  rescue => error
49
49
  raise if error.is_a?(Down::Error)
@@ -95,6 +95,8 @@ module Down
95
95
  def copy_to_tempfile(basename, io)
96
96
  tempfile = Tempfile.new(["down", File.extname(basename)], binmode: true)
97
97
  if io.is_a?(OpenURI::Meta) && io.is_a?(Tempfile)
98
+ io.close
99
+ tempfile.close
98
100
  FileUtils.mv io.path, tempfile.path
99
101
  else
100
102
  IO.copy_stream(io, tempfile)
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: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake