cherrypicker 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,12 +9,13 @@ require 'progressbar'
9
9
  require 'open-uri'
10
10
 
11
11
  class Download
12
- attr_accessor :link, :size, :location, :progress
12
+ attr_accessor :link, :size, :location, :progress, :filename
13
13
 
14
- def initialize(link, location = nil, size = nil)
14
+ def initialize(link, location = nil, size = nil, filename = nil)
15
15
  @link = link
16
16
  @size = size
17
17
  @location = location
18
+ @filename = filename
18
19
  @progress = 0
19
20
 
20
21
  download_file
@@ -28,8 +29,8 @@ class Download
28
29
  request.initialize_http_header({"User-Agent" => random_agent})
29
30
  @size = http.request_head(URI.escape(uri.path))['content-length'].to_i if @size.nil?
30
31
  http.request(request) do |response|
31
- bar = ProgressBar.new(File.basename(uri.path), @size.to_i)
32
- File.open(@location + File.basename(uri.path), "wb") do |file|
32
+ bar = ProgressBar.new((@filename ||= File.basename(uri.path)), @size.to_i)
33
+ File.open(@location + (@filename ||= File.basename(uri.path)), "wb") do |file|
33
34
  response.read_body do |segment|
34
35
  @progress += segment.length
35
36
  bar.set(@progress)
@@ -25,7 +25,7 @@ class Hotfile
25
25
  end
26
26
 
27
27
  def download
28
- Download.new(@hostname + remote_url, @location, @size)
28
+ Download.new(@hostname + remote_url, @location, @size, @filename)
29
29
  end
30
30
 
31
31
  def filename
@@ -24,7 +24,7 @@ class Rapidshare
24
24
  end
25
25
 
26
26
  def download
27
- Download.new(@hostname + remote_url, @location, @size,)
27
+ Download.new(@hostname + remote_url, @location, @size, @filename)
28
28
  end
29
29
 
30
30
  def fileid
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Entwistle