blib/lib/Alien/IE7.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 100% 5 / 5 totaltotal 95.0% 76 / 80 CC 6 SCAR 8.0
CC
6
Cov
95%
install
5.0
version
2.0
__ANON__
2.0
CRAP 2.2
↑ Summary
1 package Alien::IE7;
2  
3 ###############################################################################
4 # Required inclusions.
5 ###############################################################################
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use File::Find qw(find);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use File::Copy qw(copy);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use File::Path qw(mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use File::Basename qw(basename dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ###############################################################################
16 # Version numbering
17 ###############################################################################
18 3 our $IE7_VERSION = '0.9';
19 3 our $VERSION = '0.9.4';
20  
21 ###############################################################################
22 # Subroutine: version()
23 ###############################################################################
24 # Returns the IE7 version number.
25 #
26 # Not to be confused with the 'Alien::IE7' version number (which is the version
27 # number of the Perl wrapper).
28 ###############################################################################
29 0 ▶sub version {
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
30 0 return $IE7_VERSION;
31 }
32  
33 ###############################################################################
34 # Subroutine: path()
35 ###############################################################################
36 # Returns the path to the available copy of IE7.
37 ###############################################################################
38 3 ▶sub path {
Subroutine path: called CC=1 SCAR=0.0
Pod documented
39 3 my $base = $INC{'Alien/IE7.pm'};
40 3 $base =~ s{\.pm$}{};
41 3 return $base;
42 }
43  
44 ###############################################################################
45 # Subroutine: to_blib()
46 ###############################################################################
47 # Returns a hash containing paths to the source files to be copied, and their
48 # relative destinations.
49 ###############################################################################
50 3 ▶sub to_blib {
Subroutine to_blib: called CC=1 SCAR=0.0
Pod documented
51 3 my $class = shift;
52 3 my $path = $class->path();
53 3 my %blib;
54 File::Find::find(
55 84 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
56 84 ▶ -f && do {
Branch: 1 branch
BranchTrueFalseTotal
-f $_ and do { my $dstdir = $File::Find::dir; $dstdir =~ s[^$path/?][]; $blib{$File::Find::name} = join("", $dstdir, $_) } 81 3 84
57 81 my $dstdir = $File::Find::dir;
58 81 $dstdir =~ s{^$path/?}{};
59 81 $blib{$File::Find::name} = join('', $dstdir, $_);
60 }
61 },
62 3 $path
63 );
64 3 return %blib;
65 }
66  
67 ###############################################################################
68 # Subroutine: files()
69 ###############################################################################
70 # Returns the list of files that are installed by Alien::IE7.
71 ###############################################################################
72 1 ▶sub files {
Subroutine files: called CC=1 SCAR=0.0
Pod documented
73 1 my $class = shift;
74 1 my %blib = $class->to_blib();
75 1 return sort values %blib;
76 }
77  
78 ###############################################################################
79 # Subroutine: install($destdir)
80 # Parameters: $destdir - Destination directory
81 ###############################################################################
82 # Installs the IE7 compatibility library into the given '$destdir'. Throws a
83 # fatal exception on errors.
84 ###############################################################################
85 2 ▶sub install {
Subroutine install: called CC=5 SCAR=16.2
Pod documented
86 2 my ($class, $destdir) = @_;
87  
88 # install our files
89 2 my %blib = $class->to_blib();
90 2 ▶ while (my ($srcfile, $dest) = each %blib) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %blib) 54 2 56
91 # Get full path to destination file
92 54 my $destfile = File::Spec->catfile( $destdir, $dest );
93 # create any required install directories
94 54 my $instdir = dirname( $destfile );
95 54 ▶ if (!-d $instdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $instdir) 1 53 54
96 1 ▶ mkpath( $instdir ) || croak "can't create '$instdir'; $!";
Branch: 1 branch
BranchTrueFalseTotal
mkpath($instdir) or croak("can't create '${instdir}'; $!") 1 0 1
97 }
98 # install the file
99 54 ▶ copy( $srcfile, $destfile ) || croak "can't copy '$srcfile' to '$instdir'; $!";
Branch: 1 branch
BranchTrueFalseTotal
copy($srcfile, $destfile) or croak("can't copy '${srcfile}' to '${instdir}'; $!") 54 0 54
100 }
101 }
102  
103 3 1;
104  
105 =head1 NAME
106  
107 Alien::IE7 - (DEPRECATED) installing and finding IE7 JS compatibility library
108  
109 =head1 SYNOPSIS
110  
111 use Alien::IE7;
112 ...
113 $version = Alien::IE7->version();
114 $path = Alien::IE7->path();
115 ...
116 Alien::IE7->install( $my_destination_directory );
117  
118 =head1 DESCRIPTION
119  
120 B<DEPRECATED> - DO NOT USE
121  
122 Please see L<Alien> for the manifesto of the Alien namespace.
123  
124 =head1 METHODS
125  
126 =over
127  
128 =item version()
129  
130 Returns the IE7 version number.
131  
132 Not to be confused with the C<Alien::IE7> version number (which is the
133 version number of the Perl wrapper).
134  
135 =item path()
136  
137 Returns the path to the available copy of IE7.
138  
139 =item to_blib()
140  
141 Returns a hash containing paths to the source files to be copied, and their
142 relative destinations.
143  
144 =item files()
145  
146 Returns the list of files that are installed by Alien::IE7.
147  
148 =item install($destdir)
149  
150 Installs the IE7 compatibility library into the given C<$destdir>. Throws a
151 fatal exception on errors.
152  
153 =back
154  
155 =head1 AUTHOR
156  
157 Graham TerMarsch (cpan@howlingfrog.com)
158  
159 =head1 LICENSE
160  
161 Copyright (C) 2007, Graham TerMarsch. All rights reserved.
162  
163 This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
164  
165 =head1 SEE ALSO
166  
167 http://dean.edwards.name/ie7/
168 L<Alien>.
169  
170 =cut
↑ Summary