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   16 use Moose;
  4         6  
  4         26  
3 4     4   17104 use MooseX::StrictConstructor;
  4         7  
  4         27  
4 4     4   7704 use Moose::Util::TypeConstraints;
  4         7  
  4         31  
5 4     4   4826 use DateTime;
  4         8  
  4         74  
6 4     4   15 use namespace::autoclean;
  4         5  
  4         27  
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   7 my $self = shift;
23 4         4 my $content;
24              
25 4         111 $content .= 'tree ' . $self->tree . "\n";
26 4 100       108 $content .= 'parent ' . $self->parent . "\n" if $self->parent;
27 4         105 $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         414 $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         171 $content .= "\n";
43 4         116 my $comment = $self->comment;
44 4         9 chomp $comment;
45 4         9 $content .= "$comment\n";
46              
47 4         91 $self->content($content);
48             }
49              
50             __PACKAGE__->meta->make_immutable;
51