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

35 lines
573 B
Crystal
Raw Normal View History

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