| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | package Mariachi; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Email::Thread; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Time::HiRes qw( gettimeofday tv_interval ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Storable qw( store retrieve ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Path qw( mkpath ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::Copy qw( copy move ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Find::Rule; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use base qw( Class::Accessor::Fast ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = '0.52'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | __PACKAGE__->mk_accessors( qw( config messages rootset | |||||||||||||||||||||||||||||||||||||||||
| 15 | start_time last_time tt ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | Mariachi - all dancing mail archive generator | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 ACESSORS | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | =head2 ->config | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | An L<AppConfig> object containing the current configuration. See | ||||||||||||||||||||||||||||||||||||||||||
| 28 | L<mariachi> for details of the configurable items. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head2 ->messages | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | The current set of messages | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =head2 ->rootset | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | The rootset of threaded messages | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head2 ->start_time | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =head2 ->last_time | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | Used internally by the C<_bench> method | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | All of these are instance methods, unless stated. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head2 ->new( %initial_values ) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | your general class-method constructor | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $class->SUPER::new({@_}); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _bench { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bench: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $now = [gettimeofday]; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $start = $self->start_time; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $last = $self->last_time || $now; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->last_time || $now
MC/DC0%0/2
$self->last_time || $now
$self->last_time
$now
Truth table0%0/3
A || B
A= $self->last_timeB= $now
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $start = $self->start_time($now) unless $start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | printf "%-50s %.3f elapsed %.3f total\n", | |||||||||||||||||||||||||||||||||||||||||
| 70 | $message, tv_interval( $last, $now ), tv_interval( $start, $now ); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->last_time($now); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =head2 ->load | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | populate C<messages> from C<input> | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $folder = Mariachi::Folder->new( $self->config->input ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | or die "Unable to open ".$self->config->input; | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $cache; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $cache = $self->config->input.".cache" if $ENV{M_CACHE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($cache && -e $cache && !$self->config->refresh) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$cache and -e $cache and not $self->config->refresh
$cache and -e $cache
MC/DC0%0/3
$cache and -e $cache and not $self->config->refresh
$cache
-e $cache
not $self->config->refresh
Truth table0%0/4
A and B and not(C)
A= $cacheB= -e $cacheC= not $self->config->refresh
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | print "pulling in $cache\n"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->messages( retrieve( $cache ) ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my @msgs; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | while (my $msg = $folder->next_message) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | push @msgs, $msg; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | print STDERR "\r$count messages" if ++$count % 100 == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($cache) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | print "caching\n"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | store( \@msgs, $cache ); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->messages( \@msgs ); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =head2 ->dedupe | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | remove duplicates from C<messages> | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub dedupe { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dedupe: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my (%seen, @new, $dropped); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $dropped = 0; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | for my $mail (@{ $self->messages }) { | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $msgid = $mail->header('message-id'); | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ($seen{$msgid}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $dropped++; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | push @new, $mail; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | print "dropped $dropped duplicate messages\n"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->messages(\@new); | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | =head2 ->sanitise | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | some messages have been near mail2news gateways, which means that some | ||||||||||||||||||||||||||||||||||||||||||
| 138 | message ids in the C<references> and C<in-reply-to> headers get munged | ||||||||||||||||||||||||||||||||||||||||||
| 139 | like so: <$group/$message_id> | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | fix this in C<messages> | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub sanitise { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sanitise: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | for my $mail (@{ $self->messages }) { | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | for (qw( references in_reply_to )) { | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my $hdr = $mail->header($_) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $before = $hdr; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $hdr =~ s{<[^>]*?/}{<}g or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | #print "$_ $before$_: $hdr"; | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $mail->header_set($_, $hdr); | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | =head2 ->thread | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | populate C<rootset> with an Email::Thread::Containers created from | ||||||||||||||||||||||||||||||||||||||||||
| 162 | C<messages> | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | # the Fisher-Yates shuffle from perlfaq4 | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub _shuffle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shuffle: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $array = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | for ($i = @$array; --$i; ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $j = int rand ($i+1); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | @$array[$i,$j] = @$array[$j,$i]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub thread { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 178 | #_shuffle $self->messages; | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $threader = Email::Thread->new( @{ $self->messages } ); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $threader->thread; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->rootset( [ grep { $_->topmost } $threader->rootset ] ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | =head2 ->order | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | order C<rootset> by date | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub order { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my @rootset = @{ $self->rootset }; | |||||||||||||||||||||||||||||||||||||||||
| 194 | $_->order_children( | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | sort { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | eval { $a->topmost->message->epoch_date } <=> | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | eval { $b->topmost->message->epoch_date } | |||||||||||||||||||||||||||||||||||||||||
| 199 | } @_ | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | }) for @rootset; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # we actually want the root set to be ordered latest first | ||||||||||||||||||||||||||||||||||||||||||
| 203 | @rootset = sort { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $b->topmost->message->epoch_date <=> $a->topmost->message->epoch_date | |||||||||||||||||||||||||||||||||||||||||
| 205 | } @rootset; | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # And optionally reverse the order | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | @rootset = reverse(@rootset) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | if $self->config->reverse; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->rootset( \@rootset ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =head2 ->sanity | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | (in)sanity test - check everything in C<messages> is reachable when | ||||||||||||||||||||||||||||||||||||||||||
| 217 | walking C<rootset> | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub sanity { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sanity: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my %mails = map { $_ => $_ } @{ $self->messages }; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $count; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | my $check = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | my $cont = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | my $mail = $cont->message or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ++$count; | |||||||||||||||||||||||||||||||||||||||||
| 230 | #print STDERR "\rverify $count"; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | delete $mails{ $mail || '' }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mail || ''
MC/DC0%0/1
$mail || ''
$mail
Truth table0%0/2
A
A= $mail
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $_->iterate_down( $check ) for @{ $self->rootset }; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | undef $check; | |||||||||||||||||||||||||||||||||||||||||
| 235 | #print STDERR "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return unless %mails; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | die "\nDidn't see ".(scalar keys %mails)." messages"; | |||||||||||||||||||||||||||||||||||||||||
| 239 | print join "\n", map { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my @ancestors; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $x = $_->container; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 243 | my $last; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | while ($x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($seen{$x}++) { push @ancestors, "$x ancestor loop!\n"; last } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $extra = $x->{id}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | $extra .= " one-way" | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if $last && !grep { $last == $_ } $x->children; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$last and not grep({$last == $_;} $x->children)
MC/DC0%0/2
$last and not grep({$last == $_;} $x->children)
$last
not grep({$last == $_;} $x->children)
Truth table0%0/3
A and not(B)
A= $lastB= not grep({$last == $_;} $x->children)
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | push @ancestors, $x." $extra"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $last = $x; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $x = $x->parent; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $_->header("message-id"), @ancestors | |||||||||||||||||||||||||||||||||||||||||
| 254 | } values %mails; | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =head2 ->strand | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | run a strand through all C<messages> - wander over C<threader> setting | ||||||||||||||||||||||||||||||||||||||||||
| 261 | the Message ->next and ->prev links | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub strand { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strand: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $prev; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | for my $root (@{ $self->rootset }) { | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | my $mail = $_[0]->message or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $prev->next($mail) if $prev; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $mail->prev($prev); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $mail->root($root); | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $prev = $mail; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $root->iterate_down( $sub ); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | undef $sub; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | =head2 ->split_deep | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | wander over C<rootset> reparenting subthreads that are | ||||||||||||||||||||||||||||||||||||||||||
| 286 | considered too deep | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub split_deep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_deep: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my @toodeep; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | for my $root (@{ $self->rootset }) { | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my ($cont, $depth) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # only note first entries | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ($depth && ($depth % 6 == 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$depth and $depth % 6 == 0 and $cont->parent->child == $cont
$depth and $depth % 6 == 0
MC/DC0%0/3
$depth and $depth % 6 == 0 and $cont->parent->child == $cont
$depth
$depth % 6 == 0
$cont->parent->child == $cont
Truth table0%0/4
A and B and C
A= $depthB= $depth % 6 == 0C= $cont->parent->child == $cont
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | && $cont->parent->child == $cont) { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | push @toodeep, $cont; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $root->iterate_down( $sub ); | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | undef $sub; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | print "splicing threads in ", scalar @toodeep, " places\n"; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | for (@toodeep) { | |||||||||||||||||||||||||||||||||||||||||
| 311 | # the top one needs to be empty, because we're cheating. | ||||||||||||||||||||||||||||||||||||||||||
| 312 | # to keep references straight, we'll move its content | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $top = $_->topmost; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $root = $top->message->root or die "batshit!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ($root->message) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $new = Mail::Thread::Container->new($root->messageid); | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $root->messageid('dummy'); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $new->message($root->message); | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $root->message(undef); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $new->child($root->child); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $root->child($new); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $root = $new; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $root->add_child( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =head2 ->copy_files | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | copy files into the output dir | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub copy_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_files: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | for my $dir (@{ $self->config->templates }) { | |||||||||||||||||||||||||||||||||||||||||
| 340 | my @files = map { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | s{$dir/?}{}; $_ | |||||||||||||||||||||||||||||||||||||||||
| 342 | } find( or => [ find( directory => | ||||||||||||||||||||||||||||||||||||||||||
| 343 | name => [ qw( CVS .svn ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 344 | prune => | ||||||||||||||||||||||||||||||||||||||||||
| 345 | discard => ), | ||||||||||||||||||||||||||||||||||||||||||
| 346 | find( file => '!name' => [ '*.tt2', '*~', '*.bak' ] ) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 348 | in => $dir ); | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | for (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | mkpath dirname $self->config->output . "/$_"; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | copy( "$dir/$_", $self->config->output . "/$_" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | or die "couldn't copy $dir/$_ $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | =head2 init_tt | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub init_tt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_tt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | $self->tt( | ||||||||||||||||||||||||||||||||||||||||||
| 366 | Template->new( | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | INCLUDE_PATH => join(':', reverse @{ $self->config->templates }), | |||||||||||||||||||||||||||||||||||||||||
| 368 | RECURSION => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 369 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | =head2 generate_pages( $template, $filename, %data ) | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | sub nthpage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nthpage: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $page = shift; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | return $page if $n == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | --$n; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $page =~ s/\./_$n./; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return $page; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub generate_pages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_pages: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $template = shift; | |||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $spool = shift; | |||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $again; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $file = $spool; | |||||||||||||||||||||||||||||||||||||||||
| 396 | $self->tt->process( | ||||||||||||||||||||||||||||||||||||||||||
| 397 | $template, | ||||||||||||||||||||||||||||||||||||||||||
| 398 | { @_, | ||||||||||||||||||||||||||||||||||||||||||
| 399 | mariachi => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 400 | spool => $spool, | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # callbacktastic | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | nthpage => sub { $self->nthpage( shift, $spool ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | again => sub { $again }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | file => sub { $file }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | set_again => sub { $again = shift; return }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | set_file => sub { $file = shift; return }, }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | $self->config->output . "/$$.tmp" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | or die $self->tt->error; | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | mkpath dirname $self->config->output . "/$file"; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | move $self->config->output . "/$$.tmp", $self->config->output . "/$file" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | or die "$!"; | ||||||||||||||||||||||||||||||||||||||||||
| 413 | } while $again; | ||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | =head2 ->generate_lurker_index | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub generate_lurker { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_lurker: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return unless $self->config->lurker; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $l = Mariachi::Lurker->new; | |||||||||||||||||||||||||||||||||||||||||
| 427 | $self->generate_pages( | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 'lurker.tt2', 'lurker.html', | ||||||||||||||||||||||||||||||||||||||||||
| 429 | content => [ | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | map { [ $l->arrange( $_ ) ] } @{ $self->rootset } | |||||||||||||||||||||||||||||||||||||||||
| 431 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 432 | perpage => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 433 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =head2 ->generate_thread | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub generate_thread { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_thread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $self->generate_pages( | |||||||||||||||||||||||||||||||||||||||||
| 445 | 'index.tt2', 'index.html', | ||||||||||||||||||||||||||||||||||||||||||
| 446 | content => $self->rootset, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | perpage => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =head2 ->generate_date | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub generate_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_date: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my %touched_dates; | |||||||||||||||||||||||||||||||||||||||||
| 460 | my %dates; | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | # wander things to find dirty threads, and dates | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | for my $root (@{ $self->rootset }) { | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $sub; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | my $c = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if (my $mail = $c->message) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | # mark the thread dirty, if the message is new | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | unless (-e $self->config->output."/".$mail->filename && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $self->config->output . '/' . $mail->filename and not $self->config->refresh
MC/DC0%0/2
-e $self->config->output . '/' . $mail->filename and not $self->config->refresh
-e $self->config->output . '/' . $mail->filename
not $self->config->refresh
Truth table0%0/3
A and not(B)
A= -e $self->config->output . '/' . $mail->filenameB= not $self->config->refresh
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | !$self->config->refresh) { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | # dirty up the date indexes | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $touched_dates{ $mail->year } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $touched_dates{ $mail->month } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $touched_dates{ $mail->day } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | # add things to the date indexes | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | push @{ $dates{ $mail->year } }, $mail; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | push @{ $dates{ $mail->month } }, $mail; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | push @{ $dates{ $mail->day } }, $mail; | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $root->iterate_down($sub); | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | undef $sub; # since we closed over ourself, we'll have to be specific | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | for ( keys %touched_dates ) { | |||||||||||||||||||||||||||||||||||||||||
| 489 | my @mails = sort { | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $a->epoch_date <=> $b->epoch_date | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | } @{ $dates{$_} }; | |||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my @depth = split m!/!; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $self->generate_pages( 'date.tt2', "$_/index.html", | |||||||||||||||||||||||||||||||||||||||||
| 495 | archive_date => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 496 | content => \@mails, | ||||||||||||||||||||||||||||||||||||||||||
| 497 | base => "../" x @depth, | ||||||||||||||||||||||||||||||||||||||||||
| 498 | perpage => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 499 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | =head2 ->generate_bodies | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | render thread tree into the directory of C<output> | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | sub generate_bodies { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_bodies: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my %touched_threads; | |||||||||||||||||||||||||||||||||||||||||
| 513 | # wander things to find dirty threads | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | for my $root (@{ $self->rootset }) { | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $sub; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if (my $mail = eval { $_[0]->message }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | # mark the thread dirty, if the message is new | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | $touched_threads{ $root } = $root | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $self->config->output . '/' . $mail->filename and not $self->config->refresh
MC/DC0%0/2
-e $self->config->output . '/' . $mail->filename and not $self->config->refresh
-e $self->config->output . '/' . $mail->filename
not $self->config->refresh
Truth table0%0/3
A and not(B)
A= -e $self->config->output . '/' . $mail->filenameB= not $self->config->refresh
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | unless -e $self->config->output."/".$mail->filename | ||||||||||||||||||||||||||||||||||||||||||
| 521 | && !$self->config->refresh; | ||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $root->iterate_down($sub); | |||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | undef $sub; # since we closed over ourself, we'll have to be specific | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # figure out adjacent dirty threads | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my @threads = @{ $self->rootset }; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | for my $i (grep { $touched_threads{ $threads[$_] } } 0..$#threads) { | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | $touched_threads{ $threads[$i-1] } = $threads[$i-1] if $i > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $touched_threads{ $threads[$i+1] } = $threads[$i+1] if $i+1 < @threads; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | # and then render all the messages in the dirty threads | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $tt = $self->tt; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | for my $root (values %touched_threads) { | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my $mail = $_[0]->message or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | print STDERR "\rmessage $count" if ++$count % 100 == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | $tt->process('message.tt2', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | { base => '../../../', | ||||||||||||||||||||||||||||||||||||||||||
| 545 | mariachi => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 546 | thread => $root, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | message => $mail, | ||||||||||||||||||||||||||||||||||||||||||
| 548 | container => $_[0], | ||||||||||||||||||||||||||||||||||||||||||
| 549 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | $self->config->output . "/" . $mail->filename) | ||||||||||||||||||||||||||||||||||||||||||
| 551 | or die $tt->error; | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | $root->recurse_down( $sub ); | |||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | undef $sub; | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | =head2 ->perform | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | do all the right steps | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | sub perform { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perform: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $self->_bench("reticulating splines"); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $self->load; $self->_bench("load ".scalar @{ $self->messages }); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $self->dedupe; $self->_bench("dedupe"); | |||||||||||||||||||||||||||||||||||||||||
| 571 | #$self->sanitise; $self->_bench("sanitise"); | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->thread; $self->_bench("thread"); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $self->sanity; $self->_bench("sanity"); | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $self->order; $self->_bench("order"); | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $self->sanity; $self->_bench("sanity"); | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->copy_files; $self->_bench("copy files"); | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->init_tt; $self->_bench("tt init"); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $self->generate_lurker; $self->_bench("lurker output"); | |||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | $self->strand; $self->_bench("strand"); | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $self->split_deep; $self->_bench("deep threads split up"); | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->sanity; $self->_bench("sanity"); | |||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $self->order; $self->_bench("order"); | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $self->generate_thread; $self->_bench("regular thread indexes"); | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->generate_date; $self->_bench("date indexes"); | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $self->generate_bodies; $self->_bench("messages"); | |||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | package Mariachi::Folder; | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | ▶ | use Mariachi::Message; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | ▶ | use Email::Folder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | ▶ | use base 'Email::Folder'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | sub bless_message { Mariachi::Message->new($_[1]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bless_message: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | package Mariachi::Lurker; | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | ▶ | use Mail::Thread::Chronological; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | ▶ | use base 'Mail::Thread::Chronological'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | sub extract_time { $_[1]->message->epoch_date } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_time: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | __END__ | ||||||||||||||||||||||||||||||||||||||||||