File Coverage

blib/lib/Alien/Base/ModuleBuild/Cabinet.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 6 66.6
condition n/a
subroutine 7 7 100.0
pod 0 4 0.0
total 34 40 85.0


line stmt bran cond sub pod time code
1             package Alien::Base::ModuleBuild::Cabinet;
2              
3 4     4   389 use strict;
  4         9  
  4         107  
4 4     4   17 use warnings;
  4         7  
  4         95  
5 4     4   446 use Sort::Versions qw( versioncmp );
  4         641  
  4         1025  
6              
7             # ABSTRACT: Private class
8             our $VERSION = '1.16_01'; # TRIAL VERSION
9             $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
10              
11             sub new {
12 5     5 0 7534 my $class = shift;
13 5 50       23 my $self = ref $_[0] ? shift : { @_ };
14              
15 5         23 bless $self, $class;
16              
17 5         19 return $self;
18             }
19              
20 10     10 0 40 sub files { shift->{files} }
21              
22             sub add_files {
23 5     5 0 514 my $self = shift;
24 5         12 push @{ $self->{files} }, @_;
  5         42  
25 5         19 return $self->files;
26             }
27              
28             sub sort_files {
29 4     4 0 7 my $self = shift;
30              
31             $self->{files} = [
32 7 100       149 sort { $b->has_version <=> $a->has_version || ($a->has_version ? versioncmp($b->version, $a->version) : versioncmp($b->filename, $a->filename)) }
    50          
33 4         8 @{ $self->{files} }
  4         19  
34             ];
35              
36             ## split files which have versions and those which don't (sorted on filename)
37             #my ($name, $version) = part { $_->has_version } @{ $self->{files} };
38             #
39             ## store the sorted lists of versioned, then non-versioned
40             #my @sorted;
41             #push @sorted, sort { versioncmp( $b->version, $a->version ) } @$version if $version;
42             #push @sorted, sort { versioncmp( $b->filename, $a->filename ) } @$name if $name;
43             #
44             #$self->{files} = \@sorted;
45              
46 4         27 return;
47             }
48              
49             1;
50              
51             __END__