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