DBIx/Class/Migration/ShareDirBuilder.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 33.3% 2 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 75.6% 31 / 41 CC 5 SCAR 13.0
CC
5
Cov
81%
build
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« Test/DBIx/Class/FixtureCommand/Population.pm ↑ Summary DBIx/Class/Migration/RunScript/Trait/Dump.pm »
1 package DBIx::Class::Migration::ShareDirBuilder;
2  
3 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use version 0.77;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use File::ShareDir::ProjectDistDir 0.3.1 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 has schema_class => (
8 is => 'ro',
9 isa => 'Str',
10 required => 1);
11  
12 sub filename_from_class {
13 11 ▶ (my $filename_part = shift) =~s/::/\//g;
Subroutine filename_from_class: called CC=1 SCAR=0.0
Pod undocumented
14 11 return $INC{$filename_part.".pm"};
15 }
16  
17 sub class_to_distname {
18 11 ▶ (my $dist = shift) =~s/::/-/g;
Subroutine class_to_distname: called CC=1 SCAR=0.0
Pod undocumented
19 11 return $dist;
20 }
21  
22 sub build {
23 11 ▶ my $class = shift->schema_class;
Subroutine build: called CC=5 SCAR=18.4
Pod undocumented
24 11 File::ShareDir::ProjectDistDir->import('dist_dir',
25 filename => filename_from_class($class));
26  
27 11 my $sharedir;
28 11 ▶ while($class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 11 0 11
29 11 ▶ last if $sharedir = eval { dist_dir( class_to_distname($class) ) };
Branch: 1 branch
BranchTrueFalseTotal
if $sharedir = eval { do { dist_dir(class_to_distname($class)) } } 11 0 11
30 0 ▶ last unless $class =~s/::[^\:\:]+$//;
Branch: 1 branch
BranchTrueFalseTotal
unless $class =~ s/::[^\:\:]+$// 0 0 0
31 }
32  
33 11 ▶ return $sharedir || die "Can't find a share ($sharedir) for $class";
Condition50%1/2
$sharedir || die("Can't find a share ($sharedir) for $class")
l!l
110
MC/DC0%0/1
$sharedir || die("Can't find a share ($sharedir) for $class")
$sharedir
Truth table50%1/2
A
A= $sharedir
Aresult
11
00
34  
35 }
36  
37 8 __PACKAGE__->meta->make_immutable;
38  
39 =head1 NAME
40  
41 DBIx::Class::Migration::ShareDirBuilder - Build a target_dir in /share
42  
43 =head1 SYNOPSIS
44  
45 use DBIx::Class::Migration::ShareDirBuilder;
46  
47 =head1 DESCRIPTION
48  
49 This is a utility class that build the path to a distribution's C</share>
50 directory, whether the distribution is installed (via C<make install> or if
51 it is in development.
52  
53 This probably isn't really user servicable, although if you need to make a
54 custom C<target_dir> builder, you could look at this for example.
55  
56 =head1 SEE ALSO
57  
58 L<DBIx::Class::Migration>.
59  
60 =head1 AUTHOR
61  
62 See L<DBIx::Class::Migration> for author information
63  
64 =head1 COPYRIGHT & LICENSE
65  
66 See L<DBIx::Class::Migration> for copyright and license information
67  
68 =cut
69  
« Test/DBIx/Class/FixtureCommand/Population.pm ↑ Summary DBIx/Class/Migration/RunScript/Trait/Dump.pm »