blib/lib/Alien/Selenium.pm

filter: Statementstmt 100% 42 / 42 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 5 / 5 totaltotal 94.0% 63 / 67 CC 6 SCAR 6.2
CC
6
Cov
92%
install_readystate_xpi
3.1
install
3.0
path_readystate_xpi
2.0
CRAP 1.9
↑ Summary
1 package Alien::Selenium;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Alien::Selenium - installing and finding the Selenium Web test framework
13  
14 =head1 SYNOPSIS
15  
16 use Alien::Selenium;
17  
18 my $version = Alien::Selenium->version;
19 my $path = Alien::Selenium->path;
20  
21 Alien::Selenium->install( $destination_directory );
22  
23 =head1 DESCRIPTION
24  
25 Please see L<Alien> for the manifesto of the Alien namespace.
26  
27 =cut
28  
29 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 3 our $VERSION = '0.09';
32 3 our $SELENIUM_VERSION = '0.8.3';
33  
34 =over
35  
36 =item I<version ()>
37  
38 Returns the version of Selenium that is contained within this Alien
39 package (not to be confused with $Alien::Selenium::VERSION, which is
40 the version number of the Perl wrapper)
41  
42 =cut
43  
44 1 ▶sub version { $SELENIUM_VERSION }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
45  
46 =item I<path ()>
47  
48 Returns the path where a file-for-file copy of the Selenium core has
49 been installed as part of the Alien::Selenium Perl package. One may
50 direct one's webserver to serve files directly off I<path()>, or
51 alternatively use L</install>.
52  
53 =cut
54  
55 1 ▶sub path {
Subroutine path: called CC=1 SCAR=0.0
Pod documented
56 1 my $base = $INC{'Alien/Selenium.pm'};
57  
58 1 $base =~ s{\.pm$}{/javascript};
59  
60 1 return $base;
61 }
62  
63 =item I<install ($destdir)>
64  
65 Install a copy of the contents of L</path> into $dest_dir, which need
66 not exist beforehand.
67  
68 =cut
69  
70 1 ▶sub install {
Subroutine install: called CC=3 SCAR=11.0
Pod documented
71 1 my( $class, $dest_dir ) = @_;
72  
73 1 File::Path::mkpath $dest_dir;
74  
75 1 my $path = $class->path();
76 1 foreach my $f ( grep { -f $_ }
77 3 ▶ glob "$path/*" ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
78 13 ▶ File::Copy::copy( $f, $dest_dir )
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::copy($f, $dest_dir) or die "Can't copy $f to ${dest_dir}: $!" 13 0 13
79 or die "Can't copy $f to $dest_dir: $!";
80 }
81 }
82  
83 =item I<path_readystate_xpi ()>
84  
85 Returns the path to the C<readyState.xpi> Mozilla/Firefox extension
86 that is part of Selenium starting at version 0.8.0. Returns undef for
87 versions of Selenium that do not have such a file.
88  
89 =cut
90  
91 2 ▶sub path_readystate_xpi {
Subroutine path_readystate_xpi: called CC=2 SCAR=7.0
Pod documented
92 2 my $base = $INC{'Alien/Selenium.pm'};
93  
94 2 $base =~ s{\.pm$}{/xpi/readyState.xpi};
95 2 ▶ return if ! -f $base;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $base 0 2 2
96 2 return $base;
97 }
98  
99 =item I<install_readystate_xpi ($targetfile)>
100  
101 Installs the C<readyState.xpi> file as $targetfile, creating any
102 missing directories if needed. Croaks if there is no
103 C<readyState.xpi> in this version of Selenium (see
104 L</path_readystate_xpi>).
105  
106 =cut
107  
108 1 ▶sub install_readystate_xpi {
Subroutine install_readystate_xpi: called CC=3 SCAR=11.4
Pod documented
109 1 my ($class, $targetfile) = @_;
110  
111 1 ▶ die "no readyState.xpi in this version of Selenium ($SELENIUM_VERSION)"
Branch: 1 branch
BranchTrueFalseTotal
unless defined(my $srcfile = $class->path_readystate_xpi) 0 1 1
112 unless defined(my $srcfile = $class->path_readystate_xpi());
113  
114 1 File::Path::mkpath (dirname($targetfile));
115 1 ▶ File::Copy::copy($srcfile, $targetfile)
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::copy($srcfile, $targetfile) or die "Can't copy $srcfile to ${targetfile}: $!" 1 0 1
116 or die "Can't copy $srcfile to $targetfile: $!";
117 }
118  
119 =back
120  
121 =head1 AUTHOR
122  
123 Mattia Barbon <mbarbon@cpan.org>
124 Dominique Quatravaux <domq@cpan.org>
125  
126 =head1 LICENSE
127  
128 Copyright (c) 2005-2006 Mattia Barbon <mbarbon@cpan.org>
129  
130 This program is free software; you can redistribute it and/or
131 modify it under the same terms as Perl itself
132  
133 Please notice that Selenium comes with its own licence.
134  
135 =cut
136  
137 3 1;
↑ Summary