cherrypicker 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- .DS_Store
5
+ .DS_Store
6
+ test/console.rb
@@ -14,6 +14,8 @@ class Download
14
14
  download
15
15
  end
16
16
 
17
+ private
18
+
17
19
  def download
18
20
  Net::HTTP.start("#{self.hostname}") { |http|
19
21
  resp = http.get("#{self.url}")
@@ -13,7 +13,7 @@ def remote_query(url)
13
13
  request.initialize_http_header({"User-Agent" => random_agent})
14
14
  response = http.request(request)
15
15
  if response["X-APICPU"]
16
- if (response["X-APICPU"][/(\d*)\/\d*/, 1]).to_i > 1000
16
+ if (response["X-APICPU"][/(\d*)\/\d*/, 1]).to_i > 9500
17
17
  sleep 60 # seconds
18
18
  end
19
19
  end
@@ -3,6 +3,7 @@
3
3
  # hotfile = Hotfile.new("http://hotfile.com/dl/110589431/6ad2666/ROT007-WEB-2011.rar.html", "username", "password")
4
4
  # puts hotfile.link
5
5
  # puts hotfile.hostname
6
+ # hotfile.download
6
7
  class Hotfile
7
8
  attr_accessor :link, :hostname, :filename, :username, :password
8
9
 
@@ -5,6 +5,7 @@
5
5
  # puts rapid.fileid
6
6
  # puts rapid.filename
7
7
  # puts rapid.host
8
+ # rapid.download
8
9
  class Rapidshare
9
10
  attr_accessor :link, :fileid, :filename, :hostname, :username, :password
10
11
 
@@ -46,5 +47,4 @@ class Rapidshare
46
47
  query = remote_query("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&" + create_url)
47
48
  query.response.body[/DL:(.*).rapidshare.com/, 1] + ".rapidshare.com"
48
49
  end
49
- end
50
-
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/cherrypicker.rb CHANGED
@@ -1,4 +1,3 @@
1
- $LOAD_PATH << File.dirname(__FILE__)
2
1
  require 'cherrypicker/rapidshare'
3
2
  require 'cherrypicker/hotfile'
4
3
  require 'cherrypicker/download'
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'shoulda'
3
+
4
+ require File.dirname(__FILE__) + '/../lib/cherrypicker'
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class HotfileTest < Test::Unit::TestCase
4
+
5
+ context "Information request" do
6
+
7
+ should "return response" do
8
+ response = Hotfile.new("http://hotfile.com/dl/110752208/b0cb939/test_file.txt.html", "username", "password")
9
+ assert response.filename.length > 0
10
+ assert response.hostname[/(.*)\.hotfile.com/, 1].length > 0
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RapidshareTest < Test::Unit::TestCase
4
+
5
+ context "Information request" do
6
+
7
+ should "return response" do
8
+ response = Rapidshare.new("http://rapidshare.com/files/453165880/test_file.txt", "username", "password")
9
+ assert response.fileid =~ /\d*/
10
+ assert response.filename.length > 0
11
+ assert response.hostname.length > 0
12
+ assert !response.hostname.include?("DL: ")
13
+ end
14
+
15
+ end
16
+
17
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Entwistle
@@ -35,6 +35,9 @@ files:
35
35
  - lib/cherrypicker/hotfile.rb
36
36
  - lib/cherrypicker/rapidshare.rb
37
37
  - lib/cherrypicker/version.rb
38
+ - test/test_helper.rb
39
+ - test/unit/hostfile_test.rb
40
+ - test/unit/rapidshare_test.rb
38
41
  has_rdoc: true
39
42
  homepage: http://karl.entwistle.info/
40
43
  licenses: []
@@ -63,5 +66,7 @@ rubygems_version: 1.6.1
63
66
  signing_key:
64
67
  specification_version: 3
65
68
  summary: Cherrypicker is Ruby Gem it lets you download from; Rapidshare and Hotfile
66
- test_files: []
67
-
69
+ test_files:
70
+ - test/test_helper.rb
71
+ - test/unit/hostfile_test.rb
72
+ - test/unit/rapidshare_test.rb