| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bootylicious::ArticleByQueryIterator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
435
|
use strict; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
113
|
|
|
4
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
101
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
21
|
use base 'Bootylicious::Decorator'; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
671
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->attr('query'); |
|
9
|
|
|
|
|
|
|
__PACKAGE__->attr('before_context' => 10); |
|
10
|
|
|
|
|
|
|
__PACKAGE__->attr('after_context' => 10); |
|
11
|
|
|
|
|
|
|
__PACKAGE__->attr('replace_string_before' => ''); |
|
12
|
|
|
|
|
|
|
__PACKAGE__->attr('replace_string_after' => ''); |
|
13
|
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
29
|
use Mojo::ByteStream 'b'; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
194
|
|
|
15
|
5
|
|
|
5
|
|
305
|
use Bootylicious::IteratorSearchable; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
|
18
|
3
|
|
|
3
|
1
|
14
|
my $self = shift->SUPER::new(@_); |
|
19
|
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
8
|
return $self->build; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build { |
|
24
|
3
|
|
|
3
|
0
|
4
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
8
|
my $before_context = $self->before_context; |
|
27
|
3
|
|
|
|
|
19
|
my $after_context = $self->after_context; |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
13
|
my $replace_string_before = $self->replace_string_before; |
|
30
|
3
|
|
|
|
|
16
|
my $replace_string_after = $self->replace_string_after; |
|
31
|
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
16
|
my $q = quotemeta $self->query; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return Bootylicious::IteratorSearchable->new($self->object)->find_all( |
|
35
|
|
|
|
|
|
|
sub { |
|
36
|
6
|
|
|
6
|
|
28
|
my ($iterator, $article) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
10
|
my $found = 0; |
|
39
|
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
19
|
my $title = $article->title; |
|
41
|
6
|
100
|
66
|
|
|
79
|
if ( $title |
|
42
|
|
|
|
|
|
|
&& $title |
|
43
|
|
|
|
|
|
|
=~ s/($q)/$replace_string_before$1$replace_string_after/isg) |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
2
|
|
|
|
|
5
|
$found = 1; |
|
46
|
2
|
|
|
|
|
5
|
$article->title($title); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
13
|
my $parts = []; |
|
50
|
6
|
|
|
|
|
20
|
my $content = $article->content; |
|
51
|
6
|
|
100
|
|
|
78
|
while ($content |
|
52
|
|
|
|
|
|
|
&& $content |
|
53
|
|
|
|
|
|
|
=~ s/((?:.{$before_context})?$q(?:.{$after_context})?)//is) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
1
|
|
|
|
|
4
|
my $part = $1; |
|
56
|
1
|
|
|
|
|
5
|
$part = b($part)->xml_escape->to_string; |
|
57
|
1
|
|
|
|
|
41
|
$part |
|
58
|
|
|
|
|
|
|
=~ s/($q)/$replace_string_before$1$replace_string_after/isg; |
|
59
|
1
|
|
|
|
|
4
|
push @$parts, $part; |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
7
|
$found = 1; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
43
|
return unless $found; |
|
65
|
|
|
|
|
|
|
|
|
66
|
2
|
100
|
|
|
|
8
|
$article->content($parts) if @$parts; |
|
67
|
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
10
|
return $article; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
3
|
|
|
|
|
15
|
); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |