Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CURL: Deprecate .path in favour of .IO
  • Loading branch information
lizmat committed Oct 26, 2014
1 parent 6ef0c72 commit d9c80f4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/core/CompUnitRepo/Local/File.pm
Expand Up @@ -29,7 +29,7 @@ class CompUnitRepo::Local::File does CompUnitRepo::Locally {
return () unless %extensions.exists_key($from);

my $dir-sep := $*SPEC.dir-sep;
my $base := $!path.abspath ~ $dir-sep ~ $name.subst(:g, "::", $dir-sep) ~ '.';
my $base := $!IO.abspath ~ $dir-sep ~ $name.subst(:g, "::", $dir-sep) ~ '.';
if %seen{$base} -> $found {
return $found;
}
Expand Down
15 changes: 7 additions & 8 deletions src/core/CompUnitRepo/Local/Installation.pm
Expand Up @@ -2,16 +2,15 @@ class CompUnitRepo::Local::Installation does CompUnitRepo::Locally {
has %!dists;
has $!cver = nqp::hllize(nqp::atkey(nqp::gethllsym('perl6', '$COMPILER_CONFIG'), 'version'));

method BUILD(:$path) {
$!WHICH = self.^name ~ '|' ~ $path;
$!path = $path.IO unless $!path;
my $manifest = $!path.child("MANIFEST");
%!dists{$path} = $manifest.e
method BUILD(:$!IO, :$!lock, :$!WHICH) {
my $manifest := $!IO.child("MANIFEST");
my $abspath := $!IO.abspath;
%!dists{$abspath} = $manifest.e
?? from-json($manifest.slurp)
!! {};
%!dists{$path}<file-count> //= 0;
%!dists{$path}<dist-count> //= 0;
%!dists{$path}<dists> //= [ ];
%!dists{$abspath}<file-count> //= 0;
%!dists{$abspath}<dist-count> //= 0;
%!dists{$abspath}<dists> //= [ ];
}

method writeable-path {
Expand Down
29 changes: 18 additions & 11 deletions src/core/CompUnitRepo/Locally.pm
@@ -1,27 +1,34 @@
role CompUnitRepo::Locally {
has Lock $!lock;
has IO::Path $.path;
has Str $!WHICH;
has IO::Path $.IO;
has Str $.WHICH;

my %instances;

method new(CompUnitRepo::Locally: $dir) {
my $path := IO::Path.new-from-absolute-path($*SPEC.rel2abs($dir));
return Nil unless $path.d and $path.r;
%instances{$path.abspath} //= self.bless(:$path, :lock(Lock.new));
}
my $abspath := $*SPEC.rel2abs($dir);
my $IO := IO::Path.new-from-absolute-path($abspath);
return Nil unless $IO.d and $IO.r;

multi method WHICH (CompUnitRepo::Locally:D:) {
$!WHICH //= self.^name ~ '|' ~ $!path.abspath;
%instances{$abspath} //=
self.bless(:$IO,:lock(Lock.new),:WHICH(self.^name ~ '|' ~ $abspath));
}
method Str(CompUnitRepo::Locally:D:) { $!path.abspath }

method Str(CompUnitRepo::Locally:D:) { $!IO.abspath }
method gist(CompUnitRepo::Locally:D:) {
"{self.short-id}:{$!path.abspath}"
"{self.short-id}:{$!IO.abspath}"
}
method perl(CompUnitRepo::Locally:D:) {
"CompUnitRepo.new('{self.short-id}:{$!path.abspath}')"
"CompUnitRepo.new('{self.short-id}:{$!IO.abspath}')"
}

method path(CompUnitRepo::Locally:D:) {
DEPRECATED( 'IO', |<2014.11 2015.11> );
$!IO;
}

multi method WHICH(CompUnitRepo::Locally:D:) { $!WHICH }

# stubs
method install(CompUnitRepo::Locally:D: $source, $from? ) {...}
method files(CompUnitRepo::Locally:D: $file, :$name, :$auth, :$ver) {...}
Expand Down

0 comments on commit d9c80f4

Please sign in to comment.