File Coverage

blib/lib/Sieve/Generator/Lines/Comment.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 4 4 100.0
pod 0 1 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
1 1     1   9 use v5.36.0;
  1         3  
2             package Sieve::Generator::Lines::Comment 0.001;
3             # ABSTRACT: a Sieve comment line
4              
5 1     1   4 use Moo;
  1         1  
  1         4  
6             with 'Sieve::Generator::Lines';
7              
8             #pod =head1 DESCRIPTION
9             #pod
10             #pod A comment renders as one or more C<#>-prefixed lines of Sieve code. The
11             #pod number of hash characters is configurable.
12             #pod
13             #pod =attr content
14             #pod
15             #pod This attribute holds the content of the comment. It may be a plain string
16             #pod or an object doing L.
17             #pod
18             #pod =cut
19              
20             has content => (is => 'ro', required => 1);
21              
22             #pod =attr hashes
23             #pod
24             #pod This attribute controls how many C<#> characters prefix each comment line.
25             #pod It defaults to C<1>.
26             #pod
27             #pod =cut
28              
29             has hashes => (is => 'ro', default => 1);
30              
31 3     3 0 4 sub as_sieve ($self, $i = undef) {
  3         5  
  3         6  
  3         5  
32 3   50     11 $i //= 0;
33 3 100       20 my $sieve = ref $self->content
34             ? $self->content->as_sieve(0)
35             : $self->content;
36              
37 3         8 my $indent = q{ } x $i;
38 3         11 my $hashes = q{#} x $self->hashes;
39 3         27 $sieve =~ s/^/$indent$hashes /gm;
40              
41 3         13 return $sieve;
42             }
43              
44 1     1   387 no Moo;
  1         1  
  1         3  
45             1;
46              
47             __END__