File Coverage

blib/lib/Alien/IE7.pm
Criterion Covered Total %
statement 47 48 97.9
branch 6 8 75.0
condition n/a
subroutine 13 14 92.8
pod 5 5 100.0
total 71 75 94.6


line stmt bran cond sub pod time code
1             package Alien::IE7;
2              
3             ###############################################################################
4             # Required inclusions.
5             ###############################################################################
6 2     2   146824 use strict;
  2         12  
  2         59  
7 2     2   11 use warnings;
  2         4  
  2         47  
8 2     2   9 use Carp;
  2         4  
  2         113  
9 2     2   12 use File::Spec;
  2         4  
  2         48  
10 2     2   10 use File::Find qw(find);
  2         4  
  2         157  
11 2     2   1142 use File::Copy qw(copy);
  2         9319  
  2         131  
12 2     2   15 use File::Path qw(mkpath);
  2         3  
  2         123  
13 2     2   13 use File::Basename qw(basename dirname);
  2         3  
  2         1003  
14              
15             ###############################################################################
16             # Version numbering
17             ###############################################################################
18             our $IE7_VERSION = '0.9';
19             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             sub version {
30 0     0 1 0 return $IE7_VERSION;
31             }
32              
33             ###############################################################################
34             # Subroutine: path()
35             ###############################################################################
36             # Returns the path to the available copy of IE7.
37             ###############################################################################
38             sub path {
39 3     3 1 7 my $base = $INC{'Alien/IE7.pm'};
40 3         18 $base =~ s{\.pm$}{};
41 3         9 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             sub to_blib {
51 3     3 1 7 my $class = shift;
52 3         9 my $path = $class->path();
53 3         5 my %blib;
54             File::Find::find(
55             sub {
56 84 100   84   1339 -f && do {
57 81         227 my $dstdir = $File::Find::dir;
58 81         420 $dstdir =~ s{^$path/?}{};
59 81         608 $blib{$File::Find::name} = join('', $dstdir, $_);
60             }
61             },
62 3         264 $path
63             );
64 3         60 return %blib;
65             }
66              
67             ###############################################################################
68             # Subroutine: files()
69             ###############################################################################
70             # Returns the list of files that are installed by Alien::IE7.
71             ###############################################################################
72             sub files {
73 1     1 1 88 my $class = shift;
74 1         4 my %blib = $class->to_blib();
75 1         20 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             sub install {
86 2     2 1 9345 my ($class, $destdir) = @_;
87              
88             # install our files
89 2         8 my %blib = $class->to_blib();
90 2         13 while (my ($srcfile, $dest) = each %blib) {
91             # Get full path to destination file
92 54         16415 my $destfile = File::Spec->catfile( $destdir, $dest );
93             # create any required install directories
94 54         1502 my $instdir = dirname( $destfile );
95 54 100       910 if (!-d $instdir) {
96 1 50       170 mkpath( $instdir ) || croak "can't create '$instdir'; $!";
97             }
98             # install the file
99 54 50       228 copy( $srcfile, $destfile ) || croak "can't copy '$srcfile' to '$instdir'; $!";
100             }
101             }
102              
103             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 - DO NOT USE
121              
122             Please see L 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 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.
169              
170             =cut