Cogit/Object.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 90.7% 39 / 43 CC 3 SCAR 3.7
CC
3
Cov
94%
__ANON__
2.1
_build_size
2.1
BEGIN
1.0
CRAP 1.4
« Cogit/Loose.pm ↑ Summary Cogit/Protocol/SSH.pm »
1 package Cogit::Object;
2 4 $Cogit::Object::VERSION = '0.001001';
3 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Digest::SHA;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use MooX::Types::MooseLike::Base qw( Str Int InstanceOf );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 has kind => (
9 is => 'ro',
10 132 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
11 132 ▶ die "$_[0] is not a valid object type" unless $_[0] =~ m/commit|tree|blob|tag/
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ /commit|tree|blob|tag/ 0 132 132
12 },
13 4 required => 1,
14 );
15  
16 # TODO: make this required later
17 4 has content => (
18 is => 'rw',
19 builder => '_build_content',
20 lazy => 1,
21 predicate => 'has_content',
22 );
23  
24 4 has size => (
25 is => 'ro',
26 isa => Int,
27 builder => '_build_size',
28 lazy => 1,
29 );
30  
31 4 has sha1 => (
32 is => 'ro',
33 isa => Str,
34 builder => '_build_sha1',
35 lazy => 1,
36 );
37  
38 4 has git => (
39 is => 'rw',
40 isa => InstanceOf['Cogit'],
41 weak_ref => 1,
42 );
43  
44 14 ▶sub _build_sha1 {
Subroutine _build_sha1: called CC=1 SCAR=0.0
45 14 my $self = shift;
46 14 my $sha1 = Digest::SHA->new;
47 14 $sha1->add( $self->raw );
48 14 my $sha1_hex = $sha1->hexdigest;
49 14 return $sha1_hex;
50 }
51  
52 14 ▶sub _build_size {
Subroutine _build_size: called CC=2 SCAR=7.2
53 14 my $self = shift;
54 14 ▶ return length($self->content || "");
Condition50%1/2
$self->content || ''
l!l
140
MC/DC0%0/1
$self->content || ''
$self->content
Truth table50%1/2
A
A= $self->content
Aresult
11
00
55 }
56  
57 28 ▶sub raw {
Subroutine raw: called CC=1 SCAR=0.0
Pod undocumented
58 28 my $self = shift;
59 28 return $self->kind . ' ' . $self->size . "\0" . $self->content;
60 }
61  
62 4 1;
63  
64 __END__
« Cogit/Loose.pm ↑ Summary Cogit/Protocol/SSH.pm »