File Coverage

blib/lib/Sieve/Generator/Lines/Heredoc.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 4 4 100.0
pod 0 1 0.0
total 24 26 92.3


line stmt bran cond sub pod time code
1 1     1   14 use v5.36.0;
  1         3  
2             package Sieve::Generator::Lines::Heredoc 0.001;
3             # ABSTRACT: a Sieve multiline string (heredoc)
4              
5 1     1   7 use Moo;
  1         1  
  1         5  
6             with 'Sieve::Generator::Lines';
7              
8             #pod =head1 DESCRIPTION
9             #pod
10             #pod A heredoc renders a block of text as a Sieve multiline string using the
11             #pod C/C<.> syntax defined in RFC 5228. It is typically used as an
12             #pod argument to a command when the content is too large or complex for a simple
13             #pod quoted string.
14             #pod
15             #pod =attr text
16             #pod
17             #pod This attribute holds the text content of the multiline string. A trailing
18             #pod newline is added automatically if absent, and any line beginning with C<.>
19             #pod is escaped to C<..>.
20             #pod
21             #pod =cut
22              
23             has text => (is => 'ro', required => 1);
24              
25 3     3 0 1951 sub as_sieve ($self, $i = undef) {
  3         6  
  3         7  
  3         5  
26 3   50     17 my $indent = q{ } x ($i // 0);
27 3         15 my $str = "${indent}text:\n" . $self->text;
28 3 100       17 $str .= "\n" unless $str =~ /\n\z/;
29 3         9 $str =~ s/^\./../mg;
30 3         16 return "$str.\n";
31             }
32              
33 1     1   400 no Moo;
  1         2  
  1         2  
34             1;
35              
36             __END__