Sha256: ba200d06c5d9bf3024f21a307fd57794945987b94c33db6314458bb5ef4e432d
Contents?: true
Size: 648 Bytes
Versions: 1
Compression:
Stored size: 648 Bytes
Contents
require 'uri' require 'fileutils' require 'open-uri' require 'net/http' module FeCoreExt::CoreExt end module URI def download(file) binary = OpenURI.open_uri(self).read dirname = File.dirname(file) unless File.directory?(dirname) FileUtils.mkdir_p(dirname) end ::File.open(file, 'wb') {|f| f.write(binary)} end def exists? req = Net::HTTP.new(host, port) req.use_ssl = true if scheme == 'https' res = req.request_head(path) return URI(res['location']).exists? if %w(301 302).include?(res.code) res.code == '200' end end class URI::Generic def basename ::File.basename(path) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fe_core_ext-0.13.0 | lib/fe_core_ext/core_ext/uri.rb |