require "uri" class Source < URI getter filename : String def initialize(uri : URI) @fragment = uri.fragment @host = uri.host @password = uri.host @port = uri.port @query = uri.query @scheme = uri.scheme @user = uri.user @path = uri.path.gsub /\ *\->.*/, "" @filename = File.basename(uri.path).gsub /.*-> */, "" end def scheme : String @scheme || "file" end def self.parse(uri : String) self.new URI.parse uri end end class Package::Sources < Array(Source) def <<(url : String) self << Source.parse url end end