Hopen/Util/Filename.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 8 / 10 Podpod 100% 1 / 1 totaltotal 67.3% 35 / 52 CC 5 SCAR 19.4
CC
5
Cov
68%
__ANON__
20.0
BEGIN
4.4
new
2.0
CRAP 7.0
« Hopen/Util/Data.pm ↑ Summary Hopen/Class.pm »
1 # Data::Hopen::Util::Filename - functions for manipulating filenames
2 package Data::Hopen::Util::Filename;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::Hopen::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.000021';
7  
8 1 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS);
10 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 @EXPORT = qw();
12 1 @EXPORT_OK = qw(obj exe lib);
13 1 %EXPORT_TAGS = (
14 default => [@EXPORT],
15 all => [@EXPORT, @EXPORT_OK]
16 );
17 }
18  
19 1 ▶use Class::Method::Modifiers qw(fresh);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Data::Hopen;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # Docs {{{1
24  
25 =head1 NAME
26  
27 Data::Hopen::Util::Filename - functions for manipulating filenames
28  
29 =head1 SYNOPSIS
30  
31 Nothing is exported by default. Each function is available via an OO
32 interface or a procedural interface.
33  
34 =head1 FUNCTIONS
35  
36 =cut
37  
38 # }}}1
39  
40 =head2 obj
41  
42 Return the given filename, with the extension of an object file added.
43 Usage:
44  
45 Data::Hopen::Util::Filename::obj(filename[, -strip=>true]); # procedural
46 Data::Hopen::Util::Filename->new->obj(fn[, -strip=>true]); # OO
47  
48 If C<< -strip => <truthy> >> is given, strip any existing extension first.
49  
50 =head2 exe
51  
52 Return the given filename, with the extension of an executable file added.
53 Usage and options are the same as L</obj>.
54  
55 =head2 lib
56  
57 Return the given filename, with the extension of a library file added.
58 Usage and options are the same as L</obj>.
59  
60 =cut
61  
62 # Create obj(), exe(), and lib() in a loop since they share the same skeleton.
63  
64 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=14.9
65 1 foreach my $lrFunction ([qw(obj _o obj_ext .o)],
66 [qw(exe _exe exe_ext), ''],
67 [qw(lib _a lib_ext .a)])
68 {
69 0 ▶ fresh $lrFunction->[0] => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
70 0 my (undef, %args) = getparameters(__PACKAGE__, [qw(filename; strip)], @_);
71 # __PACKAGE__ => Permit OO interface
72 0 ▶ $args{filename} =~ s/\.[^.]*$// if $args{strip};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"strip"} 0 0 0
73 return $args{filename} .
74 0 ▶ ($Config{$lrFunction->[1]} // $Config{$lrFunction->[2]} //
Condition0%0/6
($Data::Hopen::Util::Filename::Config{$lrFunction->[1]} // $Data::Hopen::Util::Filename::Config{$lrFunction->[2]}) // $lrFunction->[3]
l!l&&r!l&&!r
000
$Data::Hopen::Util::Filename::Config{$lrFunction->[1]} // $Data::Hopen::Util::Filename::Config{$lrFunction->[2]}
l!l&&r!l&&!r
000
MC/DC0%0/3
($Data::Hopen::Util::Filename::Config{$lrFunction->[1]} // $Data::Hopen::Util::Filename::Config{$lrFunction->[2]}) // $lrFunction->[3]
$Data::Hopen::Util::Filename::Config{$lrFunction->[1]} $Data::Hopen::Util::Filename::Config{$lrFunction->[2]} $lrFunction->[3]
Truth table0%0/4
A // B // C
A= $Data::Hopen::Util::Filename::Config{$lrFunction->[1]}B= $Data::Hopen::Util::Filename::Config{$lrFunction->[2]}C= $lrFunction->[3]
ABCresult
1XX1
01X1
0011
0000
75 $lrFunction->[3]);
76 3 };
77 }
78 }
79  
80 =head2 new
81  
82 Create a new instance for the OO interface. For example:
83  
84 my $FN = Data::Hopen::Util::Filename->new;
85 say $fn->obj('hello'); # e.g., "hello.o" or "hello.obj"
86  
87 =cut
88  
89 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
90  
91 1 1;
92 __END__
« Hopen/Util/Data.pm ↑ Summary Hopen/Class.pm »