Skip to content
Permalink
Browse files

Reimplement files using .candidates

  • Loading branch information...
ugexe committed Aug 17, 2017
1 parent b378a15 commit d0a3fec997cffa77100af47a666c11166f705b0b
Showing with 42 additions and 0 deletions.
  1. +42 −0 src/core/CompUnit/Repository/FileSystem.pm
@@ -157,6 +157,48 @@ class CompUnit::Repository::FileSystem does CompUnit::Repository::Locally does C
return ($!distribution,);
}

proto method files(|) {*}
multi method files($file, Str:D :$name!, :$auth, :$ver, :$api) {
# if we have to include :$name then we take the slow path

my $spec = CompUnit::DependencySpecification.new(
short-name => $name,
auth-matcher => $auth // True,
version-matcher => $ver // True,
api-matcher => $api // True,
);

with self.candidates($spec) {
my $matches := $_.grep: { .meta<files>{$file}:exists }

my $absolutified-metas := $matches.map: {
my $meta = $_.meta;
$meta<source> = self!dist-prefix.add($meta<files>{$file});
$meta;
}

return $absolutified-metas.grep(*.<source>.e);
}
}
multi method files($file, :$auth, :$ver, :$api) {
my $spec = CompUnit::DependencySpecification.new(
short-name => $file,
auth-matcher => $auth // True,
version-matcher => $ver // True,
api-matcher => $api // True,
);

with self.candidates($spec) {
my $absolutified-metas := $_.map: {
my $meta = $_.meta;
$meta<source> = self!dist-prefix.add($meta<files>{$file});
$meta;
}

return $absolutified-metas.grep(*.<source>.e);
}
}

method !distribution {
$!distribution //= $!prefix.add('META6.json').f
?? Distribution::Path.new($!prefix)

0 comments on commit d0a3fec

Please sign in to comment.
You can’t perform that action at this time.