« blib/lib/Dist/Zilla/Plugin/Author/Plicease/Upload.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/Author/Plicease/Cleaner.pm »
| 1 | 2 | package Dist::Zilla::Plugin::Author::Plicease::Core 2.81 { | |||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.022; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Module::CoreList (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use version (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use experimental qw( signatures postderef ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use true; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Handle core prereqs | ||||||||||
| 11 | # VERSION | ||||||||||
| 12 | |||||||||||
| 13 | 2 | with 'Dist::Zilla::Role::PrereqSource', 'Dist::Zilla::Role::InstallTool'; | |||||||||
| 14 | |||||||||||
| 15 | has starting_version => ( | ||||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | lazy => 1, | ||||||||||
| 18 | 1 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | my($self) = @_; | |||||||||
| 20 | 1 | my $version = $self->zilla->prereqs->as_string_hash->{runtime}->{requires}->{perl}; | |||||||||
| 21 | 1 | $self->log("guessing perl version $version"); | |||||||||
| 22 | 1 | $version; | |||||||||
| 23 | }, | ||||||||||
| 24 | 2 | ); | |||||||||
| 25 | |||||||||||
| 26 | has check_at_configure => ( | ||||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | 2 | ▶ | default => sub { { } }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 2 | ); | |||||||||
| 30 | |||||||||||
| 31 | 2 | ▶ | sub register_prereqs ( $self ) | ||||||||
|
Subroutine
register_prereqs: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||
| 32 | { | ||||||||||
| 33 | 2 | my $prereqs = $self->zilla->prereqs->as_string_hash; | |||||||||
| 34 | |||||||||||
| 35 | 2 | foreach my $phase (keys %$prereqs) | |||||||||
| 36 | { | ||||||||||
| 37 | 8 | ▶ | next if $phase eq 'develop'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 6 | foreach my $type (keys $prereqs->{$phase}->%*) | |||||||||
| 39 | { | ||||||||||
| 40 | 6 | foreach my $module (sort keys %{ $prereqs->{$phase}->{$type} }) | |||||||||
| 41 | { | ||||||||||
| 42 | 16 | ▶ | next if $module =~ /^(ExtUtils::MakeMaker|Module::Build)$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 12 | my $value = $prereqs->{$phase}->{$type}->{$module}; | |||||||||
| 44 | 12 | ▶ | next unless $value == 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 8 | my $added_in = Module::CoreList->first_release($module); | |||||||||
| 46 | 8 | ▶ | next unless defined $added_in; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | #$self->log("considering $phase $type $module"); | ||||||||||
| 48 | #$self->log("addedin = $added_in"); | ||||||||||
| 49 | #$self->log("starting_version = @{[ version->parse($self->starting_version) ]}"); | ||||||||||
| 50 | #$self->log("added_in = @{[ version->parse($added_in) ]}"); | ||||||||||
| 51 | 6 | ▶ | if(version->parse($self->starting_version) >= version->parse($added_in)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | { | ||||||||||
| 53 | 5 | $self->log("removing prereq: $module"); | |||||||||
| 54 | 5 | $self->zilla->prereqs->requirements_for($phase, $type)->clear_requirement($module); | |||||||||
| 55 | 5 | $self->check_at_configure->{$module}++; | |||||||||
| 56 | } | ||||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 2 | ▶ | sub setup_installer ( $self ) | ||||||||
|
Subroutine
setup_installer: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | { | ||||||||||
| 64 | 2 | foreach my $file (grep { $_->name =~ /^(Makefile\.PL|Build\.PL)$/ } $self->zilla->files->@*) | |||||||||
| 65 | { | ||||||||||
| 66 | 2 | my $content = $file->content; | |||||||||
| 67 | |||||||||||
| 68 | $content = join "\n", | ||||||||||
| 69 | "BEGIN {", | ||||||||||
| 70 | " use strict; use warnings;", | ||||||||||
| 71 | " my \%missing = map {", | ||||||||||
| 72 | " eval qq{ require \$_ };", | ||||||||||
| 73 | " \$\@ ? (\$_=>1) : ()", | ||||||||||
| 74 | 2 | " } qw( @{[ sort keys %{ $self->check_at_configure } ]} );", | |||||||||
| 75 | " if(%missing)", | ||||||||||
| 76 | " {", | ||||||||||
| 77 | " print \"Your Perl is missing core modules: \@{[ sort keys \%missing ]}\\n\";", | ||||||||||
| 78 | 2 | (map { " print \"$_\\n\";" } | |||||||||
| 79 | "Ideally if you are using the system Perl you can install the appropriate", | ||||||||||
| 80 | "package which includes the core Perl modules. On at least some versions", | ||||||||||
| 81 | "of Fedora, CentOS and RHEL, this is the `perl-core` package.", | ||||||||||
| 82 | "", | ||||||||||
| 83 | " \% dnf install perl-core", | ||||||||||
| 84 | " ~ or ~", | ||||||||||
| 85 | " \% yum install perl-core", | ||||||||||
| 86 | "", | ||||||||||
| 87 | "If you really want to install dual-life modules from CPAN, then you can", | ||||||||||
| 88 | "use cpanm:", | ||||||||||
| 89 | "", | ||||||||||
| 90 | " \% cpanm \@{[ sort keys \%missing ]}", | ||||||||||
| 91 | "", | ||||||||||
| 92 | "Note that some core modules are not available from CPAN.", | ||||||||||
| 93 | ), | ||||||||||
| 94 | " exit;", | ||||||||||
| 95 | " }", | ||||||||||
| 96 | "}", | ||||||||||
| 97 | $content; | ||||||||||
| 98 | |||||||||||
| 99 | 2 | $file->content($content); | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | __END__ | ||||||||||