Permalink
Browse files

Even more future compatibility for zef locate / info

This allows things to work with the current modified provides data structure, but also the future unmodified provides structure.
  • Loading branch information...
ugexe committed Dec 31, 2018
1 parent 0ba0599 commit d866845111440d7d38ea5bede3ea3218e99bec40
Showing with 12 additions and 12 deletions.
  1. +12 −12 lib/Zef/CLI.pm6
@@ -402,7 +402,7 @@ package Zef::CLI {
if !$sha1 {
if $identity.ends-with('.pm' | '.pm6') {
my @candis = $client.list-installed.grep({
.dist.compat.meta<provides>.values.grep({.keys[0] eq $identity}).so;
.dist.compat.meta<provides>.values.grep({parse-value($_) eq $identity}).so;
});

for @candis -> $candi {
@@ -413,7 +413,7 @@ package Zef::CLI {
# This is relying on implementation details for compatability purposes. It will
# use something more appropriate sometime in 2019.
my %meta = $candi.dist.compat.meta;
%meta<provides> = %meta<provides>.map({ $_.key => $_.value.keys[0] }).hash;
%meta<provides> = %meta<provides>.map({ $_.key => parse-value($_.value) }).hash;
my $lib = %meta<provides>.hash.antipairs.hash.{$identity};
my $lib-sha1 = nqp::sha1($lib ~ CompUnit::Repository::Distribution.new($candi.dist.compat).id);

@@ -457,7 +457,7 @@ package Zef::CLI {
# use something more appropriate sometime in 2019.
use nqp;
my %meta = $candi.dist.compat.meta;
%meta<provides> = %meta<provides>.map({ $_.key => $_.value.keys[0] }).hash;
%meta<provides> = %meta<provides>.map({ $_.key => parse-value($_.value) }).hash;
my @source_files = %meta<provides>.map({ nqp::sha1($_.key ~ CompUnit::Repository::Distribution.new($candi.dist.compat).id) });
my @resource_files = %meta<files>.values.first({$_ eq $identity});
$identity ~~ any(grep *.defined, flat @source_files, @resource_files);
@@ -469,7 +469,7 @@ package Zef::CLI {

if $candi {
my %meta = $candi.dist.compat.meta;
%meta<provides> = %meta<provides>.map({ $_.key => $_.value.keys[0] }).hash;
%meta<provides> = %meta<provides>.map({ $_.key => parse-value($_.value) }).hash;
my %sources = %meta<provides>.map({ $_.key => nqp::sha1($_.key ~ CompUnit::Repository::Distribution.new($candi.dist.compat).id) }).hash;

say "===> From Distribution: {~$candi.dist}";
@@ -510,14 +510,6 @@ package Zef::CLI {
say "Provides: {@provides.elems} modules";
if ?($verbosity >= VERBOSE) {

my sub parse-value($str-or-kv) {
do given $str-or-kv {
when Str { $_ }
when Hash { $_.keys[0] }
when Pair { $_.key }
}
}

my $meta := $dist.compat.meta;
my @rows = eager gather for @provides -> $lib {
FIRST {
@@ -942,4 +934,12 @@ package Zef::CLI {
say $sep;
}
}
sub parse-value($str-or-kv) {
do given $str-or-kv {
when Str { $_ }
when Hash { $_.keys[0] }
when Pair { $_.key }
}
}
}

0 comments on commit d866845

Please sign in to comment.