Dist-Conformance

 view release on metacpan or  search on metacpan

lib/Dist/Conformance/Check/DistFiles.pm  view on Meta::CPAN

package Dist::Conformance::Check::DistFiles 0.003;

# ABSTRACT: A distribution has the files that its build needs

use 5.040;
use warnings FATAL => 'all';
use re '/aasx';
use Mojo::Base 'Dist::Conformance::Check::ToolConfiguration', -signatures;

use Dist::Conformance::Schema();


sub config_schema ($class) {
    my $schema = $class->SUPER::config_schema;
    return {
        required   => [ 'marker', @{ $schema->{required} } ],
        properties => {
            %{ $schema->{properties} },
            marker => $Dist::Conformance::Schema::PATH,
            absent => { %$Dist::Conformance::Schema::STATUS, default => 'info' },
        },
    };
}


sub check ( $self, $snapshot ) {
    my $marker = $self->config->{marker};
    return ( $self->config->{absent}, "no $marker" ) if !$snapshot->contains($marker);
    return $self->SUPER::check($snapshot);
}


sub update ( $self, $update ) {
    return if !$update->snapshot->contains( $self->config->{marker} );
    return $self->SUPER::update($update);
}

__END__

=pod

=encoding UTF-8

=head1 NAME

Dist::Conformance::Check::DistFiles - A distribution has the files that its build needs

=head1 VERSION

version 0.003

=head1 DESCRIPTION

L<Dist::Conformance::Check::ToolConfiguration>, for a repository that has a
marker file.  A repository without F<dist.ini> is not a Dist::Zilla
distribution, so it needs no F<weaver.ini>.  Without the marker the check
reports C<absent> and the update does nothing.  With it, it is the same as
L<Dist::Conformance::Check::ToolConfiguration>.

A flavor for a repository that is never a distribution can remove this check
with C<DistFiles: ~>.

=head1 METHODS

=head2 check

=head2 update

Does nothing without the marker.

=head1 IN A FLAVOR

    checks:
      DistFiles:
        marker: dist.ini
        absent: info
        files:
          weaver.ini: templates/weaver.ini
          Changes: templates/Changes
          prereqs.yml: templates/prereqs.yml

=head1 CONFIGURATION

=over

=item marker

Required.  The path whose presence makes the repository one that needs the
files.

=item absent

The status without the marker.  Default C<info>.



( run in 0.758 second using v1.01-cache-2.11-cpan-1236ad508bc )