| 1 | package App::Midgen::Role::FindMinVersion; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use constant { ONE => 1, TWO => 2, TRUE => 1, FALSE => 0,}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Types::Standard qw( Bool ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | requires qw( ppi_document debug experimental verbose ); | |||||||||
| 8 | |||||||||||
| 9 | 2 | our $VERSION = '0.34'; | |||||||||
| 10 | 2 | $VERSION = eval $VERSION; ## no critic | |||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use Perl::MinimumVersion; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use Term::ANSIColor qw( :constants colored colorstrip ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use Data::Printer {caller_info => 1,}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | has 'mro_skip' => ( | ||||||||||
| 19 | is => 'rwp', | ||||||||||
| 20 | isa => Bool, | ||||||||||
| 21 | lazy => 1, | ||||||||||
| 22 | 0 | ▶ | default => sub { 0; }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | 2 | ); | |||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | ####### | ||||||||||
| 27 | # find min perl version - pmv | ||||||||||
| 28 | ###### | ||||||||||
| 29 | 0 | ▶ | sub min_version { | ||||||||
|
Subroutine
min_version: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 30 | 0 | my $self = shift; | |||||||||
| 31 | 0 | my $filename = shift; | |||||||||
| 32 | 0 | $filename =~ s{^/}{}; | |||||||||
| 33 | |||||||||||
| 34 | 0 | my $dist_min_ver = $App::Midgen::Min_Version; | |||||||||
| 35 | 0 | my $object; | |||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | $object = Perl::MinimumVersion->new($self->ppi_document); | |||||||||
| 39 | 0 | }; | |||||||||
| 40 | |||||||||||
| 41 | # Find the minimum version | ||||||||||
| 42 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 43 | 0 | ▶ | $dist_min_ver | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | = version->parse($dist_min_ver) | ||||||||||
| 45 | > version->parse($object->minimum_version) | ||||||||||
| 46 | ? version->parse($dist_min_ver) | ||||||||||
| 47 | : version->parse($object->minimum_version); | ||||||||||
| 48 | 0 | }; | |||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 51 | 0 | ▶ | $dist_min_ver | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | = version->parse($dist_min_ver) | ||||||||||
| 53 | > version->parse($object->minimum_explicit_version) | ||||||||||
| 54 | ? version->parse($dist_min_ver) | ||||||||||
| 55 | : version->parse($object->minimum_explicit_version); | ||||||||||
| 56 | 0 | }; | |||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 59 | 0 | ▶ | $dist_min_ver | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | = version->parse($dist_min_ver) | ||||||||||
| 61 | > version->parse($object->minimum_syntax_version) | ||||||||||
| 62 | ? version->parse($dist_min_ver) | ||||||||||
| 63 | : version->parse($object->minimum_syntax_version); | ||||||||||
| 64 | 0 | }; | |||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 67 | 0 | my $blame = $object->minimum_syntax_reason->element->content; | |||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | if ($blame =~ m/\bmro[\s|;]/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | $self->_set_mro_skip(TRUE); | |||||||||
| 71 | 0 | ▶ | print BRIGHT_BLACK | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | . 'Info: PMV blame = ' | ||||||||||
| 73 | . $blame | ||||||||||
| 74 | . ' -> 5.010 in ' | ||||||||||
| 75 | . $filename | ||||||||||
| 76 | . CLEAR . "\n" if ($self->verbose >= ONE); | ||||||||||
| 77 | } | ||||||||||
| 78 | 0 | }; | |||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | if ($self->mro_skip) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | ▶ | if (defined $self->{modules}{'MRO::Compat'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 0 | foreach my $index (0 .. $#{$self->{modules}{'MRO::Compat'}{infiles}}) { | |||||||||
| 83 | 0 | ▶ | if ($self->{modules}{'MRO::Compat'}{infiles}->[$index][0] eq '/' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | . $filename) | ||||||||||
| 85 | { | ||||||||||
| 86 | 0 | print BRIGHT_BLACK | |||||||||
| 87 | . 'Warning: ' | ||||||||||
| 88 | . WHITE . 'mro' | ||||||||||
| 89 | . BRIGHT_BLACK . ' & ' | ||||||||||
| 90 | . WHITE | ||||||||||
| 91 | . 'MRO::Compat' | ||||||||||
| 92 | . BRIGHT_BLACK | ||||||||||
| 93 | . ' in the same module ^^, hence skipping pmv.' | ||||||||||
| 94 | . CLEAR . "\n"; | ||||||||||
| 95 | 0 | $self->_set_mro_skip(FALSE); | |||||||||
| 96 | 0 | return; | |||||||||
| 97 | } | ||||||||||
| 98 | } | ||||||||||
| 99 | } | ||||||||||
| 100 | } | ||||||||||
| 101 | else { | ||||||||||
| 102 | 0 | ▶ | print "min_version - $dist_min_ver\n" if ($self->{verbose} == TWO); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 0 | $App::Midgen::Min_Version = version->parse($dist_min_ver)->numify; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | 0 | return; | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 2 | ▶ | no Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 110 | |||||||||||
| 111 | 2 | 1; | |||||||||
| 112 | |||||||||||
| 113 | |||||||||||
| 114 | __END__ | ||||||||||