GitGot/Repo.pm

filter: Statementstmt 100% 50 / 50 Branchbran 91.6% 11 / 12 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 11 / 11 Podpod 75.0% 3 / 4 totaltotal 95.6% 87 / 91 CC 12 SCAR 14.1
CC
12
Cov
97%
BUILDARGS
8.0
__ANON__
3.0
in_writable_format
3.0
CRAP 4.1
« GitGot/Command/push.pm ↑ Summary GitGot/Command/chdir.pm »
1 package App::GitGot::Repo;
2 42 our $AUTHORITY = 'cpan:GENEHACK';
3 42 $App::GitGot::Repo::VERSION = '1.339';
4 # ABSTRACT: Base repository objects
5 42 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 42 ▶use List::Util qw/ uniq /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 42 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 42 ▶use App::GitGot::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 42 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 42 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 42 has label => (
17 is => 'ro' ,
18 isa => Str ,
19 );
20  
21  
22 42 has name => (
23 is => 'ro',
24 isa => Str,
25 required => 1 ,
26 );
27  
28  
29 42 has number => (
30 is => 'ro',
31 isa => Int,
32 required => 1 ,
33 );
34  
35  
36 has path => (
37 is => 'ro',
38 isa => Str,
39 required => 1 ,
40 99 ▶ coerce => sub { ref $_[0] && $_[0]->isa('Path::Tiny') ? "$_[0]" : $_[0] } ,
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] && $_[0]->isa('Path::Tiny') ? : 1 98 99
Condition66%2/3
ref $_[0] and $_[0]->isa("Path::Tiny")
!ll&&!rl&&r
9801
MC/DC50%1/2
ref $_[0] and $_[0]->isa("Path::Tiny")
ref $_[0] $_[0]->isa("Path::Tiny")
Truth table66%2/3
A and B
A= ref $_[0]B= $_[0]->isa("Path::Tiny")
ABresult
0X0
100
111
41 42 );
42  
43  
44 42 has repo => (
45 is => 'ro',
46 isa => Str,
47 );
48  
49  
50 42 has tags => (
51 is => 'rw',
52 isa => Str,
53 );
54  
55  
56 42 has type => (
57 is => 'ro',
58 isa => Str,
59 required => 1 ,
60 );
61  
62 101 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=8 SCAR=20.8
Pod undocumented
63 101 my( $class , $args ) = @_;
64  
65 101 ▶ my $count = $args->{count} || 0;
Condition100%2/2
$args->{'count'} || 0
l!l
8615
MC/DC100%1/1
$args->{'count'} || 0
$args->{'count'}
Truth table100%2/2
A
A= $args->{'count'}
Aresult
11
00
66  
67 die "Must provide entry" unless
68 101 ▶ my $entry = $args->{entry};
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $args->{"entry"} 2 99 101
69  
70 99 ▶ my $repo = $entry->{repo} //= '';
Condition100%2/2
$entry->{"repo"} //= ""
l!l
4752
MC/DC100%1/1
$entry->{"repo"} //= ""
$entry->{"repo"}
Truth table100%2/2
A
A= $entry->{"repo"}
Aresult
11
00
71  
72 99 ▶ if ( ! defined $entry->{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $entry->{"name"}) 2 97 99
73 ### FIXME this is unnecessarily Git-specific
74 2 ▶ $entry->{name} = ( $repo =~ m|([^/]+).git$| ) ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$repo =~ m[([^/]+).git$]u ? : 2 0 2
75 }
76  
77 99 ▶ $entry->{tags} //= '';
Condition100%2/2
$entry->{"tags"} //= ""
l!l
3366
MC/DC100%1/1
$entry->{"tags"} //= ""
$entry->{"tags"}
Truth table100%2/2
A
A= $entry->{"tags"}
Aresult
11
00
78  
79 my $return = {
80 number => $count ,
81 name => $entry->{name} ,
82 path => $entry->{path} ,
83 repo => $repo ,
84 type => $entry->{type} ,
85 tags => $entry->{tags} ,
86 99 };
87  
88 99 ▶ $return->{label} = $args->{label} if $args->{label};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"label"} 84 15 99
89  
90 99 return $return;
91 }
92  
93  
94 1 ▶sub add_tags {
Subroutine add_tags: called CC=1 SCAR=0.0
Pod documented
95 1 my( $self, @tags ) = @_;
96  
97 1 $self->tags( join ' ', uniq sort @tags, split ' ', $self->tags );
98 }
99  
100  
101 23 ▶sub in_writable_format {
Subroutine in_writable_format: called CC=3 SCAR=11.0
Pod documented
102 23 my $self = shift;
103  
104 23 my $writeable = {
105 name => $self->name ,
106 path => $self->path ,
107 };
108  
109 23 foreach ( qw/ repo tags type /) {
110 69 ▶ $writeable->{$_} = $self->$_ if $self->$_;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$_ 33 36 69
111 }
112  
113 23 return $writeable;
114 }
115  
116  
117 1 ▶sub remove_tags {
Subroutine remove_tags: called CC=1 SCAR=0.0
Pod documented
118 1 my( $self, @tags ) = @_;
119  
120 1 my %verboten = map { $_ => 1 } @tags;
121  
122 1 $self->tags( join ' ', grep { !$verboten{$_} } split ' ', $self->tags );
123 }
124  
125  
126 42 1;
127  
128 __END__
« GitGot/Command/push.pm ↑ Summary GitGot/Command/chdir.pm »