Aggregator/Sort.pm

filter: Statementstmt 25.0% 6 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 28.5% 2 / 7 Podpod 66.6% 2 / 3 totaltotal 17.8% 10 / 56 CC 6 SCAR 20.1
CC
6
Cov
16%
__ANON__
12.0
__ANON__
12.0
sort
6.0
CRAP 7.5
« Aggregator/Deduper.pm ↑ Summary Aggregator.pm »
1 package XML::Feed::Aggregator::Sort;
2 6 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 $XML::Feed::Aggregator::Sort::VERSION = '0.0401';
4 }
5 6 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 requires 'sort_entries';
7  
8 0 ▶sub sort_by_date {
Subroutine sort_by_date: not called CC=1 SCAR=6.9
Pod documented
9 0 my ($self) = @_;
10  
11 0 ▶ $self->sort_entries(sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
12 0 ▶ my $adt = $_[0]->issued || $_[0]->modified;
Condition0%0/3
$_[0]->issued || $_[0]->modified
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]->issued || $_[0]->modified
$_[0]->issued $_[0]->modified
Truth table0%0/3
A || B
A= $_[0]->issuedB= $_[0]->modified
ABresult
1X1
011
000
13 0 ▶ my $bdt = $_[1]->issued || $_[1]->modified;
Condition0%0/3
$_[1]->issued || $_[1]->modified
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1]->issued || $_[1]->modified
$_[1]->issued $_[1]->modified
Truth table0%0/3
A || B
A= $_[1]->issuedB= $_[1]->modified
ABresult
1X1
011
000
14 0 return $adt->compare($bdt);
15 0 });
16  
17 0 return $self;
18 }
19  
20 0 ▶sub sort_by_date_ascending {
Subroutine sort_by_date_ascending: not called CC=1 SCAR=6.9
Pod documented
21 0 my ($self) = @_;
22
23 0 ▶ $self->sort_entries(sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
24 0 ▶ my $adt = $_[0]->issued || $_[0]->modified;
Condition0%0/3
$_[0]->issued || $_[0]->modified
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]->issued || $_[0]->modified
$_[0]->issued $_[0]->modified
Truth table0%0/3
A || B
A= $_[0]->issuedB= $_[0]->modified
ABresult
1X1
011
000
25 0 ▶ my $bdt = $_[1]->issued || $_[1]->modified;
Condition0%0/3
$_[1]->issued || $_[1]->modified
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1]->issued || $_[1]->modified
$_[1]->issued $_[1]->modified
Truth table0%0/3
A || B
A= $_[1]->issuedB= $_[1]->modified
ABresult
1X1
011
000
26 0 return $bdt->compare($adt);
27 0 });
28  
29 0 return $self;
30 }
31  
32 0 ▶sub sort {
Subroutine sort: not called CC=2 SCAR=17.9
Pod undocumented
33 0 my ($self, $order) = @_;
34  
35 0 warn "Called deprecated method ->sort";
36  
37 0 ▶ if ($order eq 'desc') {
Branch: 1 branch
BranchTrueFalseTotal
if ($order eq 'desc') { } 0 0 0
38 0 $self->sort_by_date;
39 }
40 else {
41 0 $self->sort_by_date_ascending;
42 }
43  
44 0 return $self;
45 }
46  
47 6 1;
48  
49  
50 =pod
51  
52 =head1 NAME
53  
54 XML::Feed::Aggregator::Sort
55  
56 =head1 VERSION
57  
58 version 0.0401
59  
60 =head1 SYNOPSIS
61  
62 # builtin sort methods:
63  
64 $aggregator->sort_by_date_ascending;
65 $aggregator->sort_by_date;
66  
67 # custom sort routine
68  
69 $aggregator->sort_entries(sub {
70 $_[0]->title cmp $_[1]->title
71 });
72  
73 =head1 NAME
74  
75 XML::Feed::Aggregator::Sort - Role for sorting feed entries
76  
77 =head1 METHODS
78  
79 =head2 sort_entries
80  
81 Provide your own sorting routine via a CodeRef, two entries provided as arguments.
82  
83 =head2 sort_by_date
84  
85 Sort entries with date in descending order.
86  
87 =head2 sort_by_date_ascending
88  
89 Sort entries with date in ascending order.
90  
91 =head1 SEE ALSO
92  
93 L<XML::Feed::Aggregator>
94  
95 L<XML::Feed::Aggregator::Deduper>
96  
97 =head1 AUTHOR
98  
99 Robin Edwards <robin.ge@gmail.com>
100  
101 =head1 COPYRIGHT AND LICENSE
102  
103 This software is copyright (c) 2011 by Robin Edwards.
104  
105 This is free software; you can redistribute it and/or modify it under
106 the same terms as the Perl 5 programming language system itself.
107  
108 =cut
109  
110  
111 __END__
« Aggregator/Deduper.pm ↑ Summary Aggregator.pm »