File Coverage

lib/Egg/Helper/Build/Prototype.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 6 0.0
condition 0 4 0.0
subroutine 4 6 66.6
pod n/a
total 16 44 36.3


line stmt bran cond sub pod time code
1             package Egg::Helper::Build::Prototype;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: Prototype.pm 337 2008-05-14 12:30:09Z lushe $
6             #
7 1     1   440 use strict;
  1         3  
  1         37  
8 1     1   6 use warnings;
  1         2  
  1         28  
9 1     1   6 use File::Spec;
  1         4  
  1         8  
10 1     1   21 use HTML::Prototype;
  1         3  
  1         13  
11              
12             our $VERSION= '3.00';
13              
14             sub _start_helper {
15 0     0     my($self)= @_;
16 0           my $c= $self->config;
17 0           my $o= $self->_helper_get_options;
18 0 0         return $self->_helper_help() if $o->{help};
19              
20 0   0       my $htdocs= $c->{dir}{htdocs} || $c->{dir}{static}
21             || return $self->_helper_help('I want configuration dir->{htdocs}.');
22 0 0         -e $htdocs
23             || return $self->_helper_help("'$htdocs' is not found.");
24              
25 0           my $prototype = File::Spec->catfile( $htdocs, 'prototype.js' );
26 0           my $controls = File::Spec->catfile( $htdocs, 'controls.js' );
27 0           my $dragdrop = File::Spec->catfile( $htdocs, 'dragdrop.js' );
28 0           my $complete = <<END_INFO;
29              
30             ... completed.
31              
32             prototype.js : $prototype
33             controls.js : $controls
34             dragdrop.js : $dragdrop
35              
36             END_INFO
37              
38 0           $self->helper_generate_files(
39             param => {}, chdir => [$c->{root}],
40             complete_msg => $complete,
41             create_files => [
42             { filename=> $prototype, value=> $HTML::Prototype::prototype },
43             { filename=> $controls, value=> $HTML::Prototype::controls },
44             { filename=> $dragdrop, value=> $HTML::Prototype::controls },
45             ],
46             );
47             }
48             sub _helper_help {
49 0     0     my $self = shift;
50 0   0       my $msg = shift || "";
51 0 0         $msg .= "\n\n" if $msg;
52 0           my $pname= lc $self->project_name;
53 0           print <<END_HELP;
54             ${msg}% perl ${pname}_helper.pl Plugin::Prototype [-h]
55              
56             END_HELP
57             }
58              
59             1;
60              
61             __END__
62              
63             =head1 NAME
64              
65             Egg::Helper::Build::Prototype - Helper who outputs prototype.js
66              
67             =head1 SYNOPSIS
68              
69             % cd /path/to/MyApp/bin
70             % ./myapp_helper Build::Prototype
71              
72             =head1 DESCRIPTION
73              
74             It is a helper according to HTML::Prototype to whom the project outputs 'htdocs'
75             below as for 'prototype.js' etc.
76              
77             The usage only specifies 'Build::Prototype' and the mode for the helper script
78             of the project.
79              
80             =head1 SEE ALSO
81              
82             L<Egg::Release>,
83             L<Egg::Helper>,
84             L<Egg::Plugin::Prototype>,
85             L<HTML::Prototype>,
86             L<File::Spec>,
87              
88             =head1 AUTHOR
89              
90             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>.
95              
96             This library is free software; you can redistribute it and/or modify
97             it under the same terms as Perl itself, either Perl version 5.8.6 or,
98             at your option, any later version of Perl 5 you may have available.
99              
100             =cut
101