PurePerl/Object/Commit.pm

filter: Statementstmt 39.7% 27 / 68 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 41.6% 5 / 12 Podpod 0.0% 0 / 5 totaltotal 29.3% 32 / 109 CC 11 SCAR 42.0
CC
11
Cov
31%
BUILD
132.0
tree
2.0
_push_parent_sha1
2.0
CRAP 66.7
« PurePerl/PackIndex/Version2.pm ↑ Summary PurePerl/PackIndex/Version1.pm »
1 package Git::PurePerl::Object::Commit;
2 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Encode qw/decode/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 extends 'Git::PurePerl::Object';
9  
10 4 has 'kind' =>
11 ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' );
12 4 has 'tree_sha1' => ( is => 'rw', isa => 'Str', required => 0 );
13 0 ▶has 'parent_sha1s' => ( is => 'rw', isa => 'ArrayRef[Str]', required => 0, default => sub { [] });
Subroutine __ANON__: not called CC=1 SCAR=1.2
14 4 has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 );
15 4 has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 0 );
16 4 has 'committer' =>
17 ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 );
18 4 has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 0 );
19 4 has 'comment' => ( is => 'rw', isa => 'Str', required => 0 );
20 4 has 'encoding' => ( is => 'rw', isa => 'Str', required => 0 );
21  
22 4 my %method_map = (
23 'tree' => 'tree_sha1',
24 'parent' => '_push_parent_sha1',
25 'author' => 'authored_time',
26 'committer' => 'committed_time'
27 );
28  
29 sub BUILD {
30 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=11 SCAR=48.8
Pod undocumented
31 0 ▶ return unless $self->content;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->content 0 0 0
32 0 my @lines = split "\n", $self->content;
33 0 my %header;
34 0 ▶ while ( my $line = shift @lines ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @lines) 0 0 0
35 0 ▶ last unless $line;
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 0 0
36 0 my ( $key, $value ) = split ' ', $line, 2;
37 0 push @{$header{$key}}, $value;
38 }
39 $header{encoding}
40 0 ▶ ||= [ $self->git->config->get(key => "i18n.commitEncoding") || "utf-8" ];
Condition0%0/4
$header{"encoding"} ||= [$self->git->config->get("key", "i18n.commitEncoding") || "utf-8"]
l!l
00
$self->git->config->get('key', 'i18n.commitEncoding') || 'utf-8'
l!l
00
MC/DC0%0/1
$header{"encoding"} ||= [$self->git->config->get("key", "i18n.commitEncoding") || "utf-8"]
$header{"encoding"}
MC/DC0%0/1
$self->git->config->get('key', 'i18n.commitEncoding') || 'utf-8'
$self->git->config->get('key', 'i18n.commitEncoding')
Truth table0%0/2
A
A= $header{"encoding"}
Aresult
11
00
Truth table0%0/2
A
A= $self->git->config->get('key', 'i18n.commitEncoding')
Aresult
11
00
41 0 my $encoding = $header{encoding}->[-1];
42 0 for my $key (keys %header) {
43 0 for my $value (@{$header{$key}}) {
44 0 $value = decode($encoding, $value);
45 0 ▶ if ( $key eq 'committer' or $key eq 'author' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'committer' or $key eq 'author') { } 0 0 0
Condition0%0/3
$key eq "committer" or $key eq "author"
l!l&&r!l&&!r
000
MC/DC0%0/2
$key eq "committer" or $key eq "author"
$key eq "committer" $key eq "author"
Truth table0%0/3
A or B
A= $key eq "committer"B= $key eq "author"
ABresult
1X1
011
000
46 0 my @data = split ' ', $value;
47 0 my ( $email, $epoch, $tz ) = splice( @data, -3 );
48 0 $email = substr( $email, 1, -1 );
49 0 my $name = join ' ', @data;
50 0 my $actor
51 = Git::PurePerl::Actor->new( name => $name, email => $email );
52 0 $self->$key($actor);
53 0 $key = $method_map{$key};
54 0 my $dt
55 = DateTime->from_epoch( epoch => $epoch, time_zone => $tz );
56 0 $self->$key($dt);
57 } else {
58 0 ▶ $key = $method_map{$key} || $key;
Condition0%0/3
$method_map{$key} || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$method_map{$key} || $key
$method_map{$key} $key
Truth table0%0/3
A || B
A= $method_map{$key}B= $key
ABresult
1X1
011
000
59 0 $self->$key($value);
60 }
61 }
62 }
63 0 $self->comment( decode($encoding, join "\n", @lines) );
64 }
65  
66  
67 sub tree {
68 0 ▶ my $self = shift;
Subroutine tree: not called CC=1 SCAR=6.9
Pod undocumented
69 0 return $self->git->get_object( $self->tree_sha1 );
70 }
71  
72  
73 sub _push_parent_sha1 {
74 0 ▶ my ($self, $sha1) = @_;
Subroutine _push_parent_sha1: not called CC=1 SCAR=6.9
75
76 0 push(@{$self->parent_sha1s}, $sha1);
77 }
78  
79 sub parent_sha1 {
80 0 ▶ return shift->parent_sha1s->[0];
Subroutine parent_sha1: not called CC=1 SCAR=6.9
Pod undocumented
81 }
82
83 sub parent {
84 0 ▶ my $self = shift;
Subroutine parent: not called CC=1 SCAR=6.9
Pod undocumented
85 0 return $self->git->get_object( $self->parent_sha1 );
86 }
87  
88 sub parents {
89 0 ▶ my $self = shift;
Subroutine parents: not called CC=1 SCAR=6.9
Pod undocumented
90
91 0 return map { $self->git->get_object( $_ ) } @{$self->parent_sha1s};
92 }
93  
94 4 __PACKAGE__->meta->make_immutable;
95  
« PurePerl/PackIndex/Version2.pm ↑ Summary PurePerl/PackIndex/Version1.pm »