| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Mail::Summary::Tools::FlatFile; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use File::Slurp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use YAML::Syck (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Mail::Summary::Tools::ArchiveLink::Hardcoded; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | has summary => ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | isa => "Mail::Summary::Tools::Summary", | ||||||||||||||||||||||||||||||||||||||||||
| 13 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 14 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | has uri_type => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||
| 19 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 20 | default => "thread_uri", | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | has skip_summarized => ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 25 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 26 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | has include_hidden => ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 31 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 32 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | has list_posters => ( | |||||||||||||||||||||||||||||||||||||||||
| 36 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 37 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 38 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | has add_links => ( | |||||||||||||||||||||||||||||||||||||||||
| 42 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 43 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 44 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | has list_dates => ( | |||||||||||||||||||||||||||||||||||||||||
| 48 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 49 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 50 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | has list_misc => ( | |||||||||||||||||||||||||||||||||||||||||
| 54 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 55 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 56 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | has extra_fields => ( | ||||||||||||||||||||||||||||||||||||||||||
| 60 | isa => "ArrayRef", | ||||||||||||||||||||||||||||||||||||||||||
| 61 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 62 | auto_deref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | has patterns => ( | ||||||||||||||||||||||||||||||||||||||||||
| 67 | isa => "ArrayRef", | ||||||||||||||||||||||||||||||||||||||||||
| 68 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 69 | auto_deref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub save { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my $text = $self->emit_summary( $self->summary ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | if ( $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | File::Slurp::write_file( $file, $text ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | $text; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | $text = File::Slurp::read_file($text) unless $text =~ qr/---/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | foreach my $thread ( grep { length($_) } split /\s*\n---\n\s*/s, $text ) { | |||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | $self->load_thread( $thread ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | sub load_thread { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_thread: called CC=15 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | my ( $head, $junk, $summary_text ) = split /\n\n\s*/, $text, 3; | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | # filter out comments | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | ▶ | ($_||='') =~ s/^#.*$//mg for $head, $junk, $summary_text; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ ||= ""
MC/DC0%0/1
$_ ||= ""
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | return unless $head =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | local $YAML::Syck::ImplicitTyping = 1; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | my $meta_data = eval { YAML::Syck::Load($head) }; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | die "Error parsing YAML header: $@\n$head\n" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my ( $id, $list ) = delete @{ $meta_data }{qw/message_id list/}; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | die "No message id in header:\n$head\n" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | # FIXME - autovivify?. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | my $thread = $self->summary->get_thread_by_id($id) | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->summary->get_thread_by_id($id) || die("There is no thread with the message ID <$id> in the current summary.\n$text")
MC/DC0%0/1
$self->summary->get_thread_by_id($id) || die("There is no thread with the message ID <$id> in the current summary.\n$text")
$self->summary->get_thread_by_id($id)
Truth table50%1/2
A
A= $self->summary->get_thread_by_id($id)
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | || die "There is no thread with the message ID <$id> in the current summary.\n$text"; | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | my ( $thread_uri, $message_uri ) = delete @{ $meta_data }{qw/thread_uri message_uri/}; | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | if ( defined($thread_uri) || defined($message_uri) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $thread_uri or defined $message_uri
MC/DC50%1/2
defined $thread_uri or defined $message_uri
defined $thread_uri
defined $message_uri
Truth table66%2/3
A or B
A= defined $thread_uriB= defined $message_uri
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $meta_data->{archive_link} = Mail::Summary::Tools::ArchiveLink::Hardcoded->new( | |||||||||||||||||||||||||||||||||||||||||
| 122 | thread_uri => $thread_uri, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | message_uri => $message_uri, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my $out_of_date = delete $meta_data->{out_of_date}; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | if ( $out_of_date ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $thread->extra->{out_of_date} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | delete $thread->extra->{out_of_date}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | $meta_data->{summary} = $summary_text; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | foreach my $field ( keys %$meta_data ) { | |||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | ▶ | if ( $thread->can($field) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | $thread->$field( $meta_data->{$field} ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | $thread->extra->{$field} = $meta_data->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | foreach my $field ( $self->extra_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | ▶ | next if exists $meta_data->{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | if ( $thread->can($field) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $thread->$field( undef ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | delete $thread->extra->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | $self->set_list( $list, $thread ); | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | sub set_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_list: called CC=2 SCAR=10.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | my ( $self, $list, $thread ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $list = $self->get_list_by_name( $list ) unless ref $list; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | sub emit_summary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_summary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my ( $self, $summary ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | return join("", map { "$_\n\n---\n" } <<'PRE', map { $self->emit_list($_) } $summary->lists ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | # Threads are separated with the sequence "\n---\n" | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # Every thread is composed of three chunks, separated by "\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # The first chunk is YAML meta data. You may edit it. The second | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # chunk is comments, ignored by the parser. The third contains the | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # summary which should be written in the Markdown language. | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # the -s option skips threads that have already been summarized | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # the -H option forces inclusion of hidden threads | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # the -e option dumps additional fields in the YAML (e.g. -e my_header -e my_other_header ) | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # the -P option skips threads not matching the specified patterns (e.g. -P todo -P EvilUser ) | ||||||||||||||||||||||||||||||||||||||||||
| 179 | PRE | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | ▶ | sub emit_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | my ( $self, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | map { $self->emit_thread($_, $list) } $list->threads; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | ▶ | sub emit_thread { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_thread: called CC=9 SCAR=26.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 6 | my ( $self, $thread, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | ▶ | return if $self->skip_summarized and $thread->summary and !$thread->extra->{out_of_date}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->skip_summarized and $thread->summary and not $thread->extra->{"out_of_date"}
$self->skip_summarized and $thread->summary
MC/DC66%2/3
$self->skip_summarized and $thread->summary and not $thread->extra->{"out_of_date"}
$self->skip_summarized
$thread->summary
not $thread->extra->{"out_of_date"}
Truth table75%3/4
A and B and not(C)
A= $self->skip_summarizedB= $thread->summaryC= not $thread->extra->{"out_of_date"}
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | ▶ | return if $thread->hidden and !$self->include_hidden; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$thread->hidden and not $self->include_hidden
MC/DC0%0/2
$thread->hidden and not $self->include_hidden
$thread->hidden
not $self->include_hidden
Truth table33%1/3
A and not(B)
A= $thread->hiddenB= not $self->include_hidden
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | my $formatted = join("\n\n", | |||||||||||||||||||||||||||||||||||||||||
| 194 | $self->emit_head($thread, $list), | ||||||||||||||||||||||||||||||||||||||||||
| 195 | $self->emit_junk($thread, $list), | ||||||||||||||||||||||||||||||||||||||||||
| 196 | $self->emit_body($thread, $list), | ||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | ▶ | if ( my @patterns = $self->patterns ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | foreach my $pattern ( @patterns ) { | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return $formatted if $formatted =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 5 | return $formatted; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | ▶ | sub emit_head { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_head: called CC=6 SCAR=22.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 5 | my ( $self, $thread, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | local $YAML::Syck::Headless = 1; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | # FIXME YAML::Syck doesn't work well with Headless... is it OK now? | ||||||||||||||||||||||||||||||||||||||||||
| 216 | #local $YAML::UseHeader = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | #require YAML; | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | my %extra_fields; | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | foreach my $field ( $self->extra_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( defined( my $value = ($thread->can($field) ? $thread->$field : $thread->extra->{$field}) ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $extra_fields{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | my $yaml = YAML::Syck::Dump({ | ||||||||||||||||||||||||||||||||||||||||||
| 228 | list => $list->name, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | message_id => $thread->message_id, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | subject => $thread->subject, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ( $thread->hidden ? ( hidden => $thread->hidden ) : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | ▶ | ( $thread->extra->{out_of_date} ? ( out_of_date => 1 ) : () ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | %extra_fields, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 5 | chomp($yaml); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | return $yaml; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 5 | ▶ | sub emit_body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_body: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | my ( $self, $thread, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 5 | ▶ | return $thread->summary || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$thread->summary || ''
MC/DC100%1/1
$thread->summary || ''
$thread->summary
Truth table100%2/2
A
A= $thread->summary
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 5 | ▶ | sub emit_junk { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_junk: called CC=10 SCAR=36.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | my ( $self, $thread, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 5 | my $uri_type = $self->uri_type; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 5 | my @lines = ( | |||||||||||||||||||||||||||||||||||||||||
| 251 | "# these lines are ignored", | ||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 5 | ▶ | if ( $self->add_links ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $uri = $thread->archive_link->$uri_type; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | push @lines, "<$uri>"; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | ▶ | if ( $self->list_dates ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | push @lines, sprintf "Start date: %s", scalar(localtime($thread->extra->{date_from})) if $thread->extra->{date_from}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | push @lines, sprintf "End date: %s", scalar(localtime($thread->extra->{date_to})) if $thread->extra->{date_to}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 5 | ▶ | if ( $self->list_misc ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ( my $ticket = $thread->extra->{rt_ticket} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | #push @lines, sprintf 'RT-Ticket: %s', $ticket; | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | push @lines, sprintf '<rt://%s/%s>', ( $ticket =~ /^(\w+?) \#(\d+)$/ ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | ▶ | if ( $self->list_posters and my $extra = $thread->extra ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->list_posters and my $extra = $thread->extra
MC/DC0%0/2
$self->list_posters and my $extra = $thread->extra
$self->list_posters
my $extra = $thread->extra
Truth table33%1/3
A and B
A= $self->list_postersB= my $extra = $thread->extra
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ( my $posters = $extra->{posters} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | push @lines, grep { defined } map { $_->{name} } @$posters; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | join("\n", @lines ); | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | __END__ | ||||||||||||||||||||||||||||||||||||||||||