Archived
3
0
This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues or pull requests.
packaging/src/sources.cr

35 lines
573 B
Crystal

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