| 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
Condition66%2/3
ref $_[0] and $_[0]->isa("Path::Tiny")
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")
| |||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
$args->{'count'} || 0
$args->{'count'}
Truth table100%2/2
A
A= $args->{'count'}
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | die "Must provide entry" unless | ||||||||||||||||||||||||||||
| 68 | 101 | ▶ | my $entry = $args->{entry}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 99 | ▶ | my $repo = $entry->{repo} //= ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$entry->{"repo"} //= ""
MC/DC100%1/1
$entry->{"repo"} //= ""
$entry->{"repo"}
Truth table100%2/2
A
A= $entry->{"repo"}
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 99 | ▶ | if ( ! defined $entry->{name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | ### FIXME this is unnecessarily Git-specific | ||||||||||||||||||||||||||||
| 74 | 2 | ▶ | $entry->{name} = ( $repo =~ m|([^/]+).git$| ) ? $1 : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 99 | ▶ | $entry->{tags} //= ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$entry->{"tags"} //= ""
MC/DC100%1/1
$entry->{"tags"} //= ""
$entry->{"tags"}
Truth table100%2/2
A
A= $entry->{"tags"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||