blib/lib/Perl/Dist/Asset/Library.pm

filter: Statementstmt 61.7% 21 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 41.4% 29 / 70 CC 10 SCAR 41.8
CC
10
Cov
38%
new
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 65.1
« blib/lib/Perl/Dist/Inno/Script.pm ↑ Summary blib/lib/Perl/Dist/Asset/Perl.pm »
1 package Perl::Dist::Asset::Library;
2  
3 =pod
4  
5 =head1 NAME
6  
7 Perl::Dist::Asset::Library - "C Library" asset for a Win32 Perl
8  
9 =head1 SYNOPSIS
10  
11 my $library = Perl::Dist::Asset::Library->new(
12 name => 'zlib',
13 url => 'http://strawberryperl.com/packages/zlib-1.2.3.win32.zip',
14 unpack_to => 'zlib',
15 build_a => {
16 'dll' => 'zlib-1.2.3.win32/bin/zlib1.dll',
17 'def' => 'zlib-1.2.3.win32/bin/zlib1.def',
18 'a' => 'zlib-1.2.3.win32/lib/zlib1.a',
19 },
20 install_to => {
21 'zlib-1.2.3.win32/bin' => 'c/bin',
22 'zlib-1.2.3.win32/lib' => 'c/lib',
23 'zlib-1.2.3.win32/include' => 'c/include',
24 },
25 );
26  
27 =head1 DESCRIPTION
28  
29 B<Perl::Dist::Asset::Library> is a data class that provides encapsulation
30 and error checking for a "C library" to be installed in a
31 L<Perl::Dist>-based Perl distribution.
32  
33 It is normally created on the fly by the <Perl::Dist::Inno> C<install_library>
34 method (and other things that call it).
35  
36 B<Perl::Dist::Asset::Library> is similar to L<Perl::Dist::Asset::Binary>,
37 in that it captures a name, source URL, and paths for where to install
38 files.
39  
40 It also takes a few more pieces of information to support certain more
41 esoteric functions unique to C library builds.
42  
43 The specification of the location to retrieve the package is done via
44 the standard mechanism implemented in L<Perl::Dist::Asset>.
45  
46 =head1 METHODS
47  
48 This class inherits from L<Perl::Dist::Asset> and shares its API.
49  
50 =cut
51  
52 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use Params::Util qw{ _STRING _HASH };
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use Perl::Dist::Asset ();
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 1 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
58 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
59 1 $VERSION = '1.16';
60 1 @ISA = 'Perl::Dist::Asset';
61 }
62  
63 1 ▶use Object::Tiny qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
64 name
65 license
66 unpack_to
67 build_a
68 install_to
69 1 };
70  
71  
72  
73  
74  
75 #####################################################################
76 # Constructor
77  
78 =pod
79  
80 =head2 new
81  
82 TO BE COMPLETED
83  
84 =cut
85  
86 0 ▶sub new {
Subroutine new: not called CC=10 SCAR=47.0
Pod documented
87 0 my $self = shift->SUPER::new(@_);
88  
89 # Apply defaults
90 0 ▶ $self->{unpack_to} = '' unless defined $self->unpack_to;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->unpack_to 0 0 0
91  
92 # Check params
93 0 ▶ unless ( _STRING($self->name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_STRING(scalar $self->name)) 0 0 0
94 0 Carp::croak("Missing or invalid name param");
95 }
96 0 ▶ unless ( ! defined $self->license or _HASH($self->license) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $self->license or &_HASH(scalar $self->license)) 0 0 0
Condition0%0/3
not defined $self->license or &_HASH(scalar $self->license)
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->license or &_HASH(scalar $self->license)
not defined $self->license &_HASH(scalar $self->license)
Truth table0%0/3
not(A) or B
A= not defined $self->licenseB= &_HASH(scalar $self->license)
ABresult
1X1
011
000
97 0 Carp::croak("Missing or invalid license param");
98 }
99 0 ▶ unless ( defined $self->unpack_to and ! ref $self->unpack_to ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->unpack_to and not ref $self->unpack_to) 0 0 0
Condition0%0/3
defined $self->unpack_to and not ref $self->unpack_to
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->unpack_to and not ref $self->unpack_to
defined $self->unpack_to not ref $self->unpack_to
Truth table0%0/3
A and not(B)
A= defined $self->unpack_toB= not ref $self->unpack_to
ABresult
0X0
100
111
100 0 Carp::croak("Missing or invalid unpack_to param");
101 }
102 0 ▶ unless ( _STRING($self->install_to) or _HASH($self->install_to) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_STRING(scalar $self->install_to) or &_HASH(scalar $self->install_to)) 0 0 0
Condition0%0/3
&_STRING(scalar $self->install_to) or &_HASH(scalar $self->install_to)
l!l&&r!l&&!r
000
MC/DC0%0/2
&_STRING(scalar $self->install_to) or &_HASH(scalar $self->install_to)
&_STRING(scalar $self->install_to) &_HASH(scalar $self->install_to)
Truth table0%0/3
A or B
A= &_STRING(scalar $self->install_to)B= &_HASH(scalar $self->install_to)
ABresult
1X1
011
000
103 0 Carp::croak("Missing or invalid install_to param");
104 }
105 0 ▶ unless ( _HASH($self->build_a) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_HASH(scalar $self->build_a)) 0 0 0
106 0 Carp::croak("Missing or invalid build_a param");
107 }
108  
109 0 return $self;
110 }
111  
112 1 1;
113  
114 =pod
115  
116 =head1 SUPPORT
117  
118 Bugs should be reported via the CPAN bug tracker at
119  
120 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist>
121  
122 For other issues, contact the author.
123  
124 =head1 AUTHOR
125  
126 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
127  
128 =head1 SEE ALSO
129  
130 L<Perl::Dist>, L<Perl::Dist::Inno>, L<Perl::Dist::Asset>
131  
132 =head1 COPYRIGHT
133  
134 Copyright 2007 - 2009 Adam Kennedy.
135  
136 This program is free software; you can redistribute
137 it and/or modify it under the same terms as Perl itself.
138  
139 The full text of the license can be found in the
140 LICENSE file included with this module.
141  
142 =cut
« blib/lib/Perl/Dist/Inno/Script.pm ↑ Summary blib/lib/Perl/Dist/Asset/Perl.pm »