Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- role Distribution {
- method BUILDALL(|) {
- callsame();
- unless ::?CLASS.^name eq 'Distribution' {
- self does role :: {
- method meta(--> Hash) { ... }
- method content($ --> IO::Handle) { ... }
- }
- }
- self;
- }
- # `meta` provides an API to the meta data in META6 spec (s22)
- # - A Distribution may be represented internally by some other
- # spec (such as using the file system itself for prereqs), as
- # long as it can also be represented as the META6 hash format
- # method meta(--> Hash) { ... }
- # `content($content-id)` provides an API to the data itself
- # - Use `.meta` to determine the $address of a specific $content-id
- # - IO::Handle is meant to be a data stream that may or may not be available; for now
- # it would return an IO::Handle and have `.open.slurp-rest(:bin)` called on it. So if
- # a socket wants to handle this role currently it would have to wrap `open` or `.slurp-rest`
- # to handle any protocol negotiation as well as probably saving the data to a tmpfile and
- # return an IO::Handle to that
- # method content($content-id --> IO::Handle) { ... }
- # Backwards compatibility shim
- submethod new(*%_) {
- (::?CLASS.^name eq 'Distribution'
- ?? class :: {
- has $.name;
- has $.auth;
- has $.author;
- has $.authority;
- has $.api;
- has $.ver;
- has $.version;
- has $.description;
- has @.depends;
- has %.provides;
- has %.files;
- has $.source-url;
- method auth { $!auth // $!author // $!authority }
- method ver { $!ver // $!version }
- method meta(--> Hash) {
- {
- :$!name,
- :$.auth,
- :$.ver,
- :$!description,
- :@!depends,
- :%!provides,
- :%!files,
- :$!source-url,
- }
- }
- method Str() {
- return "{$.meta<name>}"
- ~ ":ver<{$.meta<ver> // ''}>"
- ~ ":auth<{$.meta<auth> // ''}>"
- ~ ":api<{$.meta<api> // ''}>";
- }
- }.new(|%_)
- !! self.bless(|%_)) but Distribution;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement