File Coverage

blib/lib/Git/PurePerl/NewObject/Commit.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 34 34 100.0


line stmt bran cond sub pod time code
1             package Git::PurePerl::NewObject::Commit;
2 4     4   17 use Moose;
  4         5  
  4         25  
3 4     4   19518 use MooseX::StrictConstructor;
  4         8  
  4         31  
4 4     4   9039 use Moose::Util::TypeConstraints;
  4         8  
  4         37  
5 4     4   5755 use DateTime;
  4         8  
  4         76  
6 4     4   15 use namespace::autoclean;
  4         6  
  4         40  
7              
8             extends 'Git::PurePerl::NewObject';
9              
10             has 'kind' =>
11             ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' );
12             has 'tree' => ( is => 'rw', isa => 'Str', required => 1 );
13             has 'parent' => ( is => 'rw', isa => 'Str', required => 0 );
14             has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 );
15             has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 1 );
16             has 'committer' =>
17             ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 );
18             has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 1 );
19             has 'comment' => ( is => 'rw', isa => 'Str', required => 1 );
20              
21             sub _build_content {
22 4     4   9 my $self = shift;
23 4         8 my $content;
24              
25 4         137 $content .= 'tree ' . $self->tree . "\n";
26 4 100       133 $content .= 'parent ' . $self->parent . "\n" if $self->parent;
27 4         136 $content
28             .= "author "
29             . $self->author->name . ' <'
30             . $self->author->email . "> "
31             . $self->authored_time->epoch . " "
32             . DateTime::TimeZone->offset_as_string( $self->authored_time->offset )
33             . "\n";
34 4         540 $content
35             .= "committer "
36             . $self->committer->name . ' <'
37             . $self->author->email . "> "
38             . $self->committed_time->epoch . " "
39             . DateTime::TimeZone->offset_as_string(
40             $self->committed_time->offset )
41             . "\n";
42 4         226 $content .= "\n";
43 4         167 my $comment = $self->comment;
44 4         11 chomp $comment;
45 4         7 $content .= "$comment\n";
46              
47 4         194 $self->content($content);
48             }
49              
50             __PACKAGE__->meta->make_immutable;
51