This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-02 03:50:50 +02:00
|
|
|
|
|
|
|
require "uri"
|
|
|
|
|
2019-08-22 19:57:51 +02:00
|
|
|
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)
|
2019-07-02 03:50:50 +02:00
|
|
|
def <<(url : String)
|
2019-08-22 19:57:51 +02:00
|
|
|
self << Source.parse url
|
2019-07-02 03:50:50 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|