| 1 | package URI::VersionRange::Version; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use feature ':5.10'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use URI::VersionRange::Util qw(generic_version_compare); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use constant DEBUG => $ENV{VERS_DEBUG}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | our $VERSION = '2.25'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 791 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 791 | my ($class, $scheme) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 791 | $scheme = lc $scheme; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 791 | my @CLASSES = ( | |||||||||||||||||||||||||||
| 23 | join('::', 'URI::VersionRange::Scheme', lc($scheme)), # Scheme specific | ||||||||||||||||||||||||||||
| 24 | join('::', 'URI::VersionRange::Version', lc($scheme)), # Scheme specific (legacy naming convention) | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 791 | foreach my $version_class (@CLASSES) { | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1540 | ▶ | if ($version_class->can('new') or eval "require $version_class; 1") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$version_class->can("new") or eval "require $version_class; 1"
MC/DC50%1/2
$version_class->can("new") or eval "require $version_class; 1"
$version_class->can("new")
eval "require $version_class; 1"
Truth table66%2/3
A or B
A= $version_class->can("new")B= eval "require $version_class; 1"
| |||||||||||||||||||||||||||||
| 30 | 42 | DEBUG and say STDERR "-- Loaded '$version_class' class"; | |||||||||||||||||||||||||||
| 31 | 42 | return $version_class; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1498 | ▶ | DEBUG and say STDERR "-- (E) Failed to load '$version_class' class: $@" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 749 | return $class; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 104 | ▶ | sub new { my $class = shift; bless [@_], $class } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub scheme { | ||||||||||||||||||||||||||
|
Subroutine
scheme: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | return (split(/\:\:/, shift, 4))[3]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 0 | my ($left, $right) = @_; | |||||||||||||||||||||||||||
| 50 | 0 | return generic_version_compare($left->[0], $right->[0]); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # CPAN | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | package # hide from pause | ||||||||||||||||||||||||||||
| 56 | 4 | URI::VersionRange::Scheme::cpan { | |||||||||||||||||||||||||||
| 57 | 4 | ▶ | use parent 'URI::VersionRange::Version'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | ▶ | use version(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 4 | ▶ | use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 20 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 20 | my ($left, $right) = @_; | |||||||||||||||||||||||||||
| 64 | 20 | return (version->parse($left->[0]) <=> version->parse($right->[0])); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # PyPi | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | package # hide from pause | ||||||||||||||||||||||||||||
| 71 | 4 | URI::VersionRange::Scheme::pypi { | |||||||||||||||||||||||||||
| 72 | 4 | ▶ | use parent 'URI::VersionRange::Version'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 4 | ▶ | use version(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 75 | 4 | ▶ | use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 32 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | 32 | my ($left, $right) = @_; | |||||||||||||||||||||||||||
| 79 | 32 | return (version->parse($left->[0]) <=> version->parse($right->[0])); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 4 | 1; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||