LowLevel/Blob.pm

filter: Statementstmt 57.1% 36 / 63 Branchbran 28.5% 4 / 14 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 66.6% 8 / 12 Podpod 100% 9 / 9 totaltotal 53.1% 60 / 113 CC 14 SCAR 17.9
CC
14
Cov
50%
timestamp_added
12.0
timestamp_last
12.0
committer
12.0
CRAP 6.0
« LowLevel/Tree.pm ↑ Summary LowLevel/Reference.pm »
1 package Git::LowLevel::Blob;
2 #ABSTRACT: class representing a GIT Blow Object
3 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use MooseX::Privacy;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8  
9 4 has 'repository' => (is => 'ro', isa => 'Git::LowLevel', required => 1);
10  
11 4 has 'hash' => (is => 'rw', isa => 'Str');
12  
13 4 has 'path' => (is => 'rw', isa => 'Str');
14  
15 4 has 'parent' => (is => 'rw', isa => 'Git::LowLevel::Tree');
16  
17  
18 4 has '_content' => (is =>'rw');
19  
20 sub timestamp_added
21 0 ▶{
Subroutine timestamp_added: not called CC=3 SCAR=24.8
Pod documented
22 0 my $self = shift;
23 0 my $help = readpipe($self->repository->gitcmd() . " log --follow --diff-filter=A --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null");
24 0 my @lines = split /\n/,$help;
25 0 for my $line (@lines)
26 {
27 0 ▶ if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/) 0 0 0
28 {
29 0 return $1;
30 }
31 }
32  
33 0 return $help;
34 }
35  
36 sub timestamp_last
37 0 ▶{
Subroutine timestamp_last: not called CC=3 SCAR=24.8
Pod documented
38 0 my $self = shift;
39 0 my $help = readpipe($self->repository->gitcmd() . " log --follow --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null");
40 0 my @lines = split /\n/,$help;
41 0 for my $line (@lines)
42 {
43 0 ▶ if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/) 0 0 0
44 {
45 0 return $1;
46 }
47 }
48  
49 0 return $help;
50 }
51  
52 sub committer
53 0 ▶{
Subroutine committer: not called CC=3 SCAR=24.8
Pod documented
54 0 my $self = shift;
55 0 my $help = readpipe($self->repository->gitcmd() . " log --follow --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null");
56 0 my @lines = split /\n/,$help;
57 0 for my $line (@lines)
58 {
59 0 ▶ if ($line =~ /^Author:\s(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Author:\s(.*)$/) 0 0 0
60 {
61 0 return $1;
62 }
63 }
64  
65 0 return $help;
66 }
67  
68 sub mypath
69 5 ▶{
Subroutine mypath: called CC=3 SCAR=12.3
Pod documented
70 5 my $self = shift;
71 5 my $path = fileparse($self->path);
72 5 ▶ if (!defined($path) || length($path)==0)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $path or length $path == 0) 0 5 5
Condition33%1/3
not defined $path or length $path == 0
l!l&&r!l&&!r
005
MC/DC0%0/2
not defined $path or length $path == 0
not defined $path length $path == 0
Truth table33%1/3
not(A) or B
A= not defined $pathB= length $path == 0
ABresult
1X1
011
000
73 {
74 0 $path = $self->path;
75 }
76  
77 5 $path=~s/\///g;
78  
79 5 return $path;
80 }
81  
82  
83  
84 sub content
85 2 ▶{
Subroutine content: called CC=1 SCAR=0.0
Pod documented
86 2 my $self = shift;
87  
88 2 my $help = readpipe($self->repository->gitcmd() . " cat-file blob " . $self->hash);
89 2 chomp($help);
90  
91 2 $self->_content($help);
92  
93 2 return $help;
94 }
95  
96  
97 sub save
98 3 ▶{
Subroutine save: called CC=3 SCAR=11.8
Pod documented
99 3 my $self = shift;
100  
101 3 ▶ return unless defined($self->_content()) && length($self->_content)>0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->_content and length $self->_content > 0 0 3 3
Condition33%1/3
defined $self->_content and length $self->_content > 0
!ll&&!rl&&r
003
MC/DC0%0/2
defined $self->_content and length $self->_content > 0
defined $self->_content length $self->_content > 0
Truth table33%1/3
A and B
A= defined $self->_contentB= length $self->_content > 0
ABresult
0X0
100
111
102  
103 #TODO: perhaps do not use stdin ... better for binary files
104 3 my $help = readpipe("echo \'".$self->_content."\' |" . $self->repository->gitcmd() . " hash-object -w --stdin ");
105 3 chomp($help);
106  
107 3 $self->hash($help);
108  
109 }
110  
111 sub treeEntry
112 3 ▶{
Subroutine treeEntry: called CC=3 SCAR=13.3
Pod documented
113 3 my $self = shift;
114  
115 3 ▶ if (defined($self->hash) && length($self->hash)>30 )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->hash and length $self->hash > 30) 3 0 3
Condition33%1/3
defined $self->hash and length $self->hash > 30
!ll&&!rl&&r
003
MC/DC0%0/2
defined $self->hash and length $self->hash > 30
defined $self->hash length $self->hash > 30
Truth table33%1/3
A and B
A= defined $self->hashB= length $self->hash > 30
ABresult
0X0
100
111
116 {
117 3 return "100644 blob " . $self->hash . "\t" . $self->mypath . "\n";
118 }
119  
120 0 return "";
121 }
122  
123 sub find
124 2 ▶{
Subroutine find: called CC=2 SCAR=7.6
Pod documented
125 2 my $self = shift;
126 2 my $path = shift;
127  
128 2 ▶ return $self unless $self->mypath ne $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->mypath ne $path 2 0 2
129  
130 0 return;
131 }
132  
133 sub del
134 0 ▶{
Subroutine del: not called CC=1 SCAR=6.9
Pod documented
135 0 my $self = shift;
136  
137 0 $self->_content("");
138 0 $self->hash(" ");
139  
140 }
141  
142 4 1;
143  
144 __END__
« LowLevel/Tree.pm ↑ Summary LowLevel/Reference.pm »