(url, output_path)
| 78 | end |
| 79 | |
| 80 | def download(url, output_path) |
| 81 | if File.directory?(output_path) |
| 82 | base_name = url.split("/").last |
| 83 | output_path = File.join(output_path, base_name) |
| 84 | end |
| 85 | absolute_output_path = File.expand_path(output_path) |
| 86 | |
| 87 | unless File.exist?(absolute_output_path) |
| 88 | mkdir_p(File.dirname(absolute_output_path)) |
| 89 | rake_output_message "Downloading... #{url}" |
| 90 | open_url(url) do |downloaded_file| |
| 91 | File.open(absolute_output_path, "wb") do |output_file| |
| 92 | IO.copy_stream(downloaded_file, output_file) |
| 93 | end |
| 94 | end |
| 95 | end |
| 96 | |
| 97 | absolute_output_path |
| 98 | end |
| 99 | |
| 100 | def open_url(url, &block) |
| 101 | URI(url).open(&block) |
nothing calls this directly
no test coverage detected