line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Rakubrew::Tools; |
2
|
|
|
|
|
|
|
require Exporter; |
3
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
4
|
|
|
|
|
|
|
our @EXPORT = qw(run slurp spurt trim uniq slurp_dir my_fileparse); |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
83
|
|
7
|
3
|
|
|
3
|
|
25
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
73
|
|
8
|
3
|
|
|
3
|
|
43
|
use 5.010; |
|
3
|
|
|
|
|
9
|
|
9
|
3
|
|
|
3
|
|
18
|
use File::Spec::Functions qw(catfile); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
140
|
|
10
|
3
|
|
|
3
|
|
26
|
use File::Basename; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
288
|
|
11
|
3
|
|
|
3
|
|
20
|
use Carp qw(croak); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1453
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub run { |
14
|
0
|
0
|
|
0
|
0
|
|
system(@_) and croak "Failed running ".$_[0] |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub slurp { |
18
|
0
|
|
|
0
|
0
|
|
my $file = shift; |
19
|
0
|
|
|
|
|
|
open(my $fh, '<', $file); |
20
|
0
|
|
|
|
|
|
local $/ = ''; |
21
|
0
|
|
|
|
|
|
my $ret = <$fh>; |
22
|
0
|
|
|
|
|
|
close($fh); |
23
|
0
|
|
0
|
|
|
|
return $ret // ''; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub spurt { |
27
|
0
|
|
|
0
|
0
|
|
my ($file, $cont) = @_; |
28
|
0
|
|
|
|
|
|
open(my $fh, '>', $file); |
29
|
0
|
|
|
|
|
|
say $fh $cont; |
30
|
0
|
|
|
|
|
|
close($fh); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub trim { |
34
|
0
|
|
|
0
|
0
|
|
my $text = shift; |
35
|
0
|
|
|
|
|
|
$text =~ s/^\s+|\s+$//g; |
36
|
0
|
|
|
|
|
|
return $text; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub uniq { |
40
|
0
|
|
|
0
|
0
|
|
my %seen; |
41
|
0
|
|
|
|
|
|
return grep { !$seen{$_}++ } @_; |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub slurp_dir { |
45
|
0
|
|
|
0
|
0
|
|
my $name = shift; |
46
|
0
|
0
|
|
|
|
|
opendir(my $dh, $name) or return; |
47
|
0
|
|
|
|
|
|
my @ret; |
48
|
0
|
|
|
|
|
|
while (my $entry = readdir $dh) { |
49
|
0
|
0
|
|
|
|
|
next if $entry =~ /^\./; |
50
|
0
|
0
|
|
|
|
|
next if !-f catfile($name, $entry); |
51
|
0
|
|
|
|
|
|
push @ret, $entry; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
closedir $dh; |
54
|
0
|
|
|
|
|
|
return @ret; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub my_fileparse { |
58
|
0
|
|
|
0
|
0
|
|
return fileparse(shift, ('.dll.lib', qr/\.[^.]+/)); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|