lib/Bio/MUST/Core/Roles/Commentable.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 8 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 94.8% 55 / 58 CC 6 SCAR 8.3
CC
6
Cov
98%
is_comment
4.0
header
3.0
BEGIN
1.0
CRAP 2.3
« lib/Bio/MUST/Core/Seq.pm ↑ Summary lib/Bio/MUST/Core/SeqId/Filter.pm »
1 package Bio::MUST::Core::Roles::Commentable;
2 # ABSTRACT: Commentable Moose role for storable objects
3 18 $Bio::MUST::Core::Roles::Commentable::VERSION = '0.252040';
4 18 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use feature qw(say);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 ▶use Bio::MUST::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use Bio::MUST::Core::Constants qw(:files);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 has 'comments' => (
14 traits => ['Array'],
15 is => 'ro',
16 isa => 'ArrayRef[Str]',
17 463 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
18 18 handles => {
19 count_comments => 'count',
20 all_comments => 'elements',
21 join_comments => 'join',
22 add_comment => 'push',
23 get_comment => 'get',
24 insert_comment => 'unshift',
25 },
26 );
27  
28  
29  
30 60 ▶sub header {
Subroutine header: called CC=3 SCAR=11.0
Pod documented
31 60 my $self = shift;
32  
33 60 ▶ return "#\n" x 2 unless $self->count_comments;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->count_comments 25 35 60
34 35 ▶ return '# ' . $self->get_comment(0) . "\n#\n" if $self->count_comments == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->count_comments == 1 8 27 35
35 27 return '# ' . $self->join_comments("\n# ") . "\n";
36 }
37  
38  
39 102237 ▶sub is_comment {
Subroutine is_comment: called CC=4 SCAR=13.9
Pod documented
40 102237 my $self = shift;
41 102237 my $line = shift;
42 102237 ▶ my $regex = shift // $COMMENT_LINE;
Condition66%2/3
shift() // $Bio::MUST::Core::Roles::Commentable::COMMENT_LINE
l!l&&r!l&&!r
441021930
MC/DC0%0/2
shift() // $Bio::MUST::Core::Roles::Commentable::COMMENT_LINE
shift() $Bio::MUST::Core::Roles::Commentable::COMMENT_LINE
Truth table66%2/3
A // B
A= shift()B= $Bio::MUST::Core::Roles::Commentable::COMMENT_LINE
ABresult
1X1
011
000
43  
44 # store comments from file header
45 # TODO: prevent addition of further comments (after first data line)
46 102237 my ($shebang, $comment) = $line =~ $regex;
47 102237 ▶ if ($shebang) { # strip starting '#' and spaces
Branch: 1 branch
BranchTrueFalseTotal
if ($shebang) 192 102045 102237
48 192 ▶ $self->add_comment($comment) if $comment;
Branch: 1 branch
BranchTrueFalseTotal
if $comment 66 126 192
49 192 return 1;
50 }
51 102045 return 0;
52 }
53  
54 18 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 18 1;
56  
57 __END__
« lib/Bio/MUST/Core/Seq.pm ↑ Summary lib/Bio/MUST/Core/SeqId/Filter.pm »