| 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
Condition66%2/3
$title and $title =~ s/($q)/$replace_string_before$1$replace_string_after/sig
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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$content and $content =~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 2 | ▶ | $article->content($parts) if @$parts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | return $article; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 3 | ); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | 1; | |||||||||||||||||||||||||||