| 1 | package Module::Install::Admin::Metadata; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 46 | ▶ | use YAML::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 46 | ▶ | use Module::Install::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 46 | ▶ | use vars qw{$VERSION @ISA}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 46 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 46 | $VERSION = '1.21'; | |||||||||||||||||||||||||||
| 10 | 46 | @ISA = 'Module::Install::Base'; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub read_meta { | ||||||||||||||||||||||||||
|
Subroutine
read_meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 0 | (YAML::Tiny::LoadFile('META.yml'))[0]; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub meta_generated_by_us { | ||||||||||||||||||||||||||
|
Subroutine
meta_generated_by_us: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 0 | my $meta = $_[0]->read_meta; | |||||||||||||||||||||||||||
| 19 | 0 | my $want = ref($_[0]->_top); | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ( defined $_[1] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | $want .= " version $_[1]"; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 0 | return $meta->{generated_by} =~ /^\Q$want\E/; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub remove_meta { | ||||||||||||||||||||||||||
|
Subroutine
remove_meta: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 0 | my $ver = $self->_top->VERSION; | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | return unless -f 'META.yml'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return unless $self->meta_generated_by_us($ver); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | unless ( -w 'META.yml' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | warn "Can't remove META.yml file. Not writable.\n"; | |||||||||||||||||||||||||||
| 33 | 0 | return; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | # warn "Removing auto-generated META.yml\n"; | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless ( unlink 'META.yml' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | die "Couldn't unlink META.yml:\n$!"; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | return; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 39 | ▶ | sub write_meta { | ||||||||||||||||||||||||||
|
Subroutine
write_meta: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 39 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | 39 | ▶ | if ( -f "META.yml" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | return unless $self->meta_generated_by_us(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||
| 47 | 39 | $self->clean_files('META.yml'); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 39 | print "Writing META.yml\n"; | |||||||||||||||||||||||||||
| 50 | 39 | Module::Install::_write("META.yml", $self->dump_meta); | |||||||||||||||||||||||||||
| 51 | 39 | return; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 39 | ▶ | sub dump_meta { | ||||||||||||||||||||||||||
|
Subroutine
dump_meta: called CC=31 SCAR=40.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 39 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 39 | my $pkg = ref( $self->_top ); | |||||||||||||||||||||||||||
| 57 | 39 | my $ver = $self->_top->VERSION; | |||||||||||||||||||||||||||
| 58 | 39 | my $val = $self->Meta->{values}; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 39 | delete $val->{sign}; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # Dependencies MUST be assumed to be dynamic unless indicated | ||||||||||||||||||||||||||||
| 63 | # otherwise, otherwise a negligent author who accidentally forgets | ||||||||||||||||||||||||||||
| 64 | # to say which will release modules that break on some platforms. | ||||||||||||||||||||||||||||
| 65 | 39 | ▶ | unless ( defined $val->{dynamic_config} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 39 | $val->{dynamic_config} = 1; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 39 | my $perl_version = delete $val->{perl_version}; | |||||||||||||||||||||||||||
| 70 | 39 | ▶ | if ( $perl_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 37 | ▶ | $val->{requires} ||= []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$val->{"requires"} ||= []
MC/DC100%1/1
$val->{"requires"} ||= []
$val->{"requires"}
Truth table100%2/2
A
A= $val->{"requires"}
| |||||||||||||||||||||||||||||
| 72 | 37 | my $requires = $val->{requires}; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Issue warnings for unversioned core modules that are | ||||||||||||||||||||||||||||
| 75 | # already satisfied by the Perl version dependency. | ||||||||||||||||||||||||||||
| 76 | 37 | require Module::CoreList; | |||||||||||||||||||||||||||
| 77 | 37 | my $corelist = $Module::CoreList::version{$perl_version}; | |||||||||||||||||||||||||||
| 78 | 37 | ▶ | if ( $corelist ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | my @bad = grep { exists $corelist->{$_} } | |||||||||||||||||||||||||||
| 80 | 0 | map { $_->[0] } | |||||||||||||||||||||||||||
| 81 | 37 | grep { ! $_->[1] } | |||||||||||||||||||||||||||
| 82 | @$requires; | ||||||||||||||||||||||||||||
| 83 | 37 | foreach ( @bad ) { | |||||||||||||||||||||||||||
| 84 | # print "WARNING: Unversioned dependency on '$_' is pointless when Perl minimum version is $perl_version\n"; | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # Canonicalize to three-dot version after Perl 5.6 | ||||||||||||||||||||||||||||
| 89 | 37 | ▶ | if ( $perl_version >= 5.006 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e | ||||||||||||||||||||||||||
|
Condition0%0/4
$2 || 0
$3 || 0
MC/DC0%0/1
$2 || 0
$2
MC/DC0%0/1
$3 || 0
$3
Truth table0%0/2
A
A= $2
Truth table0%0/2
A
A= $3
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 37 | unshift @$requires, [ perl => $perl_version ]; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # Set a default 'unknown' license | ||||||||||||||||||||||||||||
| 96 | 39 | ▶ | unless ( $val->{license} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | warn "No license specified, setting license = 'unknown'\n"; | |||||||||||||||||||||||||||
| 98 | 0 | $val->{license} = 'unknown'; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # Most distributions are modules | ||||||||||||||||||||||||||||
| 102 | 39 | ▶ | $val->{distribution_type} ||= 'module'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$val->{"distribution_type"} ||= "module"
MC/DC0%0/1
$val->{"distribution_type"} ||= "module"
$val->{"distribution_type"}
Truth table50%1/2
A
A= $val->{"distribution_type"}
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # Check and derive names | ||||||||||||||||||||||||||||
| 105 | 39 | ▶ | if ( $val->{name} =~ /::/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | my $name = $val->{name}; | |||||||||||||||||||||||||||
| 107 | 0 | $name =~ s/::/-/g; | |||||||||||||||||||||||||||
| 108 | 0 | die "Error in name(): '$val->{name}' should be '$name'!\n"; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 39 | ▶ | if ( $val->{module_name} and ! $val->{name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$val->{"module_name"} and not $val->{"name"}
MC/DC0%0/2
$val->{"module_name"} and not $val->{"name"}
$val->{"module_name"}
not $val->{"name"}
Truth table33%1/3
A and not(B)
A= $val->{"module_name"}B= not $val->{"name"}
| |||||||||||||||||||||||||||||
| 111 | 0 | $val->{name} = $val->{module_name}; | |||||||||||||||||||||||||||
| 112 | 0 | $val->{name} =~ s/::/-/g; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | # Apply default no_index entries | ||||||||||||||||||||||||||||
| 116 | 39 | ▶ | $val->{no_index} ||= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$val->{"no_index"} ||= {}
MC/DC100%1/1
$val->{"no_index"} ||= {}
$val->{"no_index"}
Truth table100%2/2
A
A= $val->{"no_index"}
| |||||||||||||||||||||||||||||
| 117 | 39 | ▶ | $val->{no_index}->{directory} ||= []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$val->{"no_index"}{"directory"} ||= []
MC/DC100%1/1
$val->{"no_index"}{"directory"} ||= []
$val->{"no_index"}{"directory"}
Truth table100%2/2
A
A= $val->{"no_index"}{"directory"}
| |||||||||||||||||||||||||||||
| 118 | SCOPE: { | ||||||||||||||||||||||||||||
| 119 | 39 | my %seen = (); | |||||||||||||||||||||||||||
| 120 | $val->{no_index}->{directory} = [ | ||||||||||||||||||||||||||||
| 121 | sort | ||||||||||||||||||||||||||||
| 122 | 51 | grep { not $seen{$_}++ } | |||||||||||||||||||||||||||
| 123 | 320 | grep { -d $_ } ( | |||||||||||||||||||||||||||
| 124 | 39 | @{$val->{no_index}->{directory}}, | |||||||||||||||||||||||||||
| 125 | qw{ | ||||||||||||||||||||||||||||
| 126 | share inc t xt test | ||||||||||||||||||||||||||||
| 127 | example examples demo | ||||||||||||||||||||||||||||
| 128 | }, | ||||||||||||||||||||||||||||
| 129 | ) | ||||||||||||||||||||||||||||
| 130 | ]; | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | # Generate the structure we'll be dumping | ||||||||||||||||||||||||||||
| 134 | my $meta = { | ||||||||||||||||||||||||||||
| 135 | resources => {}, | ||||||||||||||||||||||||||||
| 136 | license => $val->{license}, | ||||||||||||||||||||||||||||
| 137 | dynamic_config => $val->{dynamic_config}, | ||||||||||||||||||||||||||||
| 138 | 39 | }; | |||||||||||||||||||||||||||
| 139 | 39 | foreach my $key ( $self->Meta_ScalarKeys ) { | |||||||||||||||||||||||||||
| 140 | 273 | ▶ | next if $key eq 'installdirs'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 234 | ▶ | next if $key eq 'tests'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 195 | ▶ | $meta->{$key} = $val->{$key} if exists $val->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 39 | foreach my $key ( $self->Meta_ArrayKeys ) { | |||||||||||||||||||||||||||
| 145 | 78 | ▶ | $meta->{$key} = $val->{$key} if exists $val->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 39 | foreach my $key ( $self->Meta_TupleKeys ) { | |||||||||||||||||||||||||||
| 148 | 234 | ▶ | next unless exists $val->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 156 | $meta->{$key} = { map { @$_ } @{ $val->{$key} } }; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 39 | ▶ | if ( $self->_cmp( $meta->{configure_requires}->{'ExtUtils::MakeMaker'}, '6.36' ) > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | # After this version ExtUtils::MakeMaker requires perl 5.6 | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | unless ( $perl_version && $self->perl_version($perl_version) >= 5.006 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$perl_version and $self->perl_version($perl_version) >= "5.006"
MC/DC0%0/2
$perl_version and $self->perl_version($perl_version) >= "5.006"
$perl_version
$self->perl_version($perl_version) >= "5.006"
Truth table0%0/3
A and B
A= $perl_versionB= $self->perl_version($perl_version) >= "5.006"
| |||||||||||||||||||||||||||||
| 155 | 0 | $meta->{requires}->{perl} = '5.006'; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 39 | ▶ | $meta->{provides} = $val->{provides} if $val->{provides}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 39 | $meta->{no_index} = $val->{no_index}; | |||||||||||||||||||||||||||
| 161 | 39 | $meta->{generated_by} = "$pkg version $ver"; | |||||||||||||||||||||||||||
| 162 | 39 | $meta->{'meta-spec'} = { | |||||||||||||||||||||||||||
| 163 | version => 1.4, | ||||||||||||||||||||||||||||
| 164 | url => 'http://module-build.sourceforge.net/META-spec-v1.4.html', | ||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||
| 166 | 39 | ▶ | unless ( scalar keys %{$meta->{resources}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | delete $meta->{resources}; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # Support version.pm versions | ||||||||||||||||||||||||||||
| 171 | 39 | ▶ | if ( UNIVERSAL::isa($meta->{version}, 'version') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | $meta->{version} = $meta->{version}->numify; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | # extra metadata | ||||||||||||||||||||||||||||
| 176 | 39 | foreach my $key (grep /^x_/, keys %$val) { | |||||||||||||||||||||||||||
| 177 | 1 | $meta->{$key} = $val->{$key}; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 39 | YAML::Tiny::Dump($meta); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | ###################################################################### | ||||||||||||||||||||||||||||
| 188 | # MYMETA.yml Support | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub WriteMyMeta { | ||||||||||||||||||||||||||
|
Subroutine
WriteMyMeta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 192 | 0 | $self->configure_requires( 'YAML::Tiny' => 1.36 ); | |||||||||||||||||||||||||||
| 193 | 0 | $self->write_mymeta; | |||||||||||||||||||||||||||
| 194 | 0 | return 1; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 46 | 1; | |||||||||||||||||||||||||||