blib/lib/Bootylicious/ArticleByQueryIterator.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 8 / 8 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 8 / 8 Podpod 50.0% 1 / 2 totaltotal 96.0% 72 / 75 CC 7 SCAR 13.9
CC
7
Cov
98%
__ANON__
7.0
build
1.0
BEGIN
1.0
CRAP 4.0
« blib/lib/Bootylicious/DocumentContentLoader.pm ↑ Summary blib/lib/Bootylicious/Timestamp.pm »
1 package Bootylicious::ArticleByQueryIterator;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base 'Bootylicious::Decorator';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 __PACKAGE__->attr('query');
9 2 __PACKAGE__->attr('before_context' => 10);
10 2 __PACKAGE__->attr('after_context' => 10);
11 2 __PACKAGE__->attr('replace_string_before' => '<font color="red">');
12 2 __PACKAGE__->attr('replace_string_after' => '</font>');
13  
14 2 ▶use Mojo::ByteStream 'b';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Bootylicious::IteratorSearchable;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub new {
18 3 ▶ my $self = shift->SUPER::new(@_);
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19  
20 3 return $self->build;
21 }
22  
23 sub build {
24 3 ▶ my $self = shift;
Subroutine build: called CC=1 SCAR=0.0
Pod undocumented
25  
26 3 my $before_context = $self->before_context;
27 3 my $after_context = $self->after_context;
28  
29 3 my $replace_string_before = $self->replace_string_before;
30 3 my $replace_string_after = $self->replace_string_after;
31  
32 3 my $q = quotemeta $self->query;
33  
34 return Bootylicious::IteratorSearchable->new($self->object)->find_all(
35 sub {
36 6 ▶ my ($iterator, $article) = @_;
Subroutine __ANON__: called CC=7 SCAR=19.5
37  
38 6 my $found = 0;
39  
40 6 my $title = $article->title;
41 6 ▶ if ( $title
Branch: 1 branch
BranchTrueFalseTotal
if ($title and $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig) 2 4 6
Condition66%2/3
$title and $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig
!ll&&!rl&&r
042
MC/DC50%1/2
$title and $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig
$title $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig
Truth table66%2/3
A and B
A= $titleB= $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig
ABresult
0X0
100
111
42 && $title
43 =~ s/($q)/$replace_string_before$1$replace_string_after/isg)
44 {
45 2 $found = 1;
46 2 $article->title($title);
47 }
48  
49 6 my $parts = [];
50 6 my $content = $article->content;
51 6 ▶ while ($content
Branch: 1 branch
BranchTrueFalseTotal
if ($content and $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is) 1 6 7
Condition100%3/3
$content and $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is
!ll&&!rl&&r
331
MC/DC100%2/2
$content and $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is
$content $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is
Truth table100%3/3
A and B
A= $contentB= $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is
ABresult
0X0
100
111
52 && $content
53 =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is)
54 {
55 1 my $part = $1;
56 1 $part = b($part)->xml_escape->to_string;
57 1 $part
58 =~ s/($q)/$replace_string_before$1$replace_string_after/isg;
59 1 push @$parts, $part;
60  
61 1 $found = 1;
62 }
63  
64 6 ▶ return unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 4 2 6
65  
66 2 ▶ $article->content($parts) if @$parts;
Branch: 1 branch
BranchTrueFalseTotal
if @$parts 1 1 2
67  
68 2 return $article;
69 }
70 3 );
71 }
72  
73 2 1;
« blib/lib/Bootylicious/DocumentContentLoader.pm ↑ Summary blib/lib/Bootylicious/Timestamp.pm »