cherrypicker 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .DS_Store
6
- test/console.rb
6
+ test/console.rb
7
+ *.rar
data/README.md CHANGED
@@ -29,7 +29,10 @@ Examples
29
29
 
30
30
  check = LinkChecker.new([
31
31
  "http://rapidshare.com/files/329036215/myfile.rar",
32
- "http://rapidshare.com/files/329036764/deadfile.rar"]).status
32
+ "http://rapidshare.com/files/329036764/deadfile.rar"]).status
33
+
34
+ test3 = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password", "size", "location")
35
+ test3.download
33
36
 
34
37
  Contributing
35
38
  ------------
@@ -5,14 +5,15 @@ require 'net/http'
5
5
  require 'progressbar'
6
6
 
7
7
  class Download
8
- attr_accessor :hostname, :url, :filename, :size, :progress
8
+ attr_accessor :hostname, :url, :filename, :size, :progress, :location
9
9
 
10
- def initialize(hostname, url, filename, size = nil)
10
+ def initialize(hostname, url, filename, size = nil, location = nil)
11
11
  @hostname = hostname
12
12
  @url = url
13
13
  @filename = filename
14
14
  @size = size
15
- @progress = 0
15
+ @location = location
16
+ @progress = 0
16
17
 
17
18
  download_file
18
19
  end
@@ -23,7 +24,7 @@ private
23
24
  http = Net::HTTP.new("#{self.hostname}")
24
25
  http.request_get("#{self.url}") do |response|
25
26
  bar = ProgressBar.new("#{self.filename}", self.size.to_i)
26
- File.open("#{self.filename}", "wb") do |file|
27
+ File.open("#{self.location}" + "#{self.filename}", "wb") do |file|
27
28
  response.read_body do |segment|
28
29
  self.progress += segment.length
29
30
  bar.set(self.progress)
@@ -5,9 +5,9 @@
5
5
  # puts hotfile.hostname
6
6
  # hotfile.download
7
7
  class Hotfile
8
- attr_accessor :link, :hostname, :filename, :username, :password, :size
8
+ attr_accessor :link, :hostname, :filename, :username, :password, :size, :location
9
9
 
10
- def initialize(link, username, password, size = nil)
10
+ def initialize(link, username, password, size = nil, location = "")
11
11
  if link =~ /hotfile.com\/dl\/\d*\/[0-9a-f]*\/.*.*\.html/
12
12
  @link = link[/(.*)\.html/, 1]
13
13
  else
@@ -18,10 +18,11 @@ class Hotfile
18
18
  @hostname = hostname
19
19
  @filename = filename
20
20
  @size = size
21
+ @location = location
21
22
  end
22
23
 
23
24
  def download
24
- Download.new(self.hostname, remote_url, self.filename, self.size)
25
+ Download.new(self.hostname, remote_url, self.filename, self.size, self.location)
25
26
  end
26
27
 
27
28
  def filename
@@ -7,9 +7,9 @@
7
7
  # puts rapid.host
8
8
  # rapid.download
9
9
  class Rapidshare
10
- attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size
10
+ attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size, :location
11
11
 
12
- def initialize(link, username, password, size = nil)
12
+ def initialize(link, username, password, size = nil, location = "")
13
13
  @link = link
14
14
  @fileid = fileid
15
15
  @filename = filename
@@ -17,10 +17,11 @@ class Rapidshare
17
17
  @username = username
18
18
  @password = password
19
19
  @size = size
20
+ @location = location
20
21
  end
21
22
 
22
23
  def download
23
- Download.new(self.hostname, remote_url, self.filename, self.size)
24
+ Download.new(self.hostname, remote_url, self.filename, self.size, self.location)
24
25
  end
25
26
 
26
27
  def fileid
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.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.1.4
5
+ version: 0.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Entwistle
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-01 00:00:00 +01:00
13
+ date: 2011-04-07 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency