Distribution

=title class Zef::Distribution
=subtitle A generic Distribution implementation

Synopsis

    use Zef::Distribution;
    use JSON::Fast;
    my %meta = from-json("META6.json".IO.slurp);
    my $dist = Zef::Distribution.new(|%meta);
    # Show the meta data
    say $dist.meta.raku;
    # Output if the $dist contains a namespace matching Foo::Bar:ver<1>
    say $dist.contains-spec("Foo::Bar:ver<1>");

Description

A Distribution implementation that is used to represent not-yet-downloaded distributions. Generally you should use this class using the Distribution interface and not as a struct representation of META6 data -- i.e. use $dist.meta.hash{"version"} instead of <$dist.ver>. These variations are a wart included mostly for backwards compatibility purposes (or just leftover from years of changes to e.g. CompUnit::Repository and friends).

When using this class "best practice" would be to consider the following methods are the public api: meta and content (the Distribution interface methods), depends-specs, test-depends-specs, build-depends-specs, provides-specs, provides-spec-matcher, contains-spec, Str

Methods

method meta

method meta(--> Hash:D)

Returns the meta data that represents the distribution.

method content

method content()

Will always throw an exception. This class is primarily used to represent a distribution when all we have it meta data; use a class like Zef::Distribution::Local (which subclasses this class) if or when you need access to the content of files besides META6.json.

method depends-specs

method depends-specs(--> Array[Zef::Distribution::DependencySpecification])

Return an Array of DependencySpecification for the runtime dependencies of the distribution.

method test-depends-specs

method test-depends-specs(--> Array[Zef::Distribution::DependencySpecification])

Return an Array of DependencySpecification for the test dependencies of the distribution.

method depends-specs

method build-depends-specs(--> Array[Zef::Distribution::DependencySpecification])

Return an Array of DependencySpecification for the build dependencies of the distribution.

method provides-specs

method provides-specs(--> Array[Zef::Distribution::DependencySpecification])

Return an Array of DependencySpecification for the namespaces in the distributions provides.

method provides-spec-matcher

method provides-spec-matcher(Zef::Distribution::DependencySpecification $spec, :$strict --> Bool:D) { self.provides-specs.first({ ?$_.spec-matcher($spec, :$strict) }) }

Returns True if $spec matches any namespaces this distribution provides (but not the name of the distribution itself). If $strict is False then partial name matches will be allowed (i.e. HTTP matching HTTP::UserAgent).

method contains-spec

multi method contains-spec(Str $spec, |c --> Bool:D)
        multi method contains-spec(Zef::Distribution::DependencySpecification $spec, Bool :$strict = True --> Bool:D)
        multi method contains-spec(Zef::Distribution::DependencySpecification::Any $spec, Bool :$strict = True --> Bool:D)

Returns True if $spec matches any namespace this distribution provides, including the name of the distribution itself. If $strict is False then partial name matches will be allowed (i.e. HTTP matching HTTP::UserAgent).

When given a Str $spec the $spec will be turned into a Zef::Distribution::DependencySpecification.

method Str

method Str(--> Str)

Returns the explicit full name of the distribution, i.e. Foo -> Foo:ver<:auth<>:api<>>

method id

method id(--> Str)

Returns a file system safe unique string identifier for the distribution. This is generally meant for internal use only.

Note: This should not publicly be relied on for matching any Raku implementation details this may appear to be emulating.

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.