-
-
Save ugexe/72b5e491fddb977f75a650039725872a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/CompUnit.pm b/src/core/CompUnit.pm | |
index 4466a68..f311bfb 100644 | |
--- a/src/core/CompUnit.pm | |
+++ b/src/core/CompUnit.pm | |
@@ -19,7 +19,7 @@ class CompUnit { | |
# The distribution that this compilation unit was installed as part of | |
# (if known). | |
- has Distribution $.distribution; | |
+ has Distribution::Interface $.distribution; | |
my $default-from = 'Perl6'; | |
@@ -32,7 +32,7 @@ class CompUnit { | |
CompUnit::Repository :$repo, | |
Str :$repo-id, | |
Bool :$precompiled = False, | |
- Distribution :$distribution, | |
+ Distribution::Interface :$distribution, | |
) { | |
self.bless( | |
:$short-name, | |
diff --git a/src/core/CompUnit/Repository/Installable.pm b/src/core/CompUnit/Repository/Installable.pm | |
index b909069..83a7a61 100644 | |
--- a/src/core/CompUnit/Repository/Installable.pm | |
+++ b/src/core/CompUnit/Repository/Installable.pm | |
@@ -1,6 +1,6 @@ | |
role CompUnit::Repository::Installable does CompUnit::Repository { | |
# Installs a distribution into the repository. | |
- method install(Distribution $dist) { ... } | |
+ method install(Distribution::Interface $dist) { ... } | |
# Returns True if we can install modules (this will typically do a | |
# .w check on the module database). | |
diff --git a/src/core/CompUnit/Repository/Installation.pm b/src/core/CompUnit/Repository/Installation.pm | |
index 8e413b4..3654755 100644 | |
--- a/src/core/CompUnit/Repository/Installation.pm | |
+++ b/src/core/CompUnit/Repository/Installation.pm | |
@@ -184,7 +184,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
} | |
proto method install(|) {*} | |
- multi method install($dist, %sources, %scripts?, %resources?, :$force) { | |
+ multi method install(Distribution $dist, %sources, %scripts?, %resources?, :$force) { | |
# XXX: Deprecation shim | |
my %files = |%scripts, |%resources; | |
my %meta6 = %( | |
@@ -196,7 +196,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
); | |
my $new-dist = class { | |
- also does Distribution; | |
+ also does Distribution::Interface; | |
method meta { %meta6 } | |
method content($address is copy) { | |
my $handle = IO::Handle.new: path => IO::Path.new($address.IO.absolute); | |
@@ -205,7 +205,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
} | |
samewith($new-dist, :$force); | |
} | |
- multi method install(Distribution $distribution, Bool :$force) { | |
+ multi method install(Distribution::Interface $distribution, Bool :$force) { | |
my $dist = CompUnit::Repository::Distribution.new($distribution); | |
my %files = $dist.meta<files>.grep(*.defined).map: -> $link { | |
$link ~~ Str ?? ($link => $link) !! ($link.keys[0] => $link.values[0]) | |
@@ -343,7 +343,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
$lock.unlock; | |
} ) } | |
- method uninstall(Distribution $distribution) { | |
+ method uninstall(Distribution::Interface $distribution) { | |
my $repo-version = self!repository-version; | |
self.upgrade-repository unless $repo-version == 2; | |
diff --git a/src/core/Distribution.pm b/src/core/Distribution.pm | |
index 387f9a0..ad677ad 100644 | |
--- a/src/core/Distribution.pm | |
+++ b/src/core/Distribution.pm | |
@@ -1,5 +1,5 @@ | |
# API to obtain the data of any addressable content | |
-role Distribution { | |
+role Distribution::Interface { | |
# `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 | |
@@ -27,10 +27,10 @@ role Distribution::Locally { | |
# A distribution passed to `CURI.install()` will get encapsulated in this | |
# class, which normalizes the meta6 data and adds identifiers/content-id | |
class CompUnit::Repository::Distribution { | |
- has Distribution $!dist handles 'content'; | |
+ has Distribution::Interface $!dist handles 'content'; | |
has $!meta; | |
submethod BUILD(:$!meta, :$!dist) { } | |
- method new(Distribution $dist) { | |
+ method new(Distribution::Interface $dist) { | |
my $meta = $dist.meta.hash; | |
$meta<ver> //= $meta<version>; | |
$meta<auth> //= $meta<authority> // $meta<author>; | |
@@ -51,14 +51,50 @@ class CompUnit::Repository::Distribution { | |
} | |
} | |
-class Distribution::Hash does Distribution does Distribution::Locally { | |
+class Distribution does Distribution::Locally { | |
+ 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 { self.hash } | |
+ method hash { | |
+ { | |
+ :$!name, | |
+ :$.auth, | |
+ :$.ver, | |
+ :$!description, | |
+ :@!depends, | |
+ :%!provides, | |
+ :%!files, | |
+ :$!source-url, | |
+ } | |
+ } | |
+ method Str() { | |
+ return "{$.name}:ver<{$.ver // ''}>:auth<{$.auth // ''}>:api<{$.api // ''}>"; | |
+ } | |
+ method id() { | |
+ return nqp::sha1(self.Str); | |
+ } | |
+} | |
+ | |
+class Distribution::Hash does Distribution::Interface does Distribution::Locally { | |
has $!meta; | |
submethod BUILD(:$!meta, :$!prefix) { } | |
method new($hash, :$prefix) { self.bless(:meta($hash), :$prefix) } | |
method meta { $!meta } | |
} | |
-class Distribution::Path does Distribution does Distribution::Locally { | |
+class Distribution::Path does Distribution::Interface does Distribution::Locally { | |
has $!meta; | |
submethod BUILD(:$!meta, :$!prefix) { } | |
method new(IO::Path $prefix, IO::Path :$file is copy) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment