| 1 | package App::GitGot::Command::lib; | ||||||||||
| 2 | 16 | our $AUTHORITY = 'cpan:GENEHACK'; | |||||||||
| 3 | 16 | $App::GitGot::Command::lib::VERSION = '1.339'; | |||||||||
| 4 | # ABSTRACT: Generate a lib listing off a .gotlib file | ||||||||||
| 5 | 16 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 16 | ▶ | use List::Util qw/ uniq /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 16 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 16 | ▶ | use Types::Standard -types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 16 | ▶ | use App::GitGot -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 16 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 16 | extends 'App::GitGot::Command'; | |||||||||
| 15 | 16 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub options { | ||||||||
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 18 | 0 | my( $class , $app ) = @_; | |||||||||
| 19 | return ( | ||||||||||
| 20 | 0 | [ 'gotlib=s' => 'gotlib file' => { default => '.gotlib' } ] , | |||||||||
| 21 | [ 'libvar=s' => 'library environment variable' => { default => 'PERL5LIB' } ] , | ||||||||||
| 22 | [ 'separator=s' => 'library path separator' => { default => ':' } ] , | ||||||||||
| 23 | ); | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub _execute { | ||||||||
|
Subroutine
_execute: not called CC=1 SCAR=1.7
| |||||||||||
| 27 | 0 | my( $self, $opt, $args ) = @_; | |||||||||
| 28 | |||||||||||
| 29 | 0 | my @libs = map { $self->_expand_lib($_) } $self->_raw_libs( $args ); | |||||||||
| 30 | |||||||||||
| 31 | 16 | ▶ | no warnings; # $ENV{$self->opt->libvar} can be undefined | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 0 | say join $self->opt->separator, uniq @libs, split ':', $ENV{$self->opt->libvar}; | |||||||||
| 33 | |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub _expand_lib { | ||||||||
|
Subroutine
_expand_lib: not called CC=4 SCAR=30.0
| |||||||||||
| 37 | 0 | my( $self, $lib ) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | return path($lib)->absolute if $lib =~ m#^(?:\.|/)#; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | if ( $lib =~ s/^\@(\w+)// ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | # it's a tag | ||||||||||
| 43 | 0 | return map { $_->path . $lib } $self->search_repos->tags($1)->all; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | # it's a repo name | ||||||||||
| 47 | 0 | ▶ | $lib =~ s#^([^/]+)## or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | return map { $_->path . $lib } $self->search_repos->name($1)->all; | |||||||||
| 49 | |||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub _raw_libs { | ||||||||
|
Subroutine
_raw_libs: not called CC=2 SCAR=17.9
| |||||||||||
| 53 | 0 | my( $self, $args ) = @_; | |||||||||
| 54 | |||||||||||
| 55 | 0 | my $file = path( $self->opt->gotlib ); | |||||||||
| 56 | |||||||||||
| 57 | return @$args, | ||||||||||
| 58 | # remove comments and clean whitespaces | ||||||||||
| 59 | 0 | grep { $_ } | |||||||||
| 60 | 0 | ▶ | map { s/^\s+|#.*|\s+$//gr } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | ( -f $file ) ? $file->lines({ chomp => 1 }) : (); | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 16 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||