File Coverage

blib/lib/Sieve/Generator/Element/Comment.pm
Criterion Covered Total %
statement 18 22 81.8
branch 2 4 50.0
condition 1 2 50.0
subroutine 4 5 80.0
pod 0 2 0.0
total 25 35 71.4


line stmt bran cond sub pod time code
1 1     1   10 use v5.36.0;
  1         3  
2             package Sieve::Generator::Element::Comment 0.003;
3             # ABSTRACT: a Sieve comment line
4              
5 1     1   6 use Moo;
  1         15  
  1         5  
6             with 'Sieve::Generator::Element';
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 0 0   0 0 0 sub children ($self) { ref $self->content ? ($self->content) : () }
  0         0  
  0         0  
  0         0  
32              
33 3     3 0 5 sub as_sieve ($self, $i = undef) {
  3         2  
  3         4  
  3         2  
34 3   50     13 $i //= 0;
35              
36 3 100       10 my $sieve = ref $self->content
37             ? $self->content->as_sieve(0)
38             : $self->content;
39              
40 3         5 my $indent = q{ } x $i;
41 3         7 my $hashes = q{#} x $self->hashes;
42 3         18 $sieve =~ s/^/$indent$hashes /gm;
43              
44 3         8 return $sieve;
45             }
46              
47 1     1   441 no Moo;
  1         2  
  1         2  
48             1;
49              
50             __END__