helpers now create .new files where files to be created already exist; -nonew option...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Helper.pm
1 package Catalyst::Helper;
2
3 use strict;
4 use base 'Class::Accessor::Fast';
5 use Config;
6 use File::Spec;
7 use File::Path;
8 use IO::File;
9 use FindBin;
10 use Template;
11 use Catalyst;
12 use Catalyst::Exception;
13
14 my %cache;
15
16 =head1 NAME
17
18 Catalyst::Helper - Bootstrap a Catalyst application
19
20 =head1 SYNOPSIS
21
22 See L<Catalyst::Manual::Intro>
23
24 =head1 DESCRIPTION
25
26 Bootstrap a Catalyst application. Autogenerates scripts
27
28 =head2 METHODS
29
30 =head3 get_file
31
32 Slurp file from DATA.
33
34 =cut
35
36 sub get_file {
37     my ( $self, $class, $file ) = @_;
38     unless ( $cache{$class} ) {
39         local $/;
40         $cache{$class} = eval "package $class; <DATA>";
41     }
42     my $data = $cache{$class};
43     my @files = split /^__(.+)__\n/m, $data;
44     shift @files;
45     while (@files) {
46         my ( $name, $content ) = splice @files, 0, 2;
47         return $content if $name eq $file;
48     }
49     return 0;
50 }
51
52 =head3 mk_app
53
54 Create the main application skeleton.
55
56 =cut
57
58 sub mk_app {
59     my ( $self, $name ) = @_;
60     return 0 if $name =~ /[^\w\:]/;
61     $self->{name} = $name;
62     $self->{dir}  = $name;
63     $self->{dir} =~ s/\:\:/-/g;
64     $self->{appprefix} = lc $self->{dir};
65     $self->{appprefix} =~ s/-/_/g;
66     $self->{startperl} = $Config{startperl};
67     $self->{scriptgen} = $Catalyst::CATALYST_SCRIPT_GEN || 4;
68     $self->{author}    = $self->{author} = $ENV{'AUTHOR'}
69       || eval { @{ [ getpwuid($<) ] }[6] }
70       || 'Catalyst developer';
71     $self->_mk_dirs;
72     $self->_mk_appclass;
73     $self->_mk_build;
74     $self->_mk_makefile;
75     $self->_mk_readme;
76     $self->_mk_changes;
77     $self->_mk_apptest;
78     $self->_mk_cgi;
79     $self->_mk_fastcgi;
80     $self->_mk_server;
81     $self->_mk_test;
82     $self->_mk_create;
83     return 1;
84 }
85
86 =head3 mk_component
87
88 This method is called by create.pl to make new components
89 for your application.
90
91 =cut
92
93 sub mk_component {
94     my $self = shift;
95     my $app  = shift;
96     $self->{app} = $app;
97     $self->{author} = $self->{author} = $ENV{'AUTHOR'}
98       || eval { @{ [ getpwuid($<) ] }[6] }
99       || 'A clever guy';
100     $self->{base} = File::Spec->catdir( $FindBin::Bin, '..' );
101     unless ( $_[0] =~ /^(?:model|m|view|v|controller|c)$/i ) {
102         my $helper = shift;
103         my @args   = @_;
104         my $class  = "Catalyst::Helper::$helper";
105         eval "require $class";
106         
107         if ( $@ ) {
108             Catalyst::Exception->throw( 
109                 message => qq/Couldn't load helper "$class", "$@"/
110             );
111         }
112         
113         if ( $class->can('mk_stuff') ) {
114             return 1 unless $class->mk_stuff( $self, @args );
115         }
116     }
117     else {
118         my $type   = shift;
119         my $name   = shift || "Missing name for model/view/controller";
120         my $helper = shift;
121         my @args   = @_;
122         return 0 if $name =~ /[^\w\:]/;
123         $type = 'M' if $type =~ /model|m/i;
124         $type = 'V' if $type =~ /view|v/i;
125         $type = 'C' if $type =~ /controller|c/i;
126         $self->{type}  = $type;
127         $self->{name}  = $name;
128         $self->{class} = "$app\::$type\::$name";
129
130         # Class
131         my $appdir = File::Spec->catdir( split /\:\:/, $app );
132         my $path =
133           File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, $type );
134         my $file = $name;
135         if ( $name =~ /\:/ ) {
136             my @path = split /\:\:/, $name;
137             $file = pop @path;
138             $path = File::Spec->catdir( $path, @path );
139             mkpath $path;
140         }
141         $file = File::Spec->catfile( $path, "$file.pm" );
142         $self->{file} = $file;
143
144         # Test
145         $self->{test_dir} = File::Spec->catdir( $FindBin::Bin, '..', 't' );
146         $self->{test}     = $self->next_test;
147
148         # Helper
149         if ($helper) {
150             my $comp = 'Model';
151             $comp = 'View'       if $type eq 'V';
152             $comp = 'Controller' if $type eq 'C';
153             my $class = "Catalyst::Helper::$comp\::$helper";
154             eval "require $class";
155             
156             if ( $@ ) {
157                 Catalyst::Exception->throw( 
158                     message => qq/Couldn't load helper "$class", "$@"/
159                 );
160             }            
161         
162             if ( $class->can('mk_compclass') ) {
163                 return 1 unless $class->mk_compclass( $self, @args );
164             }
165             else { return 1 unless $self->_mk_compclass }
166
167             if ( $class->can('mk_comptest') ) {
168                 $class->mk_comptest( $self, @args );
169             }
170             else { $self->_mk_comptest }
171         }
172
173         # Fallback
174         else {
175             return 1 unless $self->_mk_compclass;
176             $self->_mk_comptest;
177         }
178     }
179     return 1;
180 }
181
182 =head3 mk_dir
183
184 Surprisingly, this function makes a directory.
185
186 =cut
187
188 sub mk_dir {
189     my ( $self, $dir ) = @_;
190     if ( -d $dir ) {
191         print qq/ exists "$dir"\n/;
192         return 0;
193     }
194     if ( mkpath [$dir] ) {
195         print qq/created "$dir"\n/;
196         return 1;
197     }
198     
199     Catalyst::Exception->throw( 
200         message => qq/Couldn't create "$dir", "$!"/
201     );    
202 }
203
204 =head3 mk_file
205
206 writes content to a file.
207
208 =cut
209
210 sub mk_file {
211     my ( $self, $file, $content ) = @_;
212     if ( -e $file ) {
213         print qq/ exists "$file"\n/;
214         return 0 unless $self->{'.newfiles'};
215         if ( my $f = IO::File->new("< $file") ) {
216             my $oldcontent = join('', (<$f>));
217             return 0 if $content eq $oldcontent;
218         }
219         $file .= '.new';
220     }
221     if ( my $f = IO::File->new("> $file") ) {
222         print $f $content;
223         print qq/created "$file"\n/;
224         return 1;
225     }
226     
227     Catalyst::Exception->throw( 
228         message => qq/Couldn't create "$file", "$!"/
229     );       
230 }
231
232 =head3 next_test
233
234 =cut
235
236 sub next_test {
237     my ( $self, $tname ) = @_;
238     if ($tname) { $tname = "$tname.t" }
239     else {
240         my $name   = $self->{name};
241         my $prefix = $name;
242         $prefix =~ s/::/-/g;
243         $prefix         = $prefix;
244         $tname          = $prefix . '.t';
245         $self->{prefix} = $prefix;
246         $prefix = lc $prefix;
247         $prefix =~ s/-/\//g;
248         $self->{uri} = $prefix;
249     }
250     my $dir  = $self->{test_dir};
251     my $type = $self->{type};
252     return File::Spec->catfile( $dir, $type, $tname );
253 }
254
255 =head3 render_file
256
257 Render and create a file from a template in DATA using 
258 Template Toolkit.
259
260 =cut
261
262 sub render_file {
263     my ( $self, $file, $path, $vars ) = @_;
264     $vars ||= {};
265     my $t = Template->new;
266     my $template = $self->get_file( ( caller(0) )[0], $file );
267     return 0 unless $template;
268     my $output;
269     $t->process( \$template, { %{$self}, %$vars }, \$output );
270     $self->mk_file( $path, $output );
271 }
272
273 sub _mk_dirs {
274     my $self = shift;
275     $self->mk_dir( $self->{dir} );
276     $self->{script} = File::Spec->catdir( $self->{dir}, 'script' );
277     $self->mk_dir( $self->{script} );
278     $self->{lib} = File::Spec->catdir( $self->{dir}, 'lib' );
279     $self->mk_dir( $self->{lib} );
280     $self->{root} = File::Spec->catdir( $self->{dir}, 'root' );
281     $self->mk_dir( $self->{root} );
282     $self->{t} = File::Spec->catdir( $self->{dir}, 't' );
283     $self->mk_dir( $self->{t} );
284     $self->mk_dir( File::Spec->catdir( $self->{t}, 'M' ) );
285     $self->mk_dir( File::Spec->catdir( $self->{t}, 'V' ) );
286     $self->mk_dir( File::Spec->catdir( $self->{t}, 'C' ) );
287     $self->{class} = File::Spec->catdir( split( /\:\:/, $self->{name} ) );
288     $self->{mod} = File::Spec->catdir( $self->{lib}, $self->{class} );
289     $self->mk_dir( $self->{mod} );
290     $self->{m} = File::Spec->catdir( $self->{mod}, 'M' );
291     $self->mk_dir( $self->{m} );
292     $self->{v} = File::Spec->catdir( $self->{mod}, 'V' );
293     $self->mk_dir( $self->{v} );
294     $self->{c} = File::Spec->catdir( $self->{mod}, 'C' );
295     $self->mk_dir( $self->{c} );
296     $self->{base} = File::Spec->rel2abs( $self->{dir} );
297 }
298
299 sub _mk_appclass {
300     my $self = shift;
301     my $mod  = $self->{mod};
302     $self->render_file( 'appclass', "$mod.pm" );
303 }
304
305 sub _mk_build {
306     my $self = shift;
307     my $dir  = $self->{dir};
308     $self->render_file( 'build', "$dir\/Build.PL" );
309 }
310
311 sub _mk_makefile {
312     my $self = shift;
313     my $dir  = $self->{dir};
314     $self->render_file( 'makefile', "$dir\/Makefile.PL" );
315 }
316
317 sub _mk_readme {
318     my $self = shift;
319     my $dir  = $self->{dir};
320     $self->render_file( 'readme', "$dir\/README" );
321 }
322
323 sub _mk_changes {
324     my $self = shift;
325     my $dir  = $self->{dir};
326     my $time = localtime time;
327     $self->render_file( 'changes', "$dir\/Changes", { time => $time } );
328 }
329
330 sub _mk_apptest {
331     my $self = shift;
332     my $t    = $self->{t};
333     $self->render_file( 'apptest',         "$t\/01app.t" );
334     $self->render_file( 'podtest',         "$t\/02pod.t" );
335     $self->render_file( 'podcoveragetest', "$t\/03podcoverage.t" );
336 }
337
338 sub _mk_cgi {
339     my $self      = shift;
340     my $script    = $self->{script};
341     my $appprefix = $self->{appprefix};
342     $self->render_file( 'cgi', "$script\/$appprefix\_cgi.pl" );
343     chmod 0700, "$script/$appprefix\_cgi.pl";
344 }
345
346 sub _mk_fastcgi {
347     my $self      = shift;
348     my $script    = $self->{script};
349     my $appprefix = $self->{appprefix};
350     $self->render_file( 'fastcgi', "$script\/$appprefix\_fastcgi.pl" );
351     chmod 0700, "$script/$appprefix\_fastcgi.pl";
352 }
353
354 sub _mk_server {
355     my $self      = shift;
356     my $script    = $self->{script};
357     my $appprefix = $self->{appprefix};
358     $self->render_file( 'server', "$script\/$appprefix\_server.pl" );
359     chmod 0700, "$script/$appprefix\_server.pl";
360 }
361
362 sub _mk_test {
363     my $self      = shift;
364     my $script    = $self->{script};
365     my $appprefix = $self->{appprefix};
366     $self->render_file( 'test', "$script/$appprefix\_test.pl" );
367     chmod 0700, "$script/$appprefix\_test.pl";
368 }
369
370 sub _mk_create {
371     my $self      = shift;
372     my $script    = $self->{script};
373     my $appprefix = $self->{appprefix};
374     $self->render_file( 'create', "$script\/$appprefix\_create.pl" );
375     chmod 0700, "$script/$appprefix\_create.pl";
376 }
377
378 sub _mk_compclass {
379     my $self = shift;
380     my $file = $self->{file};
381     return $self->render_file( 'compclass', "$file" );
382 }
383
384 sub _mk_comptest {
385     my $self = shift;
386     my $test = $self->{test};
387     $self->render_file( 'comptest', "$test" );
388 }
389
390 =head1 HELPERS
391
392 Helpers are classes that provide two methods.
393
394     * mk_compclass - creates the Component class
395     * mk_comptest  - creates the Component test
396
397 So when you call C<bin/create view MyView TT>, create would try to execute
398 Catalyst::Helper::View::TT->mk_compclass and
399 Catalyst::Helper::View::TT->mk_comptest.
400
401 See L<Catalyst::Helper::View::TT> and L<Catalyst::Helper::Model::CDBI> for
402 examples.
403
404 All helper classes should be under one of the following namespaces.
405
406     Catalyst::Helper::Model::
407     Catalyst::Helper::View::
408     Catalyst::Helper::Controller::
409
410 =head1 NOTE
411
412 The helpers will read author name from /etc/passwd by default.
413 To override, please export the AUTHOR variable.
414
415 =head1 SEE ALSO
416
417 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
418 L<Catalyst::Response>, L<Catalyst>
419
420 =head1 AUTHOR
421
422 Sebastian Riedel, C<sri@oook.de>
423
424 =head1 LICENSE
425
426 This library is free software . You can redistribute it and/or modify
427 it under the same terms as perl itself.
428
429 =cut
430
431 1;
432 __DATA__
433
434 __appclass__
435 package [% name %];
436
437 use strict;
438 use Catalyst qw/-Debug/;
439
440 our $VERSION = '0.01';
441
442 [% name %]->config( name => '[% name %]' );
443
444 [% name %]->setup;
445
446 =head1 NAME
447
448 [% name %] - Catalyst based application
449
450 =head1 SYNOPSIS
451
452     script/[% appprefix %]_server.pl
453
454 =head1 DESCRIPTION
455
456 Catalyst based application.
457
458 =head1 METHODS
459
460 =over 4
461
462 =item default
463
464 =cut
465
466 sub default : Private {
467     my ( $self, $c ) = @_;
468     $c->res->output('Congratulations, [% name %] is on Catalyst!');
469 }
470
471 =back
472
473 =head1 AUTHOR
474
475 [%author%]
476
477 =head1 LICENSE
478
479 This library is free software . You can redistribute it and/or modify
480 it under the same terms as perl itself.
481
482 =cut
483
484 1;
485 __makefile__
486     unless ( eval "use Module::Build::Compat 0.02; 1" ) {
487         print "This module requires Module::Build to install itself.\n";
488
489         require ExtUtils::MakeMaker;
490         my $yn =
491           ExtUtils::MakeMaker::prompt( '  Install Module::Build now from CPAN?',            'y' );
492
493         unless ( $yn =~ /^y/i ) {
494             die " *** Cannot install without Module::Build.  Exiting ...\n";
495         }
496
497         require Cwd;
498         require File::Spec;
499         require CPAN;
500
501         # Save this 'cause CPAN will chdir all over the place.
502         my $cwd      = Cwd::cwd();
503         my $makefile = File::Spec->rel2abs($0);
504
505         CPAN::Shell->install('Module::Build::Compat')
506           or die " *** Cannot install without Module::Build.  Exiting ...\n";
507
508         chdir $cwd or die "Cannot chdir() back to $cwd: $!";
509     }
510     eval "use Module::Build::Compat 0.02; 1" or die $@;
511     use lib '_build/lib';
512     Module::Build::Compat->run_build_pl( args => \@ARGV );
513     require Module::Build;
514     Module::Build::Compat->write_makefile( build_class => 'Module::Build' );
515 __build__
516 use strict;
517 use Catalyst::Build;
518
519 my $build = Catalyst::Build->new(
520     create_makefile_pl => 'passthrough',
521     license            => 'perl',
522     module_name        => '[% name %]',
523     requires           => { Catalyst => '5.10' },
524     create_makefile_pl => 'passthrough',
525     script_files       => [ glob('script/*') ],
526     test_files         => [ glob('t/*.t'), glob('t/*/*.t') ]
527 );
528 $build->create_build_script;
529 __readme__
530 Run script/[% appprefix %]_server.pl to test the application.
531 __changes__
532 This file documents the revision history for Perl extension [% name %].
533 0.01  [% time %]
534         - initial revision, generated by Catalyst
535 __apptest__
536 use Test::More tests => 2;
537 use_ok( Catalyst::Test, '[% name %]' );
538
539 ok( request('/')->is_success );
540 __podtest__
541 use Test::More;
542
543 eval "use Test::Pod 1.14";
544 plan skip_all => 'Test::Pod 1.14 required' if $@;
545 plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
546
547 all_pod_files_ok();
548 __podcoveragetest__
549 use Test::More;
550
551 eval "use Test::Pod::Coverage 1.04";
552 plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
553 plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
554
555 all_pod_coverage_ok();
556 __cgi__
557 [% startperl %] -w
558
559 BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
560
561 use strict;
562 use FindBin;
563 use lib "$FindBin::Bin/../lib";
564 use [% name %];
565
566 [% name %]->run;
567
568 1;
569
570 =head1 NAME
571
572 [% appprefix %]_cgi.pl - Catalyst CGI
573
574 =head1 SYNOPSIS
575
576 See L<Catalyst::Manual>
577
578 =head1 DESCRIPTION
579
580 Run a Catalyst application as cgi.
581
582 =head1 AUTHOR
583
584 Sebastian Riedel, C<sri@oook.de>
585
586 =head1 COPYRIGHT
587
588 Copyright 2004 Sebastian Riedel. All rights reserved.
589
590 This library is free software. You can redistribute it and/or modify
591 it under the same terms as perl itself.
592
593 =cut
594 __fastcgi__
595 [% startperl %] -w
596
597 BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
598
599 use strict;
600 use FindBin;
601 use lib "$FindBin::Bin/../lib";
602 use [% name %];
603
604 [% name %]->run;
605
606 1;
607
608 =head1 NAME
609
610 [% appprefix %]_fastcgi.pl - Catalyst FastCGI
611
612 =head1 SYNOPSIS
613
614 See L<Catalyst::Manual>
615
616 =head1 DESCRIPTION
617
618 Run a Catalyst application as fastcgi.
619
620 =head1 AUTHOR
621
622 Sebastian Riedel, C<sri@oook.de>
623
624 =head1 COPYRIGHT
625
626 Copyright 2004 Sebastian Riedel. All rights reserved.
627
628 This library is free software. You can redistribute it and/or modify
629 it under the same terms as perl itself.
630
631 =cut
632 __server__
633 [% startperl %] -w
634
635 BEGIN { 
636     $ENV{CATALYST_ENGINE} ||= 'HTTP';
637     $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %];
638 }  
639
640 use strict;
641 use Getopt::Long;
642 use Pod::Usage;
643 use FindBin;
644 use lib "$FindBin::Bin/../lib";
645 use [% name %];
646
647 my $help = 0;
648 my $port = 3000;
649
650 GetOptions( 'help|?' => \$help, 'port=s' => \$port );
651
652 pod2usage(1) if $help;
653
654 [% name %]->run($port);
655
656 1;
657
658 =head1 NAME
659
660 [% appprefix %]_server.pl - Catalyst Testserver
661
662 =head1 SYNOPSIS
663
664 [% appprefix %]_server.pl [options]
665
666  Options:
667    -? -help    display this help and exits
668    -p -port    port (defaults to 3000)
669
670  See also:
671    perldoc Catalyst::Manual
672    perldoc Catalyst::Manual::Intro
673
674 =head1 DESCRIPTION
675
676 Run a Catalyst Testserver for this application.
677
678 =head1 AUTHOR
679
680 Sebastian Riedel, C<sri@oook.de>
681
682 =head1 COPYRIGHT
683
684 Copyright 2004 Sebastian Riedel. All rights reserved.
685
686 This library is free software. You can redistribute it and/or modify
687 it under the same terms as perl itself.
688
689 =cut
690 __test__
691 [% startperl %] -w
692
693 BEGIN { $ENV{CATALYST_ENGINE} ||= 'Test' }
694
695 use strict;
696 use Getopt::Long;
697 use Pod::Usage;
698 use FindBin;
699 use lib "$FindBin::Bin/../lib";
700 use [% name %];
701
702 my $help = 0;
703
704 GetOptions( 'help|?' => \$help );
705
706 pod2usage(1) if ( $help || !$ARGV[0] );
707
708 print [% name %]->run($ARGV[0])->content . "\n";
709
710 1;
711
712 =head1 NAME
713
714 [% appprefix %]_test.pl - Catalyst Test
715
716 =head1 SYNOPSIS
717
718 [% appprefix %]_test.pl [options] uri
719
720  Options:
721    -help    display this help and exits
722
723  Examples:
724    [% appprefix %]_test.pl http://localhost/some_action
725    [% appprefix %]_test.pl /some_action
726
727  See also:
728    perldoc Catalyst::Manual
729    perldoc Catalyst::Manual::Intro
730
731 =head1 DESCRIPTION
732
733 Run a Catalyst action from the comand line.
734
735 =head1 AUTHOR
736
737 Sebastian Riedel, C<sri@oook.de>
738
739 =head1 COPYRIGHT
740
741 Copyright 2004 Sebastian Riedel. All rights reserved.
742
743 This library is free software. You can redistribute it and/or modify
744 it under the same terms as perl itself.
745
746 =cut
747 __create__
748 [% startperl %] -w
749
750 use strict;
751 use Getopt::Long;
752 use Pod::Usage;
753 use Catalyst::Helper;
754
755 my $help = 0;
756 my $nonew = 0;
757
758 GetOptions( 'help|?' => \$help,
759             'nonew'  => \$nonew );
760
761 pod2usage(1) if ( $help || !$ARGV[0] );
762
763 my $helper = Catalyst::Helper->new({'.newfiles' => !$nonew});
764 pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
765
766 1;
767
768 =head1 NAME
769
770 [% appprefix %]_create.pl - Create a new Catalyst Component
771
772 =head1 SYNOPSIS
773
774 [% appprefix %]_create.pl [options] model|view|controller name [helper] [options]
775
776  Options:
777    -help    display this help and exits
778    -nonew   don't create a .new file where a file to be created exists
779
780  Examples:
781    [% appprefix %]_create.pl controller My::Controller
782    [% appprefix %]_create.pl view My::View
783    [% appprefix %]_create.pl view MyView TT
784    [% appprefix %]_create.pl view TT TT
785    [% appprefix %]_create.pl model My::Model
786    [% appprefix %]_create.pl model SomeDB CDBI dbi:SQLite:/tmp/my.db
787    [% appprefix %]_create.pl model AnotherDB CDBI dbi:Pg:dbname=foo root 4321
788
789  See also:
790    perldoc Catalyst::Manual
791    perldoc Catalyst::Manual::Intro
792
793 =head1 DESCRIPTION
794
795 Create a new Catalyst Component.
796
797 Existing component files are not overwritten.  If any of the component files
798 to be created already exist the file will be written with a '.new' suffix.
799 This behaviour can be supressed with the C<-nonew> option.
800
801 =head1 AUTHOR
802
803 Sebastian Riedel, C<sri\@oook.de>
804
805 =head1 COPYRIGHT
806
807 Copyright 2004 Sebastian Riedel. All rights reserved.
808
809 This library is free software. You can redistribute it and/or modify
810 it under the same terms as perl itself.
811
812 =cut
813 __compclass__
814 package [% class %];
815
816 use strict;
817 use base 'Catalyst::Base';
818
819 =head1 NAME
820
821 [% class %] - Catalyst component
822
823 =head1 SYNOPSIS
824
825 See L<[% app %]>
826
827 =head1 DESCRIPTION
828
829 Catalyst component.
830 [% IF type == 'C' %]
831 =head1 METHODS
832
833 =over 4
834
835 =item default
836
837 =cut
838
839 sub default : Private {
840     my ( $self, $c ) = @_;
841     $c->res->output('Congratulations, [% class %] is on Catalyst!');
842 }
843
844 =back
845
846 [% END %]
847 =head1 AUTHOR
848
849 [%author%]
850
851 =head1 LICENSE
852
853 This library is free software . You can redistribute it and/or modify
854 it under the same terms as perl itself.
855
856 =cut
857
858 1;
859 __comptest__
860 [% IF type == 'C' %]
861 use Test::More tests => 3;
862 use_ok( Catalyst::Test, '[% app %]' );
863 use_ok('[% class %]');
864
865 ok( request('[% uri %]')->is_success );
866 [% ELSE %]
867 use Test::More tests => 1;
868 use_ok('[% class %]');
869 [% END %]