downer 0.3.1 → 0.3.2
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/downer.gemspec +2 -2
- data/lib/downer.rb +1 -0
- data/lib/downer/download_item.rb +10 -10
- data/lib/downer/download_worker.rb +2 -2
- data/spec/downer/download_item_spec.rb +4 -0
- data/version.yml +1 -1
- metadata +4 -4
data/downer.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{downer}
|
|
8
|
-
s.version = "0.3.
|
|
8
|
+
s.version = "0.3.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Nate Miller"]
|
|
12
|
-
s.date = %q{2010-08-
|
|
12
|
+
s.date = %q{2010-08-09}
|
|
13
13
|
s.default_executable = %q{downer}
|
|
14
14
|
s.description = %q{Downer is a tool used to download a list of urls from a website thorugh HTTP.}
|
|
15
15
|
s.email = %q{nate@natemiller.org}
|
data/lib/downer.rb
CHANGED
data/lib/downer/download_item.rb
CHANGED
|
@@ -10,15 +10,15 @@ module Downer
|
|
|
10
10
|
|
|
11
11
|
def initialize(url, destination)
|
|
12
12
|
@url, @destination = sanitize_url(url), destination
|
|
13
|
-
@uri = URI.parse(url)
|
|
13
|
+
@uri = URI.parse(@url)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Returns the name which this file will be saved as
|
|
17
17
|
def get_save_filename
|
|
18
|
-
file_name = @uri.to_s
|
|
18
|
+
file_name = CGI.unescape(@uri.to_s)
|
|
19
19
|
file_name = file_name.gsub(/https?:\/\//,'').split('/').last
|
|
20
|
-
file_name = file_name.gsub('%5B', '[')
|
|
21
|
-
file_name = file_name.gsub('%5D', ']')
|
|
20
|
+
#file_name = file_name.gsub('%5B', '[')
|
|
21
|
+
#file_name = file_name.gsub('%5D', ']')
|
|
22
22
|
file_name
|
|
23
23
|
# TODO : refine to auto append file extentions based on content type
|
|
24
24
|
end
|
|
@@ -52,12 +52,12 @@ module Downer
|
|
|
52
52
|
fout.puts @content
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
def sanitize_url(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
def sanitize_url(url)
|
|
56
|
+
unsafe_url = String.new(url)
|
|
57
|
+
scheme = unsafe_url.slice!(/(https?|ftp|smb):\/\//)
|
|
58
|
+
parts = unsafe_url.split('/')
|
|
59
|
+
parts.map! { |part| CGI::escape(part).gsub('+', '%20') }
|
|
60
|
+
scheme + parts.join('/')
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -16,6 +16,10 @@ module Downer
|
|
|
16
16
|
item.get_save_filename.should == 'mapsAndAtlases2.png'
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
it "should successfully encode invalid chars into ASCII equivalents" do
|
|
20
|
+
item = DownloadItem.new('http://www.urbaninfluence.com/My File_Name With White space.png', '/tmp')
|
|
21
|
+
item.url.should == 'http://www.urbaninfluence.com/My%20File_Name%20With%20White%20space.png'
|
|
22
|
+
end
|
|
19
23
|
|
|
20
24
|
it "should restore bad url tokens into valid ascii characters" do
|
|
21
25
|
item = DownloadItem.new('http://www.urbaninfluence.com/my[place].html', '/tmp')
|
data/version.yml
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: downer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 3
|
|
9
|
-
-
|
|
10
|
-
version: 0.3.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.3.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Nate Miller
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-08-
|
|
18
|
+
date: 2010-08-09 00:00:00 -07:00
|
|
19
19
|
default_executable: downer
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|