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