| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Dist::Zilla::Plugin::Author::Plicease::Core 2.41 { | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 719 | use 5.014; | 
|  | 1 |  |  |  |  | 2 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use Moose; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 5 | 1 |  |  | 1 |  | 7653 | use Module::CoreList (); | 
|  | 1 |  |  |  |  | 82889 |  | 
|  | 1 |  |  |  |  | 571 |  | 
| 6 | 1 |  |  | 1 |  | 14 | use version (); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 640 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | # ABSTRACT: Handle core prereqs | 
| 9 |  |  |  |  |  |  | # VERSION | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | with 'Dist::Zilla::Role::PrereqSource', 'Dist::Zilla::Role::InstallTool'; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | has starting_version => ( | 
| 14 |  |  |  |  |  |  | is      => 'ro', | 
| 15 |  |  |  |  |  |  | lazy    => 1, | 
| 16 |  |  |  |  |  |  | default => sub { | 
| 17 |  |  |  |  |  |  | my($self) = @_; | 
| 18 |  |  |  |  |  |  | my $version = $self->zilla->prereqs->as_string_hash->{runtime}->{requires}->{perl}; | 
| 19 |  |  |  |  |  |  | $self->log("guessing perl version $version"); | 
| 20 |  |  |  |  |  |  | $version; | 
| 21 |  |  |  |  |  |  | }, | 
| 22 |  |  |  |  |  |  | ); | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | has check_at_configure => ( | 
| 25 |  |  |  |  |  |  | is      => 'ro', | 
| 26 |  |  |  |  |  |  | default => sub { { } }, | 
| 27 |  |  |  |  |  |  | ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub register_prereqs | 
| 30 |  |  |  |  |  |  | { | 
| 31 | 0 |  |  | 0 | 0 |  | my($self) = @_; | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 0 |  |  |  |  |  | my $prereqs = $self->zilla->prereqs->as_string_hash; | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 0 |  |  |  |  |  | foreach my $phase (keys %$prereqs) | 
| 36 |  |  |  |  |  |  | { | 
| 37 | 0 |  |  |  |  |  | foreach my $type (keys %{ $prereqs->{$phase} }) | 
|  | 0 |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | { | 
| 39 | 0 |  |  |  |  |  | foreach my $module (sort keys %{ $prereqs->{$phase}->{$type} }) | 
|  | 0 |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | { | 
| 41 | 0 | 0 |  |  |  |  | next if $module =~ /^(ExtUtils::MakeMaker|Module::Build)$/; | 
| 42 | 0 |  |  |  |  |  | my $value = $prereqs->{$phase}->{$type}->{$module}; | 
| 43 | 0 | 0 |  |  |  |  | next unless $value == 0; | 
| 44 | 0 |  |  |  |  |  | my $added_in = Module::CoreList->first_release($module); | 
| 45 | 0 | 0 |  |  |  |  | next unless defined $added_in; | 
| 46 |  |  |  |  |  |  | #$self->log("considering $phase $type $module"); | 
| 47 |  |  |  |  |  |  | #$self->log("addedin = $added_in"); | 
| 48 |  |  |  |  |  |  | #$self->log("starting_version = @{[ version->parse($self->starting_version) ]}"); | 
| 49 |  |  |  |  |  |  | #$self->log("added_in         = @{[ version->parse($added_in) ]}"); | 
| 50 | 0 | 0 |  |  |  |  | if(version->parse($self->starting_version) >= version->parse($added_in)) | 
| 51 |  |  |  |  |  |  | { | 
| 52 | 0 |  |  |  |  |  | $self->log("removing prereq: $module"); | 
| 53 | 0 |  |  |  |  |  | $self->zilla->prereqs->requirements_for($phase, $type)->clear_requirement($module); | 
| 54 | 0 |  |  |  |  |  | $self->check_at_configure->{$module}++; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | sub setup_installer | 
| 62 |  |  |  |  |  |  | { | 
| 63 | 0 |  |  | 0 | 0 |  | my($self) = @_; | 
| 64 | 0 |  |  |  |  |  | foreach my $file (grep { $_->name =~ /^(Makefile\.PL|Build\.PL)$/ } @{ $self->zilla->files }) | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | { | 
| 66 | 0 |  |  |  |  |  | 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 | 0 |  |  |  |  |  | "  } qw( @{[ sort keys %{ $self->check_at_configure } ]} );", | 
|  | 0 |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | "  if(%missing)", | 
| 76 |  |  |  |  |  |  | "  {", | 
| 77 |  |  |  |  |  |  | "    print \"Your Perl is missing core modules: \@{[ sort keys \%missing ]}\\n\";", | 
| 78 | 0 |  |  |  |  |  | (map { "    print \"$_\\n\";" } | 
|  | 0 |  |  |  |  |  |  | 
| 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 | 0 |  |  |  |  |  | $file->content($content); | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | 1; | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | __END__ | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =pod | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =encoding UTF-8 | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =head1 NAME | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | Dist::Zilla::Plugin::Author::Plicease::Core - Handle core prereqs | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =head1 VERSION | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | version 2.41 | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head1 AUTHOR | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | Graham Ollis <plicease@cpan.org> | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | This software is copyright (c) 2017 by Graham Ollis. | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 132 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =cut |