| 1 | package Alien::Prototype::Carousel; | ||||||||||
| 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::Copy qw(copy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use File::Path qw(mkpath); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use File::Basename qw(dirname); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 3 | ▶ | use Alien::scriptaculous; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | ############################################################################### | ||||||||||
| 16 | # Version number | ||||||||||
| 17 | ############################################################################### | ||||||||||
| 18 | 3 | our $CAROUSEL_VERSION = '0.26'; | |||||||||
| 19 | 3 | our $VERSION = '0.26.4'; | |||||||||
| 20 | |||||||||||
| 21 | ############################################################################### | ||||||||||
| 22 | # Subroutine: version() | ||||||||||
| 23 | ############################################################################### | ||||||||||
| 24 | # Return the Prototype Carousel component version number. | ||||||||||
| 25 | # | ||||||||||
| 26 | # Not to be confused with the 'Alien::Prototype::Carousel' version number | ||||||||||
| 27 | # (which is the version number of the Perl wrapper). | ||||||||||
| 28 | ############################################################################### | ||||||||||
| 29 | 0 | ▶ | sub version { | ||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 0 | return $CAROUSEL_VERSION; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | ############################################################################### | ||||||||||
| 34 | # Subroutine: path() | ||||||||||
| 35 | ############################################################################### | ||||||||||
| 36 | # Returns the path to the available copy of the Prototype Carousel component. | ||||||||||
| 37 | ############################################################################### | ||||||||||
| 38 | 3 | ▶ | sub path { | ||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 3 | my $base = $INC{'Alien/Prototype/Carousel.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 @files = qw( carousel.js carousel.css ); | |||||||||
| 54 | 3 | my %blib = map { (File::Spec->catfile($path,$_) => $_) } @files; | |||||||||
| 55 | 3 | return %blib; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | ############################################################################### | ||||||||||
| 59 | # Subroutine: files() | ||||||||||
| 60 | ############################################################################### | ||||||||||
| 61 | # Returns the list of files that are installed by Alien::Prototype::Carousel. | ||||||||||
| 62 | ############################################################################### | ||||||||||
| 63 | 1 | ▶ | sub files { | ||||||||
|
Subroutine
files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 64 | 1 | my $class = shift; | |||||||||
| 65 | 1 | my %blib = $class->to_blib(); | |||||||||
| 66 | 1 | return sort values %blib; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | ############################################################################### | ||||||||||
| 70 | # Subroutine: install($destdir) | ||||||||||
| 71 | # Parameters: $destdir - Destination directory. | ||||||||||
| 72 | ############################################################################### | ||||||||||
| 73 | # Installs the Prototype Carousel component into the given '$destdir'. Throws | ||||||||||
| 74 | # a fatal exception on errors. | ||||||||||
| 75 | ############################################################################### | ||||||||||
| 76 | 2 | ▶ | sub install { | ||||||||
|
Subroutine
install: called CC=5 SCAR=17.3
Pod
documented
| |||||||||||
| 77 | 2 | my ($class, $destdir) = @_; | |||||||||
| 78 | |||||||||||
| 79 | # install script.aculo.us | ||||||||||
| 80 | 2 | Alien::scriptaculous->install( $destdir ); | |||||||||
| 81 | |||||||||||
| 82 | # install our files | ||||||||||
| 83 | 2 | my %blib = $class->to_blib(); | |||||||||
| 84 | 2 | ▶ | while (my ($srcfile, $dest) = each %blib) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | # get full path to destination file | ||||||||||
| 86 | 4 | my $destfile = File::Spec->catfile( $destdir, $dest ); | |||||||||
| 87 | # create any required install directories | ||||||||||
| 88 | 4 | my $instdir = dirname( $destfile ); | |||||||||
| 89 | 4 | ▶ | if (!-d $instdir) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | ▶ | mkpath( $instdir ) || croak "can't create '$instdir'; $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | } | ||||||||||
| 92 | # install the file | ||||||||||
| 93 | 4 | ▶ | copy( $srcfile, $destfile ) || croak "can't copy '$srcfile' to '$instdir'; $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | } | ||||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 3 | 1; | |||||||||
| 98 | |||||||||||
| 99 | =head1 NAME | ||||||||||
| 100 | |||||||||||
| 101 | Alien::Prototype::Carousel - (DEPRECATED) installing and finding Prototype Carousel component | ||||||||||
| 102 | |||||||||||
| 103 | =head1 SYNOPSIS | ||||||||||
| 104 | |||||||||||
| 105 | use Alien::Prototype::Carousel; | ||||||||||
| 106 | ... | ||||||||||
| 107 | $version = Alien::Prototype::Carousel->version(); | ||||||||||
| 108 | $path = Alien::Prototype::Carousel->path(); | ||||||||||
| 109 | ... | ||||||||||
| 110 | Alien::Prototype::Carousel->install( $my_destination_directory ); | ||||||||||
| 111 | |||||||||||
| 112 | =head1 DESCRIPTION | ||||||||||
| 113 | |||||||||||
| 114 | B<DEPRECATED> - DO NOT USE | ||||||||||
| 115 | |||||||||||
| 116 | Please see L<Alien> for the manifesto of the Alien namespace. | ||||||||||
| 117 | |||||||||||
| 118 | =head1 METHODS | ||||||||||
| 119 | |||||||||||
| 120 | =over | ||||||||||
| 121 | |||||||||||
| 122 | =item version() | ||||||||||
| 123 | |||||||||||
| 124 | Return the Prototype Carousel component version number. | ||||||||||
| 125 | |||||||||||
| 126 | Not to be confused with the C<Alien::Prototype::Carousel> version number | ||||||||||
| 127 | (which is the version number of the Perl wrapper). | ||||||||||
| 128 | |||||||||||
| 129 | =item path() | ||||||||||
| 130 | |||||||||||
| 131 | Returns the path to the available copy of the Prototype Carousel component. | ||||||||||
| 132 | |||||||||||
| 133 | =item to_blib() | ||||||||||
| 134 | |||||||||||
| 135 | Returns a hash containing paths to the source files to be copied, and their | ||||||||||
| 136 | relative destinations. | ||||||||||
| 137 | |||||||||||
| 138 | =item files() | ||||||||||
| 139 | |||||||||||
| 140 | Returns the list of files that are installed by Alien::Prototype::Carousel. | ||||||||||
| 141 | |||||||||||
| 142 | =item install($destdir) | ||||||||||
| 143 | |||||||||||
| 144 | Installs the Prototype Carousel component into the given C<$destdir>. | ||||||||||
| 145 | Throws a fatal exception on errors. | ||||||||||
| 146 | |||||||||||
| 147 | =back | ||||||||||
| 148 | |||||||||||
| 149 | =head1 AUTHOR | ||||||||||
| 150 | |||||||||||
| 151 | Graham TerMarsch (cpan@howlingfrog.com) | ||||||||||
| 152 | |||||||||||
| 153 | =head1 LICENSE | ||||||||||
| 154 | |||||||||||
| 155 | Copyright (C) 2007, Graham TerMarsch. All rights reserved. | ||||||||||
| 156 | |||||||||||
| 157 | This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 158 | |||||||||||
| 159 | =head1 SEE ALSO | ||||||||||
| 160 | |||||||||||
| 161 | http://prototype-carousel.xilinus.com/, | ||||||||||
| 162 | L<Alien::scriptaculous>, | ||||||||||
| 163 | L<Alien>. | ||||||||||
| 164 | |||||||||||
| 165 | =cut | ||||||||||