Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. role Distribution {
  2. method BUILDALL(|) {
  3. callsame();
  4. unless ::?CLASS.^name eq 'Distribution' {
  5. self does role :: {
  6. method meta(--> Hash) { ... }
  7. method content($ --> IO::Handle) { ... }
  8. }
  9. }
  10. self;
  11. }
  12. # `meta` provides an API to the meta data in META6 spec (s22)
  13. # - A Distribution may be represented internally by some other
  14. # spec (such as using the file system itself for prereqs), as
  15. # long as it can also be represented as the META6 hash format
  16. # method meta(--> Hash) { ... }
  17.  
  18. # `content($content-id)` provides an API to the data itself
  19. # - Use `.meta` to determine the $address of a specific $content-id
  20. # - IO::Handle is meant to be a data stream that may or may not be available; for now
  21. # it would return an IO::Handle and have `.open.slurp-rest(:bin)` called on it. So if
  22. # a socket wants to handle this role currently it would have to wrap `open` or `.slurp-rest`
  23. # to handle any protocol negotiation as well as probably saving the data to a tmpfile and
  24. # return an IO::Handle to that
  25. # method content($content-id --> IO::Handle) { ... }
  26.  
  27. # Backwards compatibility shim
  28. submethod new(*%_) {
  29. (::?CLASS.^name eq 'Distribution'
  30. ?? class :: {
  31. has $.name;
  32. has $.auth;
  33. has $.author;
  34. has $.authority;
  35. has $.api;
  36. has $.ver;
  37. has $.version;
  38. has $.description;
  39. has @.depends;
  40. has %.provides;
  41. has %.files;
  42. has $.source-url;
  43. method auth { $!auth // $!author // $!authority }
  44. method ver { $!ver // $!version }
  45. method meta(--> Hash) {
  46. {
  47. :$!name,
  48. :$.auth,
  49. :$.ver,
  50. :$!description,
  51. :@!depends,
  52. :%!provides,
  53. :%!files,
  54. :$!source-url,
  55. }
  56. }
  57. method Str() {
  58. return "{$.meta<name>}"
  59. ~ ":ver<{$.meta<ver> // ''}>"
  60. ~ ":auth<{$.meta<auth> // ''}>"
  61. ~ ":api<{$.meta<api> // ''}>";
  62.  
  63. }
  64. }.new(|%_)
  65. !! self.bless(|%_)) but Distribution;
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement