File Coverage

blib/lib/Git/PurePerl/Object/Tag.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 5 80.0
pod 0 1 0.0
total 16 41 39.0


line stmt bran cond sub pod time code
1             package Git::PurePerl::Object::Tag;
2 4     4   19 use Moose;
  4         6  
  4         31  
3 4     4   22802 use MooseX::StrictConstructor;
  4         11  
  4         36  
4 4     4   10651 use Moose::Util::TypeConstraints;
  4         8  
  4         37  
5 4     4   6898 use namespace::autoclean;
  4         8  
  4         40  
6              
7             extends 'Git::PurePerl::Object';
8              
9             has 'kind' =>
10             ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tag' );
11             has 'object' => ( is => 'rw', isa => 'Str', required => 0 );
12             has 'tag' => ( is => 'rw', isa => 'Str', required => 0 );
13             has 'tagger' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 );
14             has 'tagged_time' => ( is => 'rw', isa => 'DateTime', required => 0 );
15             has 'comment' => ( is => 'rw', isa => 'Str', required => 0 );
16             has 'object_kind' =>
17             ( is => 'rw', isa => 'ObjectKind', required => 0);
18              
19             my %method_map = (type => 'object_kind');
20              
21             sub BUILD {
22 0     0 0   my $self = shift;
23 0           my @lines = split "\n", $self->content;
24 0           while ( my $line = shift @lines ) {
25 0 0         last unless $line;
26 0           my ( $key, $value ) = split ' ', $line, 2;
27            
28 0 0         if ($key eq 'tagger') {
29 0           my @data = split ' ', $value;
30 0           my ($email, $epoch, $tz) = splice(@data, -3);
31 0           my $name = join(' ', @data);
32 0           my $actor =
33             Git::PurePerl::Actor->new( name => $name, email => $email );
34 0           $self->tagger($actor);
35 0           my $dt= DateTime->from_epoch( epoch => $epoch, time_zone => $tz );
36 0           $self->tagged_time($dt);
37             } else {
38 0   0       my $method = $method_map{$key} || $key;
39 0           $self->$method($value);
40             }
41             }
42 0           $self->comment( join "\n", @lines );
43             }
44              
45             __PACKAGE__->meta->make_immutable;
46