File Coverage

blib/lib/Sieve/Generator/Text/Terms.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 4 4 100.0
pod 0 1 0.0
total 22 24 91.6


line stmt bran cond sub pod time code
1 1     1   10 use v5.36.0;
  1         3  
2             package Sieve::Generator::Text::Terms 0.001;
3             # ABSTRACT: a sequence of Sieve terms joined by spaces
4              
5 1     1   4 use Moo;
  1         1  
  1         5  
6             with 'Sieve::Generator::Text';
7              
8             #pod =head1 DESCRIPTION
9             #pod
10             #pod A C object renders a sequence of terms as a space-joined inline Sieve
11             #pod expression. It is the general-purpose building block for Sieve test
12             #pod expressions and argument sequences.
13             #pod
14             #pod =attr terms
15             #pod
16             #pod This attribute holds the arrayref of terms. Each term may be a plain string or
17             #pod an object doing L; all terms are joined with single
18             #pod spaces when rendered.
19             #pod
20             #pod =cut
21              
22             has terms => (is => 'ro', required => 1);
23              
24 25     25 0 37 sub as_sieve ($self, $i = undef) {
  25         37  
  25         45  
  25         32  
25             my $str = (q{ } x ($i // 0))
26             . join q{ },
27 25 100 50     94 map {; ref($_) ? $_->as_sieve : $_ }
  49         206  
28             $self->terms->@*;
29              
30 25         76 return $str;
31             }
32              
33 1     1   379 no Moo;
  1         2  
  1         4  
34             1;
35              
36             __END__