class CompUnit::Repository::Installation

CompUnit::Repository::Installation

class CompUnit::Repository::Installation
    does CompUnit::Repository::Locally
    does CompUnit::Repository::Installable
    { }

A CompUnit::Repository implementation backed by the filesystem, but uses an internal storage format to:

Because of the internal storage format the usual way to add a distribution is not by copying files but by calling CompUnit::Repository::Installation#method_install.

Methods

method install

method install(Distribution $distributionBool :$force)

Copies modules into a special location so that they can be loaded afterwards.

:$force will allow installing over an existing distribution that has the same name, auth, api, and ver. Otherwise such a situation will result in Failure.

my $inst-repo = CompUnit::RepositoryRegistry.repository-for-name("site");
my $dist = Distribution::Path.new(...);
$inst-repo.install($dist);

method uninstall

method uninstall(Distribution $distribution)

Removes the $distribution from the repository. $distribution should be obtained from the repository it is being removed from:

my $inst-repo = CompUnit::RepositoryRegistry.repository-for-name("site");
my $dist = $inst-repo.candidates("Acme::Unused").head;
$inst-repo.uninstall($dist);

method candidates

multi method candidates(Str:D $name:$auth:$ver:$api)
multi method candidates(CompUnit::DependencySpecification $spec)

Return all distributions that contain a module matching the specified $name, auth, ver, and api.

my $inst-repo-path = CompUnit::RepositoryRegistry.repository-for-name("perl").prefix;
my $inst-repo = CompUnit::Repository::Installation.new(prefix => $inst-repo-path);
my $dist = $inst-repo.candidates("Test").head;
say "Test version: " ~ $dist.meta<ver># OUTPUT: «6.d␤»

method files

multi method files(Str:D $name:$auth:$ver:$api)
multi method files(CompUnit::DependencySpecification $spec)

Return all distributions that match the specified auth ver and api, and contains a non-module file matching the specified $name.

# assuming Zef is installed to the default location... 
my $repo = CompUnit::RepositoryRegistry.repository-for-name("site");
 
say $repo.files('bin/zef':ver<419.0+>).head.<name>              // "Nada"# OUTPUT: «Nada␤» 
say $repo.files('resources/config.txt':ver<419.0+>).head.<name> // "Nada"# OUTPUT: «Nada␤» 
 
say $repo.files('bin/zef':ver<0.4.0+>).head.<name>;                        # OUTPUT: «zef␤» 
say $repo.files('resources/config.txt':ver<0.4.0+>).head.<name>;           # OUTPUT: «zef␤»

method resolve

method resolve(CompUnit::DependencySpecification $spec --> CompUnit:D)

Returns a CompUnit mapped to the highest version distribution matching $spec from the first repository in the repository chain that contains any version of a distribution matching $spec.

method need

method need(
    CompUnit::DependencySpecification $spec,
    CompUnit::PrecompilationRepository $precomp = self.precomp-repository(),
    CompUnit::PrecompilationStore :@precomp-stores = self!precomp-stores(),
    --> CompUnit:D)

Loads and returns a CompUnit which is mapped to the highest version distribution matching $spec from the first repository in the repository chain that contains any version of a distribution matching $spec.

method load

method load(IO::Path:D $file --> CompUnit:D)

Load the $file and return a CompUnit object representing it.

method loaded

method loaded(--> Iterable:D)

Returns all CompUnits this repository has loaded.

method short-id

method short-id()

Returns the repo short-id, which for this repository is inst.

Type Graph

Type relations for CompUnit::Repository::Installation
perl6-type-graph CompUnit::Repository::Installation CompUnit::Repository::Installation Any Any CompUnit::Repository::Installation->Any CompUnit::Repository::Locally CompUnit::Repository::Locally CompUnit::Repository::Installation->CompUnit::Repository::Locally CompUnit::Repository::Installable CompUnit::Repository::Installable CompUnit::Repository::Installation->CompUnit::Repository::Installable Mu Mu Any->Mu

Expand above chart