| 1 | package CPAN::Maker::Utils; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use CPAN::Maker::Constants qw( :all ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CLI::Simple::Constants qw(:booleans); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use CLI::Simple::Utils qw(slurp_json); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Module::CoreList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '2.0.13'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use parent qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our @EXPORT = qw(is_core trim is_array is_hash is_scalar get_json_file); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub is_core { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_core: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my ( $module_w_version, $perl_version ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my ( $module, $version ) = split /\s/xsm, $module_w_version; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($perl_version) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $perl_version = version->parse($perl_version); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my @ms = Module::CoreList->find_modules( qr/\A$module\z/xsm, $perl_version ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return $FALSE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | if !@ms; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # is core and we don't care about version | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return $TRUE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@ms and not $perl_version && $version
$perl_version && $version
MC/DC0%0/3
@ms and not $perl_version && $version
@ms
$perl_version
$version
Truth table0%0/4
A and not(B && C)
A= @msB= $perl_versionC= $version
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | if @ms && ( !$perl_version || !$version ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $modules = Module::CoreList->find_version($perl_version); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # return false if the version we want is > then provided by CORE | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( version->parse($version) > version->parse( $modules->{$module} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return $FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub get_json_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_json_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return slurp_json($file); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub _is_obj { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_obj: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my ( $this, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return ref $this && reftype($this) eq $type; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $this && builtin::reftype($this) eq $type
MC/DC0%0/2
ref $this && builtin::reftype($this) eq $type
ref $this
builtin::reftype($this) eq $type
Truth table0%0/3
A && B
A= ref $thisB= builtin::reftype($this) eq $type
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub is_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return _is_obj( $this, 'ARRAY' ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub is_scalar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_scalar: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return !ref $this; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub is_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return _is_obj( $this, 'HASH' ); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub trim { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | chomp $s; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $s =~ s/^\s*(.*?)$/$1/xsm; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||||||||||||||||