|
| 1 | +=begin pod |
| 2 | +
|
| 3 | +=TITLE class CompUnit::Repository::Installation |
| 4 | +
|
| 5 | +=SUBTITLE CompUnit::Repository::Installation |
| 6 | +
|
| 7 | + class CompUnit::Repository::Installation |
| 8 | + does CompUnit::Repository::Locally |
| 9 | + does CompUnit::Repository::Installable |
| 10 | + { } |
| 11 | +
|
| 12 | +A L<CompUnit::Repository> implementation backed by the filesystem, but uses an internal |
| 13 | +storage format to: |
| 14 | +
|
| 15 | +=item Handle case sensitivity issues on filesystems that may conflict as a C<CompUnit::Repository::FileSystem>. |
| 16 | +=item Handle allowable filename issues (e.g. unicode) on filesystems that don't support them. |
| 17 | +=item Allow multiple distributions, possibly with the same name, to be installed in a single repository. |
| 18 | +=item Enable faster module loading. |
| 19 | +
|
| 20 | +Because of the internal storage format the usual way to add a distribution is not by copying |
| 21 | +files but by calling L<CompUnit::Repository::Installation#method_install>. |
| 22 | +
|
| 23 | +=head1 Methods |
| 24 | +
|
| 25 | +=head2 method install |
| 26 | +
|
| 27 | + method install(Distribution $distribution, Bool :$force) |
| 28 | +
|
| 29 | +Copies modules into a special location so that they can be loaded afterwards. |
| 30 | +
|
| 31 | +C<:$force> will allow installing over an existing distribution that has the same C<name>, |
| 32 | +C<auth>, C<api>, and C<ver>. Otherwise such a situation will result in L<Failure>. |
| 33 | +
|
| 34 | + my $inst-repo = CompUnit::RepositoryRegistry.repository-for-name("site"); |
| 35 | + my $dist = Distribution::Path.new(...); |
| 36 | + $inst-repo.install($dist); |
| 37 | +
|
| 38 | +=head2 method uninstall |
| 39 | +
|
| 40 | + method uninstall(Distribution $distribution) |
| 41 | +
|
| 42 | +Removes the C<$distribution> from the repository. C<$distribution> should be obtained from |
| 43 | +the repository it is being removed from: |
| 44 | +
|
| 45 | + my $inst-repo = CompUnit::RepositoryRegistry.repository-for-name("site"); |
| 46 | + my $dist = $inst-repo.candidates("Acme::Unused").head; |
| 47 | + $inst-repo.uninstall($dist); |
| 48 | +
|
| 49 | +=head2 method candidates |
| 50 | +
|
| 51 | + multi method candidates(Str:D $name, :$auth, :$ver, :$api) |
| 52 | + multi method candidates(CompUnit::DependencySpecification $spec) |
| 53 | +
|
| 54 | +Return all distributions that contain a module matching the specificed C<$name>, C<auth>, |
| 55 | +C<ver>, and C<api>. |
| 56 | +
|
| 57 | + my $inst-repo-path = CompUnit::RepositoryRegistry.repository-for-name("perl").prefix; |
| 58 | + my $inst-repo = CompUnit::Repository::Installation.new(prefix => $inst-repo-path); |
| 59 | + my $dist = $inst-repo.candidates("Test").head; |
| 60 | + say "Test version: " ~ $dist.meta<ver>; # OUTPUT: «6.d» |
| 61 | +
|
| 62 | +=head2 method files |
| 63 | +
|
| 64 | + multi method files(Str:D $name, :$auth, :$ver, :$api) |
| 65 | + multi method files(CompUnit::DependencySpecification $spec) |
| 66 | +
|
| 67 | +Return all distributions that match the specified C<auth> C<ver> and C<api>, and |
| 68 | +contains a non-module file matching the specified C<$name>. |
| 69 | +
|
| 70 | + # assuming Zef is installed to the default location... |
| 71 | + my $repo = CompUnit::RepositoryRegistry.repository-for-name("site"); |
| 72 | +
|
| 73 | + say $repo.files('bin/zef', :ver<419.0+>).head.<name> // "Nada"; # OUTPUT: «Nada» |
| 74 | + say $repo.files('resources/config.txt', :ver<419.0+>).head.<name> // "Nada"; # OUTPUT: «Nada» |
| 75 | +
|
| 76 | + say $repo.files('bin/zef', :ver<0.4.0+>).head.<name>; # OUTPUT: «zef» |
| 77 | + say $repo.files('resources/config.txt', :ver<0.4.0+>).head.<name>; # OUTPUT: «zef» |
| 78 | +
|
| 79 | +=head2 method resolve |
| 80 | +
|
| 81 | + method resolve(CompUnit::DependencySpecification $spec --> CompUnit:D) |
| 82 | +
|
| 83 | +Returns a L<CompUnit> mapped to the highest version distribution matching C<$spec> from |
| 84 | +the first repository in the repository chain that contains any version of a distribution |
| 85 | +matching C<$spec>. |
| 86 | +
|
| 87 | +=head2 method need |
| 88 | +
|
| 89 | + method need( |
| 90 | + CompUnit::DependencySpecification $spec, |
| 91 | + CompUnit::PrecompilationRepository $precomp = self.precomp-repository(), |
| 92 | + CompUnit::PrecompilationStore :@precomp-stores = self!precomp-stores(), |
| 93 | + --> CompUnit:D) |
| 94 | +
|
| 95 | +Loads and returns a L<CompUnit> which is mapped to the highest version distribution |
| 96 | +matching C<$spec> from the first repository in the repository chain that contains |
| 97 | +any version of a distribution matching C<$spec>. |
| 98 | +
|
| 99 | +=head2 method load |
| 100 | +
|
| 101 | + method load(IO::Path:D $file --> CompUnit:D) |
| 102 | +
|
| 103 | +Load the C<$file> and return a L<CompUnit> object representing it. |
| 104 | +
|
| 105 | +=head2 method loaded |
| 106 | +
|
| 107 | + method loaded(--> Iterable:D) |
| 108 | +
|
| 109 | +Returns all L<CompUnit>s this repository has loaded. |
| 110 | +
|
| 111 | +=head2 method short-id |
| 112 | +
|
| 113 | + method short-id() |
| 114 | +
|
| 115 | +Returns the repo short-id, which for this repository is C<inst>. |
| 116 | +
|
| 117 | +=end pod |
| 118 | + |
| 119 | +# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6 |
0 commit comments