Sha256: 16989314b93dd0e0e962e5ea253fa0e571c67c63c1403d3c594a26275c9672bb
Contents?: true
Size: 687 Bytes
Versions: 2
Compression:
Stored size: 687 Bytes
Contents
require "open-uri" require "open_uri_redirections" require "anyfetch/file" require "anyfetch/ftp" require "anyfetch/http" require "anyfetch/sftp" require "anyfetch/version" module Anyfetch extend self def open(uri, options = {}) uri = to_uri(uri) handler(uri, options).open end private def to_uri(uri) URI.parse(uri.to_s) end def handler(uri, options = {}) scheme = uri.scheme || "file" klass = case scheme when "file" then File when "ftp" then FTP when "sftp" then SFTP when /^https?/ then HTTP else raise "No handler for '#{scheme}' protocol." end klass.new(uri, options) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anyfetch-0.1.7 | lib/anyfetch.rb |
anyfetch-0.1.6 | lib/anyfetch.rb |