File Coverage

blib/lib/Text/vCard/Precisely/V4/Node/Member.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Text::vCard::Precisely::V4::Node::Member;
2              
3 14     14   116 use Carp;
  14         34  
  14         1123  
4 14     14   97 use Moose;
  14         28  
  14         110  
5 14     14   94116 use Moose::Util::TypeConstraints;
  14         37  
  14         137  
6              
7             extends 'Text::vCard::Precisely::V4::Node';
8              
9             has name => ( is => 'ro', default => 'MEMBER', isa => 'Str' );
10             has content => ( is => 'ro', default => '', isa => 'Str' );
11              
12             subtype 'MemberType' => as 'Str' => where {
13             m/^(?:contact|acquaintance|friend|met|co-worker|colleague|co-resident|neighbor|child|parent|sibling|spouse|kin|muse|crush|date|sweetheart|me|agent|emergency)$/is;
14              
15             # it needs tests
16             } => message {"The text you provided, $_, was not supported in 'MemberType'"};
17             has types => ( is => 'rw', isa => 'ArrayRef[MemberType]', default => sub { [] } );
18              
19             override 'as_string' => sub {
20             my ($self) = @_;
21             my @lines;
22             push @lines, $self->name() || croak "Empty name";
23             push @lines, 'ALTID=' . $self->altID() if $self->altID();
24             push @lines, 'PID=' . join ',', @{ $self->pid() } if $self->pid();
25             push @lines, 'TYPE="' . join( ',', map { uc $_ } @{ $self->types() } ) . '"'
26             if ref $self->types() eq 'ARRAY' and $self->types()->[0];
27             push @lines, 'PREF=' . $self->pref() if $self->pref();
28              
29             my $string = join( ';', @lines ) . ':' . $self->_escape( $self->content() );
30             return $self->fold($string);
31              
32             };
33              
34             __PACKAGE__->meta->make_immutable;
35 14     14   36931 no Moose;
  14         46  
  14         87  
36              
37             1;