Skip to content

Commit 7b31400

Browse files
committed
#71 Refactoring
1 parent 6483c05 commit 7b31400

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/store/file.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
99

1010
require 'open-uri'
11+
require 'uri'
1112

1213
module Automatic::Plugin
1314
class StoreFile
@@ -46,17 +47,19 @@ def run
4647
end
4748

4849
private
50+
4951
def wget(url)
50-
filename = url.split(/\//).last
52+
uri = URI.parse(url)
53+
filename = File.basename(uri.path)
5154
filepath = File.join(@config['path'], filename)
5255
open(url) {|source|
5356
open(filepath, "w+b") { |o|
5457
o.print source.read
5558
}
5659
}
57-
uri_scheme = "file://" + filepath
58-
Automatic::Log.puts("info", "Saved: #{uri_scheme}")
59-
uri_scheme
60+
return_uri = URI.join("file://" + filepath)
61+
Automatic::Log.puts("info", "Saved: #{return_uri.path}")
62+
return_uri.path
6063
end
6164
end
6265
end

0 commit comments

Comments
 (0)