| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::Prototype; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | ############################################################################### | 
| 4 |  |  |  |  |  |  | # Required inclusions. | 
| 5 |  |  |  |  |  |  | ############################################################################### | 
| 6 | 2 |  |  | 2 |  | 149044 | use strict; | 
|  | 2 |  |  |  |  | 13 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 7 | 2 |  |  | 2 |  | 11 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 44 |  | 
| 8 | 2 |  |  | 2 |  | 10 | use Carp; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 110 |  | 
| 9 | 2 |  |  | 2 |  | 13 | use File::Spec; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 47 |  | 
| 10 | 2 |  |  | 2 |  | 1141 | use File::Copy qw(copy); | 
|  | 2 |  |  |  |  | 9422 |  | 
|  | 2 |  |  |  |  | 122 |  | 
| 11 | 2 |  |  | 2 |  | 16 | use File::Path qw(mkpath); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 91 |  | 
| 12 | 2 |  |  | 2 |  | 13 | use File::Basename qw(dirname); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 930 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | ############################################################################### | 
| 15 |  |  |  |  |  |  | # Version number. | 
| 16 |  |  |  |  |  |  | ############################################################################### | 
| 17 |  |  |  |  |  |  | our $PROTOTYPE_VERSION = '1.6.0'; | 
| 18 |  |  |  |  |  |  | our $VERSION = '1.6.0.3'; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | ############################################################################### | 
| 21 |  |  |  |  |  |  | # Subroutine:   version() | 
| 22 |  |  |  |  |  |  | ############################################################################### | 
| 23 |  |  |  |  |  |  | # Return the Prototype version number. | 
| 24 |  |  |  |  |  |  | # | 
| 25 |  |  |  |  |  |  | # Not to be confused with the 'Alien::Prototype' version number (which is the | 
| 26 |  |  |  |  |  |  | # version number of the Perl wrapper). | 
| 27 |  |  |  |  |  |  | ############################################################################### | 
| 28 |  |  |  |  |  |  | sub version { | 
| 29 | 0 |  |  | 0 | 1 | 0 | return $PROTOTYPE_VERSION; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | ############################################################################### | 
| 33 |  |  |  |  |  |  | # Subroutine:   path() | 
| 34 |  |  |  |  |  |  | ############################################################################### | 
| 35 |  |  |  |  |  |  | # Returns the path to the available copy of the Prototype JS library. | 
| 36 |  |  |  |  |  |  | ############################################################################### | 
| 37 |  |  |  |  |  |  | sub path { | 
| 38 | 3 |  |  | 3 | 1 | 7 | my $base = $INC{'Alien/Prototype.pm'}; | 
| 39 | 3 |  |  |  |  | 19 | $base =~ s{\.pm$}{}; | 
| 40 | 3 |  |  |  |  | 7 | return $base; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | ############################################################################### | 
| 44 |  |  |  |  |  |  | # Subroutine:   to_blib() | 
| 45 |  |  |  |  |  |  | ############################################################################### | 
| 46 |  |  |  |  |  |  | # Returns a hash containing paths to the source files to be copied, and their | 
| 47 |  |  |  |  |  |  | # relative destinations. | 
| 48 |  |  |  |  |  |  | ############################################################################### | 
| 49 |  |  |  |  |  |  | sub to_blib { | 
| 50 | 3 |  |  | 3 | 1 | 7 | my $class = shift; | 
| 51 | 3 |  |  |  |  | 8 | my $path  = $class->path(); | 
| 52 | 3 |  |  |  |  | 10 | my @files = (qw( prototype.js )); | 
| 53 | 3 |  |  |  |  | 7 | my %blib  = map { (File::Spec->catfile($path,$_) => $_) } @files; | 
|  | 3 |  |  |  |  | 44 |  | 
| 54 | 3 |  |  |  |  | 16 | return %blib; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | ############################################################################### | 
| 58 |  |  |  |  |  |  | # Subroutine:   files() | 
| 59 |  |  |  |  |  |  | ############################################################################### | 
| 60 |  |  |  |  |  |  | # Returns the list of files that are installed by Alien::Prototype. | 
| 61 |  |  |  |  |  |  | ############################################################################### | 
| 62 |  |  |  |  |  |  | sub files { | 
| 63 | 1 |  |  | 1 | 1 | 85 | my $class = shift; | 
| 64 | 1 |  |  |  |  | 6 | my %blib  = $class->to_blib(); | 
| 65 | 1 |  |  |  |  | 6 | return sort values %blib; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | ############################################################################### | 
| 69 |  |  |  |  |  |  | # Subroutine:   install($destdir) | 
| 70 |  |  |  |  |  |  | # Parameters:   $destdir        - Destination directory | 
| 71 |  |  |  |  |  |  | ############################################################################### | 
| 72 |  |  |  |  |  |  | # Installs the Prototype JS library into the given '$destdir'.  Throws a fatal | 
| 73 |  |  |  |  |  |  | # exception on errors. | 
| 74 |  |  |  |  |  |  | ############################################################################### | 
| 75 |  |  |  |  |  |  | sub install { | 
| 76 | 2 |  |  | 2 | 1 | 1944 | my ($class, $destdir) = @_; | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | # install our files | 
| 79 | 2 |  |  |  |  | 17 | my %blib = $class->to_blib(); | 
| 80 | 2 |  |  |  |  | 12 | while (my ($srcfile, $dest) = each %blib) { | 
| 81 |  |  |  |  |  |  | # get full path to destination file | 
| 82 | 2 |  |  |  |  | 12 | my $destfile = File::Spec->catfile( $destdir, $dest ); | 
| 83 |  |  |  |  |  |  | # create any required install directories | 
| 84 | 2 |  |  |  |  | 107 | my $instdir = dirname( $destfile ); | 
| 85 | 2 | 100 |  |  |  | 35 | if (!-d $instdir) { | 
| 86 | 1 | 50 |  |  |  | 171 | mkpath( $instdir ) || croak "can't create '$instdir'; $!"; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  | # install the file | 
| 89 | 2 | 50 |  |  |  | 13 | copy( $srcfile, $destfile ) || croak "can't copy '$srcfile' to '$instdir'; $!"; | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | 1; | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =head1 NAME | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | Alien::Prototype - (DEPRECATED) installing and finding Prototype JS library | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | use Alien::Prototype; | 
| 102 |  |  |  |  |  |  | ... | 
| 103 |  |  |  |  |  |  | $version = Alien::Prototype->version(); | 
| 104 |  |  |  |  |  |  | $path    = Alien::Prototype->path(); | 
| 105 |  |  |  |  |  |  | ... | 
| 106 |  |  |  |  |  |  | Alien::Prototype->install( $my_destination_directory ); | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | B - DO NOT USE | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | Please see L for the manifesto of the Alien namespace. | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head1 METHODS | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =over | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =item version() | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | Return the Prototype version number. | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Not to be confused with the C version number (which is | 
| 123 |  |  |  |  |  |  | the version number of the Perl wrapper). | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =item path() | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | Returns the path to the available copy of the Prototype JS library. | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =item to_blib() | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | Returns a hash containing paths to the source files to be copied, and their | 
| 132 |  |  |  |  |  |  | relative destinations. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =item files() | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | Returns the list of files that are installed by Alien::Prototype. | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =item install($destdir) | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Installs the Prototype JS library into the given C<$destdir>. Throws a | 
| 141 |  |  |  |  |  |  | fatal exception on errors. | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =back | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =head1 AUTHOR | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | Graham TerMarsch (cpan@howlingfrog.com) | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =head1 LICENSE | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | Copyright (C) 2007, Graham TerMarsch.  All rights reserved. | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | http://www.prototypejs.org/, | 
| 158 |  |  |  |  |  |  | L. | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | =cut |