line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Prototype; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Required inclusions. |
5
|
|
|
|
|
|
|
############################################################################### |
6
|
2
|
|
|
2
|
|
63206
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
7
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
8
|
2
|
|
|
2
|
|
18
|
use Carp; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
829
|
|
9
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
10
|
2
|
|
|
2
|
|
2148
|
use File::Copy qw(copy); |
|
2
|
|
|
|
|
12761
|
|
|
2
|
|
|
|
|
145
|
|
11
|
2
|
|
|
2
|
|
17
|
use File::Path qw(mkpath); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
104
|
|
12
|
2
|
|
|
2
|
|
12
|
use File::Basename qw(dirname); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
980
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
############################################################################### |
15
|
|
|
|
|
|
|
# Version number. |
16
|
|
|
|
|
|
|
############################################################################### |
17
|
|
|
|
|
|
|
our $PROTOTYPE_VERSION = '1.6.0'; |
18
|
|
|
|
|
|
|
our $VERSION = '1.6.0.2'; |
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
|
8
|
my $base = $INC{'Alien/Prototype.pm'}; |
39
|
3
|
|
|
|
|
18
|
$base =~ s{\.pm$}{}; |
40
|
3
|
|
|
|
|
8
|
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
|
6
|
my $class = shift; |
51
|
3
|
|
|
|
|
10
|
my $path = $class->path(); |
52
|
3
|
|
|
|
|
7
|
my @files = (qw( prototype.js )); |
53
|
3
|
|
|
|
|
5
|
my %blib = map { (File::Spec->catfile($path,$_) => $_) } @files; |
|
3
|
|
|
|
|
75
|
|
54
|
3
|
|
|
|
|
15
|
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
|
17
|
my $class = shift; |
64
|
1
|
|
|
|
|
6
|
my %blib = $class->to_blib(); |
65
|
1
|
|
|
|
|
8
|
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
|
2436
|
my ($class, $destdir) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# install our files |
79
|
2
|
|
|
|
|
7
|
my %blib = $class->to_blib(); |
80
|
2
|
|
|
|
|
10
|
while (my ($srcfile, $dest) = each %blib) { |
81
|
|
|
|
|
|
|
# get full path to destination file |
82
|
2
|
|
|
|
|
18
|
my $destfile = File::Spec->catfile( $destdir, $dest ); |
83
|
|
|
|
|
|
|
# create any required install directories |
84
|
2
|
|
|
|
|
97
|
my $instdir = dirname( $destfile ); |
85
|
2
|
100
|
|
|
|
29
|
if (!-d $instdir) { |
86
|
1
|
50
|
|
|
|
181
|
mkpath( $instdir ) || croak "can't create '$instdir'; $!"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
# install the file |
89
|
2
|
50
|
|
|
|
12
|
copy( $srcfile, $destfile ) || croak "can't copy '$srcfile' to '$instdir'; $!"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Alien::Prototype - 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
|
|
|
|
|
|
|
Please see L for the manifesto of the Alien namespace. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item version() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Return the Prototype version number. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Not to be confused with the C version number (which is |
121
|
|
|
|
|
|
|
the version number of the Perl wrapper). |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item path() |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the path to the available copy of the Prototype JS library. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item to_blib() |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns a hash containing paths to the source files to be copied, and their |
130
|
|
|
|
|
|
|
relative destinations. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item files() |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns the list of files that are installed by Alien::Prototype. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item install($destdir) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Installs the Prototype JS library into the given C<$destdir>. Throws a |
139
|
|
|
|
|
|
|
fatal exception on errors. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Graham TerMarsch (cpan@howlingfrog.com) |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright (C) 2007, Graham TerMarsch. All rights reserved. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
http://www.prototypejs.org/, |
156
|
|
|
|
|
|
|
L. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |