File Coverage

blib/lib/Text/vCard/Precisely/V3/Node/URL.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Text::vCard::Precisely::V3::Node::URL;
2              
3 28     28   238 use Carp;
  28         73  
  28         2859  
4 28     28   241 use URI;
  28         78  
  28         836  
5              
6 28     28   200 use Moose;
  28         80  
  28         285  
7 28     28   201979 use Moose::Util::TypeConstraints;
  28         89  
  28         351  
8              
9             extends 'Text::vCard::Precisely::V3::Node';
10              
11             has name => ( is => 'ro', default => 'URL', isa => 'Str' );
12             has types => ( is => 'rw', isa => 'Types', coerce => 1 );
13              
14             subtype 'URL' => as 'Str';
15             coerce 'URL' => from 'Str' => via { [ URI->new($_)->as_string() ] };
16             has content => ( is => 'ro', default => '', isa => 'URL', coerce => 1 );
17              
18             override 'as_string' => sub {
19             my ($self) = @_;
20             my @lines;
21             push @lines, $self->name() || croak "Empty name";
22             push @lines, 'ALTID=' . $self->altID() if $self->can('altID') and $self->altID();
23             push @lines, 'PID=' . join ',', @{ $self->pid() } if $self->can('pid') and $self->pid();
24             push @lines, 'TYPE=' . join( ',', map { uc $_ } @{ $self->types() } )
25             if ref $self->types() eq 'ARRAY' and $self->types()->[0];
26              
27             my $string = join( ';', @lines ) . ':' . $self->content();
28             return $self->fold( $string, -force => 1 );
29             };
30              
31             __PACKAGE__->meta->make_immutable;
32 28     28   75209 no Moose;
  28         89  
  28         197  
33              
34             1;