blib/lib/Bootylicious/Article.pm

filter: Statementstmt 85.1% 63 / 74 Branchbran 56.2% 9 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 85.0% 17 / 20 Podpod 0.0% 0 / 11 totaltotal 73.0% 92 / 126 CC 10 SCAR 9.4
CC
10
Cov
80%
tags
6.3
has_tags
6.0
comments_enabled
3.0
CRAP 2.6
« blib/lib/Bootylicious/Decorator.pm ↑ Summary blib/lib/Bootylicious/IteratorSearchable.pm »
1 package Bootylicious::Article;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use base 'Bootylicious::Document';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 ▶use Bootylicious::Timestamp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Bootylicious::Pingback;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Bootylicious::PingbackIterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Bootylicious::PingbackIteratorFinder;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Bootylicious::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Bootylicious::CommentIteratorLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 9 ▶sub title { my $self = shift; $self->metadata(title => @_) || $self->name }
Subroutine title: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$self->metadata("title", @_) or $self->name 0 9 9
16 0 ▶sub description { shift->metadata(description => @_) }
Subroutine description: not called CC=1 SCAR=6.9
Pod undocumented
17 0 ▶sub link { shift->metadata(link => @_) }
Subroutine link: not called CC=1 SCAR=6.9
Pod undocumented
18  
19 sub tags {
20 10 ▶ my $self = shift;
Subroutine tags: called CC=4 SCAR=18.4
Pod undocumented
21 10 my $value = shift;
22  
23 10 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 10 10
24 $value = join ', ' => sort keys %{
25 0 ▶ { map { $_ => 1 }
Branch: 1 branch
BranchTrueFalseTotal
if $value ne "" 0 0 0
26 0 map { s/^\s+//; s/\s+$//; $_ }
27 0 grep { $_ ne '' } split ',' => $value
28 }
29 } if $value ne '';
30 0 return $self->metadata(tags => $value);
31 }
32  
33 10 my $tags = $self->metadata('tags');
34 10 ▶ return [] unless $tags;
Branch: 1 branch
BranchTrueFalseTotal
unless $tags 0 10 10
35  
36 10 return [map { s/^\s+//; s/\s+$//; $_ } split ',' => $tags];
37 }
38  
39 0 ▶sub has_tags { shift->tags ? 1 : 0 }
Subroutine has_tags: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->tags ? : 0 0 0
40  
41 sub comments_enabled {
42 2 ▶ my $self = shift;
Subroutine comments_enabled: called CC=3 SCAR=11.0
Pod undocumented
43  
44 2 my $comments = $self->metadata('comments');
45  
46 2 ▶ return defined $comments && $comments =~ /^(no|false|disable)$/i ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $comments && $comments =~ /^(no|false|disable)$/i ? : 1 1 2
Condition66%2/3
defined $comments and $comments =~ /^(no|false|disable)$/i
!ll&&!rl&&r
101
MC/DC50%1/2
defined $comments and $comments =~ /^(no|false|disable)$/i
defined $comments $comments =~ /^(no|false|disable)$/i
Truth table66%2/3
A and B
A= defined $commentsB= $comments =~ /^(no|false|disable)$/i
ABresult
0X0
100
111
47 }
48  
49 sub pingbacks {
50 4 ▶ my $self = shift;
Subroutine pingbacks: called CC=1 SCAR=0.0
Pod undocumented
51  
52 4 return Bootylicious::PingbackIterator->new(
53 path => $self->path . '.pingbacks');
54 }
55  
56 sub has_pingback {
57 2 ▶ my $self = shift;
Subroutine has_pingback: called CC=2 SCAR=6.9
Pod undocumented
58 2 my $source_uri = shift;
59  
60 2 my $finder =
61 Bootylicious::PingbackIteratorFinder->new(iterator => $self->pingbacks);
62  
63 2 ▶ return $finder->find($source_uri) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$finder->find($source_uri) ? : 1 1 2
64 }
65  
66 sub pingback {
67 1 ▶ my $self = shift;
Subroutine pingback: called CC=1 SCAR=0.0
Pod undocumented
68 1 my $source_uri = shift;
69  
70 1 my $pingback = Bootylicious::Pingback->new(
71 created => Bootylicious::Timestamp->new(epoch => time),
72 source_uri => $source_uri
73 );
74 1 return $pingback->create($self->path . '.pingbacks');
75 }
76  
77 sub comments {
78 12 ▶ my $self = shift;
Subroutine comments: called CC=1 SCAR=0.0
Pod undocumented
79  
80 12 return Bootylicious::CommentIteratorLoader->new(path => $self->path)
81 ->load(Bootylicious::Iterator->new);
82 }
83  
84 sub comment {
85 4 ▶ my $self = shift;
Subroutine comment: called CC=2 SCAR=6.9
Pod undocumented
86 4 my %params = @_;
87  
88 4 my $number = 1;
89  
90 4 ▶ if (my $last = $self->comments->last) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $last = $self->comments->last) 3 1 4
91 3 ($number) = ($last->path =~ m/\.comment-(\d+)/);
92 3 $number++;
93 }
94  
95 4 my $path = $self->path . '.comment-' . $number;
96  
97 4 my $comment = Bootylicious::Comment->new(@_);
98  
99 4 return $comment->create($path);
100 }
101  
102 10 1;
« blib/lib/Bootylicious/Decorator.pm ↑ Summary blib/lib/Bootylicious/IteratorSearchable.pm »