line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitGot::Command::lib; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENEHACK'; |
3
|
|
|
|
|
|
|
$App::GitGot::Command::lib::VERSION = '1.339'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Generate a lib listing off a .gotlib file |
5
|
15
|
|
|
15
|
|
10638
|
use 5.014; |
|
15
|
|
|
|
|
65
|
|
6
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
104
|
use List::Util qw/ uniq /; |
|
15
|
|
|
|
|
40
|
|
|
15
|
|
|
|
|
1227
|
|
8
|
15
|
|
|
15
|
|
111
|
use Path::Tiny; |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
947
|
|
9
|
15
|
|
|
15
|
|
232
|
use Types::Standard -types; |
|
15
|
|
|
|
|
41
|
|
|
15
|
|
|
|
|
163
|
|
10
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
|
69787
|
use App::GitGot -command; |
|
15
|
|
|
|
|
43
|
|
|
15
|
|
|
|
|
130
|
|
12
|
|
|
|
|
|
|
|
13
|
15
|
|
|
15
|
|
6273
|
use Moo; |
|
15
|
|
|
|
|
51
|
|
|
15
|
|
|
|
|
119
|
|
14
|
|
|
|
|
|
|
extends 'App::GitGot::Command'; |
15
|
15
|
|
|
15
|
|
6490
|
use namespace::autoclean; |
|
15
|
|
|
|
|
99
|
|
|
15
|
|
|
|
|
119
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub options { |
18
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub _execute { |
27
|
0
|
|
|
0
|
|
|
my( $self, $opt, $args ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my @libs = map { $self->_expand_lib($_) } $self->_raw_libs( $args ); |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
15
|
|
|
15
|
|
3006
|
no warnings; # $ENV{$self->opt->libvar} can be undefined |
|
15
|
|
|
|
|
38
|
|
|
15
|
|
|
|
|
7466
|
|
32
|
0
|
|
|
|
|
|
say join $self->opt->separator, uniq @libs, split ':', $ENV{$self->opt->libvar}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _expand_lib { |
37
|
0
|
|
|
0
|
|
|
my( $self, $lib ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
return path($lib)->absolute if $lib =~ m#^(?:\.|/)#; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ( $lib =~ s/^\@(\w+)// ) { |
42
|
|
|
|
|
|
|
# it's a tag |
43
|
0
|
|
|
|
|
|
return map { $_->path . $lib } $self->search_repos->tags($1)->all; |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# it's a repo name |
47
|
0
|
0
|
|
|
|
|
$lib =~ s#^([^/]+)## or return; |
48
|
0
|
|
|
|
|
|
return map { $_->path . $lib } $self->search_repos->name($1)->all; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _raw_libs { |
53
|
0
|
|
|
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
|
0
|
|
|
|
|
map { s/^\s+|#.*|\s+$//gr } |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
( -f $file ) ? $file->lines({ chomp => 1 }) : (); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |