require 'uri' require 'addressable/uri' module Downloader # use_cache => save in the home and return path to it # forced => download even if the file exists in the cache, saves to chace if use_cache == true def self.get(url, use_cache = true, forced = false) puts "downloading..." puts url uri = Addressable::URI.parse(url) path = File.join("#{ENV["HOME"]}/.cache/dat/downloads/", uri.domain, uri.path) #uri = URI.parse(url) #file_name = File.basename(uri.path) puts "Download path: #{path}" yield path end end