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

filter: Statementstmt 77.7% 21 / 27 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 64.4% 29 / 45 CC 4 SCAR 20.7
CC
4
Cov
62%
new
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.9
« blib/lib/auto/share/dist/Perl-Dist/default/perl-5.10.0/lib/ExtUtils/Command.pm ↑ Summary blib/lib/Perl/Dist/Machine.pm »
1 package Perl::Dist::Asset::Binary;
2  
3 =pod
4  
5 =head1 NAME
6  
7 Perl::Dist::Asset::Binary - "Binary Package" asset for a Win32 Perl
8  
9 =head1 SYNOPSIS
10  
11 my $binary = Perl::Dist::Asset::Binary->new(
12 name => 'dmake',
13 license => {
14 'dmake/COPYING' => 'dmake/COPYING',
15 'dmake/readme/license.txt' => 'dmake/license.txt',
16 },
17 install_to => {
18 'dmake/dmake.exe' => 'c/bin/dmake.exe',
19 'dmake/startup' => 'c/bin/startup',
20 },
21 );
22  
23 =head1 DESCRIPTION
24  
25 B<Perl::Dist::Asset::Binary> is a data class that provides encapsulation
26 and error checking for a "binary package" to be installed in a
27 L<Perl::Dist>-based Perl distribution.
28  
29 It is normally created on the fly by the <Perl::Dist::Inno> C<install_binary>
30 method (and other things that call it).
31  
32 These packages will be simple zip or tar.gz files that are local files,
33 installed in a CPAN distribution's 'share' directory, or retrieved from
34 the internet via a URI.
35  
36 The specification of the location to retrieve the package is done via
37 the standard mechanism implemented in L<Perl::Dist::Asset>.
38  
39 =head1 METHODS
40  
41 This class inherits from L<Perl::Dist::Asset> and shares its API.
42  
43 =cut
44  
45 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use Params::Util qw{ _STRING _HASH };
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use Perl::Dist::Asset ();
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 1 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 $VERSION = '1.16';
53 1 @ISA = 'Perl::Dist::Asset';
54 }
55  
56 1 ▶use Object::Tiny qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
57 name
58 license
59 install_to
60 1 };
61  
62  
63  
64  
65  
66 #####################################################################
67 # Constructor and Accessors
68  
69 =pod
70  
71 =head2 new
72  
73 The C<new> constructor takes a series of parameters, validates then
74 and returns a new B<Perl::Dist::Asset::Binary> object.
75  
76 It inherits all the params described in the L<Perl::Dist::Asset> C<new>
77 method documentation, and adds some additional params.
78  
79 =over 4
80  
81 =item name
82  
83 The required C<name> param is the logical (arbitrary) name of the package
84 for the purposes of identification.
85  
86 =item license
87  
88 During the installation build process, licenses files are pulled from
89 the various source packages and written to a single dedicated directory.
90  
91 The optional C<license> param should be a reference to a HASH, where the keys
92 are the location of license files within the package, and the values are
93 locations within the "licenses" subdirectory of the final installation.
94  
95 =item install_to
96  
97 The required C<install_to> param describes the location that the package
98 will be installed to.
99  
100 If the C<install_to> param is a single string, such as "c" or "perl\foo"
101 the entire binary package will be installed, with the root of the package
102 archive being placed in the directory specified.
103  
104 If the C<install_to> param is a reference to a HASH, it is taken to mean
105 that only some parts of the original binary package are required in the
106 final install. In this case, the keys should be the file or directories
107 desired, and the values are the names of the file or directory in the
108 final Perl installation.
109  
110 Although this param does not default when called directly, in practice
111 the L<Perl::Dist::Inno> C<install_binary> method will default this value
112 to "c", as most binary installations are for C toolchain tools or
113 pre-compiled C libraries.
114  
115 =back
116  
117 The C<new> constructor returns a B<Perl::Dist::Asset::Binary> object,
118 or throws an exception (dies) if an invalid param is provided.
119  
120 =cut
121  
122 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
123 0 my $self = shift->SUPER::new(@_);
124  
125 # Check params
126 0 ▶ unless ( _STRING($self->name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_STRING(scalar $self->name)) 0 0 0
127 0 Carp::croak("Missing or invalid name param");
128 }
129 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
130 0 Carp::croak("Missing or invalid install_to param");
131 }
132  
133 0 return $self;
134 }
135  
136 1 1;
137  
138 =pod
139  
140 =head1 SUPPORT
141  
142 Bugs should be reported via the CPAN bug tracker at
143  
144 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist>
145  
146 For other issues, contact the author.
147  
148 =head1 AUTHOR
149  
150 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
151  
152 =head1 SEE ALSO
153  
154 L<Perl::Dist>, L<Perl::Dist::Inno>, L<Perl::Dist::Asset>
155  
156 =head1 COPYRIGHT
157  
158 Copyright 2007 - 2009 Adam Kennedy.
159  
160 This program is free software; you can redistribute
161 it and/or modify it under the same terms as Perl itself.
162  
163 The full text of the license can be found in the
164 LICENSE file included with this module.
165  
166 =cut
« blib/lib/auto/share/dist/Perl-Dist/default/perl-5.10.0/lib/ExtUtils/Command.pm ↑ Summary blib/lib/Perl/Dist/Machine.pm »