blib/lib/Bootylicious/Plugin/BootyHelpers.pm

filter: Statementstmt 24.7% 67 / 271 Branchbran 6.0% 3 / 50 Conditioncond 5.8% 2 / 34 MC/DCmcdc 4.5% 1 / 22 Subroutinesub 10.9% 7 / 64 Podpod 100% 1 / 1 totaltotal 18.3% 81 / 442 CC 42 SCAR 22.4
CC
42
Cov
20%
__ANON__
30.0
__ANON__
30.0
__ANON__
20.0
CRAP 9.4
« blib/lib/Bootylicious/Plugin/Search.pm ↑ Summary blib/lib/Bootylicious/DocumentStatLoader.pm »
1 package Bootylicious::Plugin::BootyHelpers;
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 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Mojo::ByteStream 'b';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub register {
11 2 ▶ my ($self, $app) = @_;
Subroutine register: called CC=3 SCAR=20.8
Pod documented
12  
13 2 my $config = $app->config;
14  
15 $app->helper(
16 render_smart => sub {
17 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
18  
19 0 $app->plugins->emit_hook(before_render => $self);
20  
21 0 ▶ $self->render(@_) unless $self->res->code;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->res->code 0 0 0
22 }
23 2 );
24  
25 $app->helper(
26 render_article_or_preview => sub {
27 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=5 SCAR=34.0
28 0 my $article = shift;
29  
30 0 my $parser = $self->parsers->{$article->format};
31 0 ▶ $parser ||= sub { $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$parser ||= sub { $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$parser ||= sub { $_[0]; }
$parser sub { $_[0]; }
Truth table0%0/3
A ||= B
A= $parserB= sub { $_[0]; }
ABresult
1X1
011
000
32  
33 0 my $cuttag = quotemeta $self->config->{cuttag};
34  
35 0 my $content = $article->content;
36  
37 0 my ($preview, $preview_link);
38 0 ▶ if ($content =~ s{^(.*?)\n$cuttag(?: (.*?))?(?:\n|\r|\n\r)}{}s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ s/^(.*?)\n$cuttag(?: (.*?))?(?:\n|\r|\n\r)//s) 0 0 0
39 0 $preview = $1;
40 0 ▶ $preview_link = $2 || $self->config->{cuttext};
Condition0%0/3
$2 || $self->config->{'cuttext'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$2 || $self->config->{'cuttext'}
$2 $self->config->{'cuttext'}
Truth table0%0/3
A || B
A= $2B= $self->config->{'cuttext'}
ABresult
1X1
011
000
41 0 $content = $3;
42 }
43  
44 return Mojo::ByteStream->new(
45 $parser->($preview) . $self->tag(
46 div => class => 'more' => sub {
47 0 ▶ '→ '
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 . $self->link_to_full_content($article,
49 $preview_link);
50 }
51 )
52 0 ▶ ) if $preview;
Branch: 1 branch
BranchTrueFalseTotal
if $preview 0 0 0
53  
54 0 return Mojo::ByteStream->new($parser->($content));
55 }
56 2 );
57  
58 $app->helper(
59 render_article => sub {
60 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
61 0 my $article = shift;
62  
63 0 my $parser = $self->parsers->{$article->format};
64 0 ▶ $parser ||= sub { $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$parser ||= sub { $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$parser ||= sub { $_[0]; }
$parser sub { $_[0]; }
Truth table0%0/3
A ||= B
A= $parserB= sub { $_[0]; }
ABresult
1X1
011
000
65  
66 0 my $cuttag = quotemeta $self->config->{cuttag};
67  
68 0 my $head = $article->content;
69 0 my $tail = '';
70 0 ▶ if ($head =~ s{(.*?)\n$cuttag.*?\n(.*)}{$1}s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ s/(.*?)\n$cuttag.*?\n(.*)/$1/s) 0 0 0
71 0 $tail = $2;
72 }
73  
74 0 my $cuttag_anchor = '<a name="cut"></a>';
75  
76 0 my $string;
77 0 $string = $parser->($head);
78 0 ▶ $string .= $cuttag_anchor . $parser->($tail) if $tail;
Branch: 1 branch
BranchTrueFalseTotal
if $tail 0 0 0
79  
80 0 return Mojo::ByteStream->new($string);
81 }
82 2 );
83  
84 $app->helper(
85 render_comment => sub {
86 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 0 my $comment = shift;
88  
89 0 my $content = $comment->content;
90  
91 0 $content = Mojo::ByteStream->new($content)->xml_escape;
92  
93 0 _parse_tag(\$content, 'quote' => 'blockquote');
94 0 _parse_tag(\$content, 'code');
95  
96 0 $content =~ s{\n}{<br />}xmsg;
97  
98 0 return Mojo::ByteStream->new($content);
99 }
100 2 );
101  
102 $app->helper(
103 article_author => sub {
104 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
105 0 my $article = shift;
106  
107 0 ▶ return $article->author || $config->{author};
Condition0%0/3
$article->author || $config->{'author'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$article->author || $config->{'author'}
$article->author $config->{'author'}
Truth table0%0/3
A || B
A= $article->authorB= $config->{'author'}
ABresult
1X1
011
000
108 }
109 2 );
110  
111 $app->helper(
112 comment_author => sub {
113 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
114 0 my $comment = shift;
115  
116 0 ▶ return $comment->author unless $comment->url;
Branch: 1 branch
BranchTrueFalseTotal
unless $comment->url 0 0 0
117  
118 0 ▶ return $self->link_to($comment->url => sub { $comment->author });
Subroutine __ANON__: not called CC=1 SCAR=6.9
119 }
120 2 );
121  
122 $app->helper(
123 render_page => sub {
124 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
125 0 my $page = shift;
126  
127 0 my $parser = $self->parsers->{$page->format};
128 0 ▶ $parser ||= sub { $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$parser ||= sub { $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$parser ||= sub { $_[0]; }
$parser sub { $_[0]; }
Truth table0%0/3
A ||= B
A= $parserB= sub { $_[0]; }
ABresult
1X1
011
000
129  
130 0 my $string = $parser->($page->content);
131 0 return Mojo::ByteStream->new($string);
132 }
133 2 );
134  
135 $app->helper(
136 date => sub {
137 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
138 0 my $date = shift;
139 0 my $fmt = shift;
140  
141 0 ▶ return '' unless $date;
Branch: 1 branch
BranchTrueFalseTotal
unless $date 0 0 0
142  
143 0 ▶ $fmt ||= $config->{'datefmt'};
Condition0%0/3
$fmt ||= $config->{"datefmt"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$fmt ||= $config->{"datefmt"}
$fmt $config->{"datefmt"}
Truth table0%0/3
A ||= B
A= $fmtB= $config->{"datefmt"}
ABresult
1X1
011
000
144  
145 0 return b($date->strftime($fmt))->decode('utf-8');
146 }
147 2 );
148 0 ▶ $app->helper(date_rss => sub { Mojo::Date->new($_[1]->epoch)->to_string }
Subroutine __ANON__: not called CC=1 SCAR=6.9
149 2 );
150 $app->helper(
151 href_to_article => sub {
152 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
153 0 my $article = shift;
154  
155 0 return $self->url_for(
156 article => (
157 year => $article->created->year,
158 month => $article->created->month,
159 alias => $article->name,
160 format => 'html'
161 )
162 );
163 }
164 2 );
165 $app->helper(
166 link_to_article => sub {
167 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=5 SCAR=34.0
168 0 my $article = shift;
169  
170 0 my $href = $self->href_to_article($article);
171  
172 0 ▶ my $cb = ref $_[-1] eq 'CODE' ? pop : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'CODE' ? : 0 0 0
173  
174 0 ▶ if ($article->link) {
Branch: 1 branch
BranchTrueFalseTotal
if ($article->link) 0 0 0
175 0 my $string = '';
176  
177 $string
178 0 ▶ .= $self->link_to($href => $cb || sub { $article->title });
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$cb || sub { $article->title; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$cb || sub { $article->title; }
$cb sub { $article->title; }
Truth table0%0/3
A || B
A= $cbB= sub { $article->title; }
ABresult
1X1
011
000
179 0 $string .= '&nbsp;';
180 0 ▶ $string .= $self->link_to($article->link => sub {"&raquo;"});
Subroutine __ANON__: not called CC=1 SCAR=6.9
181  
182 0 return Mojo::ByteStream->new($string);
183 }
184  
185 0 ▶ return $self->link_to($href => $cb || sub { $article->title });
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$cb || sub { $article->title; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$cb || sub { $article->title; }
$cb sub { $article->title; }
Truth table0%0/3
A || B
A= $cbB= sub { $article->title; }
ABresult
1X1
011
000
186 }
187 2 );
188 $app->helper(
189 link_to_full_content => sub {
190 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 0 my ($article, $preview_link) = @_;
192  
193 0 my $href = $self->href_to_article($article);
194 0 $href->fragment('cut');
195  
196 0 ▶ return $self->link_to($href => sub {$preview_link});
Subroutine __ANON__: not called CC=1 SCAR=6.9
197 }
198 2 );
199 $app->helper(
200 link_to_tag => sub {
201 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
202 0 my $tag = shift;
203  
204 0 ▶ my $name = ref $tag ? $tag->name : $tag;
Branch: 1 branch
BranchTrueFalseTotal
ref $tag ? : 0 0 0
205  
206 0 ▶ my $cb = ref $_[-1] eq 'CODE' ? $_[-1] : sub {$name};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'CODE' ? : 0 0 0
207 0 ▶ my $args = ref $_[0] eq 'HASH' ? $_[0] : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
208  
209 0 return $self->link_to(
210 tag => {tag => $name, format => 'html', %$args} => $cb);
211 }
212 2 );
213 $app->helper(
214 tags_links => sub {
215 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
216 0 my $article = shift;
217  
218 0 my @links = map { $self->link_to_tag($_) } @{$article->tags};
219  
220 0 my $string = '';
221 0 $string .= join ', ' => @links;
222  
223 0 return Mojo::ByteStream->new($string);
224 }
225 2 );
226 $app->helper(
227 link_to_page => sub {
228 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
229 0 my $name = shift;
230  
231 0 ▶ my %args = ref $_[0] eq 'HASH' ? %{shift @_} : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
232  
233 0 my $timestamp = shift;
234  
235 0 ▶ my $query = delete $args{query} || {};
Condition0%0/2
delete $args{'query'} || {}
l!l
00
MC/DC0%0/1
delete $args{'query'} || {}
delete $args{'query'}
Truth table0%0/2
A
A= delete $args{'query'}
Aresult
11
00
236  
237 0 ▶ if ($timestamp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timestamp) { } 0 0 0
238 0 return $self->link_to(
239 $self->url_for($name, %args, format => 'html')
240 ->query(timestamp => $timestamp, %$query) => @_);
241 }
242 else {
243 0 return $self->tag('span' => @_);
244 }
245 }
246 2 );
247 $app->helper(
248 link_to_author => sub {
249 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
250 0 my $author = shift;
251  
252 0 ▶ return $author || $self->config('author');
Condition0%0/3
$author || $self->config('author')
l!l&&r!l&&!r
000
MC/DC0%0/2
$author || $self->config('author')
$author $self->config('author')
Truth table0%0/3
A || B
A= $authorB= $self->config('author')
ABresult
1X1
011
000
253 }
254 2 );
255  
256 $app->helper(
257 permalink_to => sub {
258 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
259 0 my $link = shift;
260  
261 0 ▶ return $self->link_to($link => sub {'&#x2605;'});
Subroutine __ANON__: not called CC=1 SCAR=6.9
262 }
263 2 );
264  
265 $app->helper(
266 strings => sub {
267 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
268  
269 0 my $string = $config->{'strings'}->{$_[0]};
270  
271 0 ▶ for (my $i = 0; $i < @_; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 0 0 0
272 0 $string =~ s/\[_$i\]/$_[$i]/;
273 }
274  
275 0 return $string;
276 }
277 2 );
278  
279 2 foreach my $name (qw/articles pages drafts/) {
280 6 ▶ my $option = $config->{"${name}_directory"} || '';
Condition100%2/2
$$config{"${name}_directory"} || ''
l!l
15
MC/DC100%1/1
$$config{"${name}_directory"} || ''
$$config{"${name}_directory"}
Truth table100%2/2
A
A= $$config{"${name}_directory"}
Aresult
11
00
281 $app->helper(
282 "${name}_root" => sub {
283 1 ▶ ($option =~ m/^\//) ? $option : $app->home->rel_dir($option);
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$option =~ m[^/] ? : 0 1 1
284 }
285 6 );
286 }
287  
288 2 ▶ $app->helper(page_limit => sub { $config->{pagelimit} });
Subroutine __ANON__: not called CC=1 SCAR=1.2
289  
290 $app->helper(
291 meta => sub {
292 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
293  
294 0 my $string = '';
295  
296 0 ▶ if (my $description = $self->stash('description')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $description = $self->stash("description")) 0 0 0
297 0 $string .= $self->tag(
298 'meta',
299 name => 'description',
300 content => $description
301 );
302 }
303  
304 0 my $meta_from_config = $self->config('meta');
305 0 ▶ $meta_from_config = [$meta_from_config]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $meta_from_config eq "ARRAY" 0 0 0
306 unless ref $meta_from_config eq 'ARRAY';
307  
308 0 foreach my $meta (@$meta_from_config) {
309 0 $string .= $self->tag('meta' => %$meta);
310 }
311  
312 0 return Mojo::ByteStream->new($string);
313 }
314 2 );
315  
316 $app->helper(
317 css => sub {
318 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
319  
320 0 my $string = '';
321  
322 0 my $css_from_config = $self->config('css');
323 0 ▶ $css_from_config = [$css_from_config]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $css_from_config eq "ARRAY" 0 0 0
324 unless ref $css_from_config eq 'ARRAY';
325  
326 0 foreach my $css (@$css_from_config) {
327 0 $string .= $self->stylesheet($css);
328 }
329  
330 0 return Mojo::ByteStream->new($string);
331 }
332 2 );
333  
334 $app->helper(
335 js => sub {
336 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
337  
338 0 my $string = '';
339  
340 0 my $js_from_config = $self->config('js');
341 0 ▶ $js_from_config = [$js_from_config]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $js_from_config eq "ARRAY" 0 0 0
342 unless ref $js_from_config eq 'ARRAY';
343  
344 0 foreach my $js (@$js_from_config) {
345 0 $string .= $self->javascript($js);
346 }
347  
348 0 return Mojo::ByteStream->new($string);
349 }
350 2 );
351  
352 $app->helper(
353 href_to_rss => sub {
354 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
355  
356 0 return $self->url_for('index', format => 'rss')->to_abs;
357 }
358 2 );
359  
360 $app->helper(
361 link_to_rss => sub {
362 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
363  
364 0 return $self->link_to($self->href_to_rss => @_);
365 }
366 2 );
367  
368 $app->helper(
369 href_to_comments_rss => sub {
370 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
371  
372 0 return $self->url_for('comments', format => 'rss')->to_abs;
373 }
374 2 );
375  
376 $app->helper(
377 link_to_comments_rss => sub {
378 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
379  
380 0 return $self->link_to($self->href_to_comments_rss => @_);
381 }
382 2 );
383  
384 $app->helper(
385 menu => sub {
386 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
387  
388 0 my @links;
389  
390 0 my $menu = $self->config('menu');
391  
392 0 ▶ for (my $i = 0; $i < @$menu; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$menu) 0 0 0
393 0 my $title = $menu->[$i];
394 0 my $href = $menu->[$i + 1];
395  
396 0 ▶ push @links, $self->link_to($href => sub {$title});
Subroutine __ANON__: not called CC=1 SCAR=6.9
397 }
398  
399 0 return Mojo::ByteStream->new(join ' ' => @links);
400 }
401 2 );
402  
403 $app->helper(
404 link_to_home => sub {
405 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
406  
407 return $self->link_to(
408 'root' => {format => undef},
409 title => $self->config('title'),
410 0 ▶ rel => 'home' => sub { $self->config('title') }
Subroutine __ANON__: not called CC=1 SCAR=6.9
411 0 );
412 }
413 2 );
414  
415 $app->helper(
416 link_to_bootylicious => sub {
417 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
418  
419 return $self->link_to('https://github.com/vti/bootylicious' => title =>
420 0 ▶ 'Powered by Bootylicious!' => sub {'Bootylicious'});
Subroutine __ANON__: not called CC=1 SCAR=6.9
421 }
422 2 );
423  
424 $app->helper(
425 powered_by => sub {
426 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
427  
428 return $self->link_to('https://github.com/vti/bootylicious' =>
429 0 ▶ sub {'Powered by Bootylicious'});
Subroutine __ANON__: not called CC=1 SCAR=6.9
430  
431 }
432 2 );
433  
434 $app->helper(
435 generator => sub {
436 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
437  
438 0 return Mojo::ByteStream->new('Bootylicious ' . $Bootylicious::VERSION);
439 }
440 2 );
441  
442 $app->helper(
443 link_to_archive => sub {
444 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
445 0 my ($year, $month) = @_;
446  
447 0 my @months = (
448 qw/January February March April May July June August September October November December/
449 );
450 0 my $title = $months[$month - 1] . ' ' . $year;
451 return $self->link_to(
452 'articles',
453 { year => $year,
454 month => $month
455 0 ▶ } => sub {$title}
Subroutine __ANON__: not called CC=1 SCAR=6.9
456 0 );
457 }
458 2 );
459  
460 $app->helper(
461 gravatar => sub {
462 2 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
463 2 my $email = shift;
464  
465 2 my %attrs = (
466 class => 'gravatar',
467 width => 40,
468 height => 40
469 );
470  
471 2 ▶ return $self->tag(
Branch: 1 branch
BranchTrueFalseTotal
unless $email 1 1 2
472 'img',
473 src =>
474 'http://www.gravatar.com/avatar/00000000000000000000000000000000?s=40',
475 %attrs
476 ) unless $email;
477  
478 1 $email = lc $email;
479 1 $email =~ s/^\s+//;
480 1 $email =~ s/\s+$//;
481  
482 1 my $hash = Mojo::ByteStream->new($email)->md5_sum;
483  
484 1 my $url = "http://www.gravatar.com/avatar/$hash?s=40";
485  
486 1 return $self->tag(
487 'img',
488 src => $url,
489 %attrs,
490 @_
491 );
492 }
493 2 );
494  
495 $app->helper(
496 href_to_comments => sub {
497 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
498 0 my $article = shift;
499  
500 0 return $self->href_to_article($article)->fragment('comments');
501 }
502 2 );
503  
504 $app->helper(
505 href_to_comment => sub {
506 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
507 0 my $comment = shift;
508  
509 0 return $self->href_to_article($comment->article)
510 ->fragment('comment-' . $comment->number);
511 }
512 2 );
513  
514 $app->helper(
515 link_to_comment => sub {
516 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
517 0 my $comment = shift;
518  
519 return $self->link_to($self->href_to_comment($comment) =>
520 0 ▶ sub { $comment->article->title });
Subroutine __ANON__: not called CC=1 SCAR=6.9
521 }
522 2 );
523  
524 $app->helper(
525 link_to_comments => sub {
526 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
527 0 my $article = shift;
528  
529 0 my $href = $self->href_to_article($article);
530  
531 return $self->link_to(
532 0 ▶ $href->fragment('comment-form') => sub {'No comments'})
Subroutine __ANON__: not called CC=1 SCAR=6.9
533 0 ▶ unless $article->comments->size;
Branch: 1 branch
BranchTrueFalseTotal
unless $article->comments->size 0 0 0
534  
535 return $self->link_to($href->fragment('comments') =>
536 0 ▶ sub { 'Comments (' . $article->comments->size . ') '; });
Subroutine __ANON__: not called CC=1 SCAR=6.9
537 }
538 2 );
539  
540 $app->helper(
541 comments_enabled => sub {
542 0 ▶ shift->config('comments_enabled') ? 1 : 0;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
(shift())->config('comments_enabled') ? : 0 0 0
543 }
544 2 );
545 }
546  
547 sub _parse_tag {
548 0 ▶ my $content_ref = shift;
Subroutine _parse_tag: not called CC=3 SCAR=24.8
549 0 my ($tag, $html) = @_;
550  
551 0 ▶ $html ||= $tag;
Condition0%0/3
$html ||= $tag
l!l&&r!l&&!r
000
MC/DC0%0/2
$html ||= $tag
$html $tag
Truth table0%0/3
A ||= B
A= $htmlB= $tag
ABresult
1X1
011
000
552  
553 0 my $tags = $$content_ref =~ s{\s*\[$tag\]\s*}{<$html>}xmsg;
554 0 $tags -= $$content_ref =~ s{\s*\[/$tag\]\s*}{</$html>}xmsg;
555 0 ▶ $$content_ref .= "</$html>" while $tags--;
Branch: 1 branch
BranchTrueFalseTotal
$tags-- and do { $$content_ref .= "</$html>" } 0 0 0
556 }
557  
558 2 1;
« blib/lib/Bootylicious/Plugin/Search.pm ↑ Summary blib/lib/Bootylicious/DocumentStatLoader.pm »