downspout 0.2.3 → 0.2.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/Rakefile +15 -0
- data/VERSION +1 -1
- data/lib/downspout/config.rb +1 -1
- data/lib/downspout/downloader.rb +24 -13
- metadata +3 -3
data/Rakefile
CHANGED
@@ -51,3 +51,18 @@ Rake::TestTask.new(:test) do |test|
|
|
51
51
|
end
|
52
52
|
|
53
53
|
task :default => :test
|
54
|
+
|
55
|
+
namespace :basic do
|
56
|
+
desc "Basic Steps to take when updating this gem via GemCutter"
|
57
|
+
task :steps do
|
58
|
+
puts "rake version:bump:patch"
|
59
|
+
puts "rake gemspec"
|
60
|
+
puts ">>> write code <<<"
|
61
|
+
puts "rake test"
|
62
|
+
puts "rake build"
|
63
|
+
puts "gem install pkg/downspout-{version}.gem"
|
64
|
+
puts ">>> manual tests <<<"
|
65
|
+
puts "git commit"
|
66
|
+
puts "gem push pkg/downspout-{version}.gem"
|
67
|
+
end
|
68
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/downspout/config.rb
CHANGED
data/lib/downspout/downloader.rb
CHANGED
@@ -131,16 +131,14 @@ module Downspout
|
|
131
131
|
|
132
132
|
$logger.debug("downspout | downloader | download! | #{self.basename} downloaded? : #{downloaded} ")
|
133
133
|
@finished_at = Time.now
|
134
|
-
|
135
|
-
|
134
|
+
|
135
|
+
new_name = generate_file_name
|
136
|
+
if (tf && new_name && !(@basename == new_name)) then
|
136
137
|
# rename file more appropriately
|
137
|
-
new_name
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
FileUtils.mv( tf.path, new_path )
|
142
|
-
@path = new_path
|
143
|
-
end
|
138
|
+
$logger.debug("downspout | downloader | download! | Renaming #{@basename} to #{new_name} ...")
|
139
|
+
new_path = File.join( File.dirname( tf.path ), new_name)
|
140
|
+
FileUtils.mv( tf.path, new_path )
|
141
|
+
@path = new_path
|
144
142
|
end
|
145
143
|
|
146
144
|
$logger.debug("downspout | downloader | download! | Started: #{@started_at.utc}, Finished: #{@finished_at.utc}, Duration: #{duration}")
|
@@ -328,17 +326,30 @@ module Downspout
|
|
328
326
|
end
|
329
327
|
|
330
328
|
def generate_file_name
|
331
|
-
|
332
|
-
|
329
|
+
|
330
|
+
cd_key = response_headers.keys.select{|k| k =~ /content-disposition/i }.first
|
331
|
+
# example : Content-Disposition: attachment; filename="iPad_User_Guide.pdf"
|
332
|
+
if cd_key then
|
333
|
+
disposition = @response_headers[cd_key]
|
334
|
+
if disposition then
|
335
|
+
file_name = disposition.match("filename=\"(.+)\"")[1]
|
336
|
+
return file_name unless (file_name.nil? || file_name.empty?)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
ct_key = response_headers.keys.select{|k| k =~ /content-type/i }.first
|
341
|
+
return nil unless ct_key
|
342
|
+
|
343
|
+
file_type = @response_headers[ct_key]
|
333
344
|
return nil unless file_type
|
334
345
|
|
335
|
-
return "default.html" if file_type =~ /text\/html/
|
336
346
|
# TODO : smarter file name generation
|
347
|
+
return "#{@basename || 'default'}.html" if file_type =~ /html/
|
348
|
+
return "#{@basename || 'default'}.pdf" if file_type =~ /pdf/
|
337
349
|
|
338
350
|
return nil
|
339
351
|
end
|
340
352
|
|
341
353
|
end
|
342
|
-
|
343
354
|
|
344
355
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: downspout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phi.Sanders
|