« blib/lib/Dist/Zilla/Plugin/DBIO/RequireCoreVersion.pm
↑ Summary
blib/lib/Pod/Weaver/PluginBundle/DBIO/Heritage.pm »
| 1 | package Dist::Zilla::Plugin::DBIO::LicenseFile; | ||||||||||||||||||||
| 2 | # ABSTRACT: Check the committed LICENSE against the license the dist is meant to carry | ||||||||||||||||||||
| 3 | 8 | our $VERSION = '0.900007'; | |||||||||||||||||||
| 4 | 8 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 8 | extends 'Dist::Zilla::Plugin::LicenseFile'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 8 | has heritage => ( | |||||||||||||||||||
| 9 | is => 'ro', | ||||||||||||||||||||
| 10 | isa => 'Bool', | ||||||||||||||||||||
| 11 | default => 0, | ||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 8 | my $HERITAGE_TEXT; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 5 | ▶ | sub heritage_text { | ||||||||||||||||||
|
Subroutine
heritage_text: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 18 | 5 | ▶ | $HERITAGE_TEXT //= do { local $/; scalar <DATA> }; | ||||||||||||||||||
|
Condition66%2/3
$HERITAGE_TEXT //= do {
local $/;
scalar readline DATA
}
MC/DC0%0/2
$HERITAGE_TEXT //= do {
local $/;
scalar readline DATA
}
$HERITAGE_TEXT
do {
local $/;
scalar readline DATA
}
Truth table66%2/3
A //= B
A= $HERITAGE_TEXTB= do {
local $/;
scalar readline DATA
}
| |||||||||||||||||||||
| 19 | 5 | return $HERITAGE_TEXT; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 8 | ▶ | around wanted_text => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 24 | 8 | my ($orig, $self, @args) = @_; | |||||||||||||||||||
| 25 | 8 | ▶ | return $self->heritage_text if $self->heritage; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 4 | return $self->$orig(@args); | |||||||||||||||||||
| 27 | 8 | }; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | # The parent tells the reader to run `dzil genlicense`, which would write | ||||||||||||||||||||
| 30 | # the wrong text for a heritage dist. | ||||||||||||||||||||
| 31 | 5 | ▶ | around _complain => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 32 | 5 | my ($orig, $self, $message) = @_; | |||||||||||||||||||
| 33 | 5 | ▶ | if ($self->heritage) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | 3 | $message =~ s/\. Run 'dzil genlicense' and commit the file\z//; | |||||||||||||||||||
| 35 | 3 | $message =~ s/it no longer matches the license in dist\.ini/it differs from the fixed text/; | |||||||||||||||||||
| 36 | 3 | $message =~ s/: run 'dzil genlicense' and commit the file\z//; | |||||||||||||||||||
| 37 | 3 | $message .= ": a heritage distribution must commit the fixed DBIx::Class " | |||||||||||||||||||
| 38 | . "license text (copy LICENSE from DBIO core)"; | ||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | 5 | return $self->$orig($message); | |||||||||||||||||||
| 41 | 8 | }; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 44 | 8 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 8 | 1; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =pod | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =encoding UTF-8 | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =head1 NAME | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | Dist::Zilla::Plugin::DBIO::LicenseFile - Check the committed LICENSE against the license the dist is meant to carry | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =head1 VERSION | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | version 0.900007 | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =head1 DESCRIPTION | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | Part of the C<[@DBIO]> bundle, which always adds it. It generates nothing: the | ||||||||||||||||||||
| 63 | F<LICENSE> is a committed file that L<Dist::Zilla::Plugin::Git::GatherDir> | ||||||||||||||||||||
| 64 | gathers like any other tracked file, and this plugin, a subclass of | ||||||||||||||||||||
| 65 | L<Dist::Zilla::Plugin::LicenseFile>, only checks the gathered file after the | ||||||||||||||||||||
| 66 | gathering is done. A missing or deviating F<LICENSE> aborts the build with a | ||||||||||||||||||||
| 67 | message that names the file and what is wrong. | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | Without C<heritage> the behaviour is the parent's: the gathered F<LICENSE> must | ||||||||||||||||||||
| 70 | be the license text of the distribution as L<Dist::Zilla> declares it (for | ||||||||||||||||||||
| 71 | C<[@DBIO]>: C<Perl_5> with the copyright holder and year of the dist). Run | ||||||||||||||||||||
| 72 | C<dzil genlicense> and commit the result when it is out of date. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | With C<heritage = 1> the expected text is a fixed one, held in this module: the | ||||||||||||||||||||
| 75 | notice that DBIO is a fork of L<DBIx::Class> followed by the original | ||||||||||||||||||||
| 76 | DBIx::Class license, exactly the F<LICENSE> the heritage repositories commit | ||||||||||||||||||||
| 77 | (413 lines). The gathered file must equal it, apart from trailing whitespace at | ||||||||||||||||||||
| 78 | the end. Copyright holder and year of the dist play no part here. A | ||||||||||||||||||||
| 79 | deviating text is fixed by copying the F<LICENSE> from DBIO core, not by | ||||||||||||||||||||
| 80 | C<dzil genlicense>. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head2 heritage | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | Boolean. Expect the fixed DBIx::Class heritage text instead of the license | ||||||||||||||||||||
| 87 | generated from the dist. The bundle passes its own C<heritage> option. | ||||||||||||||||||||
| 88 | Default: 0. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =head1 METHODS | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =head2 heritage_text | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | Class or object method. Returns the fixed heritage license text. | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =head2 wanted_text | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | The text the gathered F<LICENSE> is compared against: the heritage text when | ||||||||||||||||||||
| 99 | C<heritage> is set, otherwise whatever the parent class expects. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head1 AUTHOR | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | DBIO Authors | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | Copyright (C) 2026 DBIO Authors | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 110 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | __DATA__ | ||||||||||||||||||||