added: passthrough makefile.pl compat for Catalyst and helpers.
[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;
adfe7ead 110 my $name = shift || "Missing name for model/view/controller";
111 my $helper = shift ;
b5524568 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 %]',
809fd1e0 455 requires => { Catalyst => '5.10' },
adfe7ead 456 create_makefile_pl => 'passthrough',
4f6748f1 457 script_files => [ glob('script/*') ],
458 test_files => [ glob('t/*.t'), glob('t/*/*.t') ]
fc7ec1d9 459);
4f6748f1 460$build->create_build_script;
fc7ec1d9 461
61cfdd57 462__readme__
4f6748f1 463Run script/[% apprefix %]_server.pl to test the application.
91864987 464
61cfdd57 465__changes__
7a870961 466This file documents the revision history for Perl extension [% name %].
91864987 467
61cfdd57 4680.01 [% time %]
91864987 469 - initial revision, generated by Catalyst
91864987 470
61cfdd57 471__apptest__
fc7ec1d9 472use Test::More tests => 2;
61cfdd57 473use_ok( Catalyst::Test, '[% name %]' );
fc7ec1d9 474
475ok( request('/')->is_success );
61cfdd57 476
477__podtest__
5a8fd7e9 478use Test::More;
479
480eval "use Test::Pod 1.14";
61cfdd57 481plan skip_all => 'Test::Pod 1.14 required' if $@;
482plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
5a8fd7e9 483
484all_pod_files_ok();
61cfdd57 485
486__podcoveragetest__
1df125c9 487use Test::More;
488
489eval "use Test::Pod::Coverage 1.04";
61cfdd57 490plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
491plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
1df125c9 492
493all_pod_coverage_ok();
fc7ec1d9 494
195631f4 495__cgi__
61cfdd57 496[% startperl %] -w
497BEGIN { $ENV{CATALYST_ENGINE} = 'CGI' }
d8ab1b45 498
499use strict;
500use FindBin;
61cfdd57 501use lib "$FindBin::Bin/../lib";
502use [% name %];
d8ab1b45 503
61cfdd57 504[% name %]->run;
d8ab1b45 505
5061;
d8ab1b45 507
508=head1 NAME
509
510cgi - Catalyst CGI
511
512=head1 SYNOPSIS
513
514See L<Catalyst::Manual>
515
516=head1 DESCRIPTION
517
518Run a Catalyst application as cgi.
519
520=head1 AUTHOR
521
61cfdd57 522Sebastian Riedel, C<sri@oook.de>
d8ab1b45 523
524=head1 COPYRIGHT
525
526Copyright 2004 Sebastian Riedel. All rights reserved.
527
b160463f 528This library is free software. You can redistribute it and/or modify
529it under the same terms as perl itself.
d8ab1b45 530
531=cut
d8ab1b45 532
61cfdd57 533__fcgi__
534[% startperl %] -w
cb8d90e5 535
61cfdd57 536BEGIN { $ENV{CATALYST_ENGINE} = 'FCGI' }
cb8d90e5 537
538use strict;
539use FindBin;
61cfdd57 540use lib "$FindBin::Bin/../lib";
541use [% name %];
cb8d90e5 542
61cfdd57 543[% name %]->run;
cb8d90e5 544
5451;
cb8d90e5 546
547=head1 NAME
548
549fcgi - Catalyst FCGI
550
551=head1 SYNOPSIS
552
553See L<Catalyst::Manual>
554
555=head1 DESCRIPTION
556
557Run a Catalyst application as fcgi.
558
559=head1 AUTHOR
560
61cfdd57 561Sebastian Riedel, C<sri@oook.de>
cb8d90e5 562
563=head1 COPYRIGHT
564
565Copyright 2004 Sebastian Riedel. All rights reserved.
566
b160463f 567This library is free software. You can redistribute it and/or modify
568it under the same terms as perl itself.
cb8d90e5 569
570=cut
cb8d90e5 571
61cfdd57 572__server__
573[% startperl %] -w
fc7ec1d9 574
42a57832 575BEGIN {
576 $ENV{CATALYST_ENGINE} = 'HTTP';
577 $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %];
578}
585893b9 579
fc7ec1d9 580use strict;
581use Getopt::Long;
582use Pod::Usage;
583use FindBin;
61cfdd57 584use lib "$FindBin::Bin/../lib";
585use [% name %];
fc7ec1d9 586
61cfdd57 587my $help = 0;
588my $port = 3000;
fc7ec1d9 589
61cfdd57 590GetOptions( 'help|?' => \$help, 'port=s' => \$port );
fc7ec1d9 591
195631f4 592pod2usage(1) if $help;
fc7ec1d9 593
61cfdd57 594[% name %]->run($port);
fc7ec1d9 595
5961;
fc7ec1d9 597
598=head1 NAME
599
600server - Catalyst Testserver
601
602=head1 SYNOPSIS
603
91864987 604server.pl [options]
fc7ec1d9 605
606 Options:
ad41e777 607 -? -help display this help and exits
608 -p -port port (defaults to 3000)
fc7ec1d9 609
03a53815 610 See also:
611 perldoc Catalyst::Manual
612 perldoc Catalyst::Manual::Intro
613
fc7ec1d9 614=head1 DESCRIPTION
615
616Run a Catalyst Testserver for this application.
617
618=head1 AUTHOR
619
61cfdd57 620Sebastian Riedel, C<sri@oook.de>
fc7ec1d9 621
622=head1 COPYRIGHT
623
624Copyright 2004 Sebastian Riedel. All rights reserved.
625
b160463f 626This library is free software. You can redistribute it and/or modify
627it under the same terms as perl itself.
fc7ec1d9 628
629=cut
fc7ec1d9 630
61cfdd57 631__test__
632[% startperl %] -w
fc7ec1d9 633
61cfdd57 634BEGIN { $ENV{CATALYST_ENGINE} = 'Test' }
e646f111 635
fc7ec1d9 636use strict;
637use Getopt::Long;
638use Pod::Usage;
639use FindBin;
61cfdd57 640use lib "$FindBin::Bin/../lib";
641use [% name %];
fc7ec1d9 642
61cfdd57 643my $help = 0;
fc7ec1d9 644
61cfdd57 645GetOptions( 'help|?' => \$help );
fc7ec1d9 646
61cfdd57 647pod2usage(1) if ( $help || !$ARGV[0] );
fc7ec1d9 648
61cfdd57 649print [% name %]->run($ARGV[0])->content . "\n";
fc7ec1d9 650
6511;
fc7ec1d9 652
653=head1 NAME
654
655test - Catalyst Test
656
657=head1 SYNOPSIS
658
91864987 659test.pl [options] uri
fc7ec1d9 660
661 Options:
662 -help display this help and exits
663
664 Examples:
91864987 665 test.pl http://localhost/some_action
666 test.pl /some_action
fc7ec1d9 667
03a53815 668 See also:
669 perldoc Catalyst::Manual
670 perldoc Catalyst::Manual::Intro
671
fc7ec1d9 672=head1 DESCRIPTION
673
674Run a Catalyst action from the comand line.
675
676=head1 AUTHOR
677
61cfdd57 678Sebastian Riedel, C<sri@oook.de>
fc7ec1d9 679
680=head1 COPYRIGHT
681
682Copyright 2004 Sebastian Riedel. All rights reserved.
683
b160463f 684This library is free software. You can redistribute it and/or modify
685it under the same terms as perl itself.
fc7ec1d9 686
687=cut
fc7ec1d9 688
61cfdd57 689__create__
690[% startperl %] -w
fc7ec1d9 691
692use strict;
693use Getopt::Long;
694use Pod::Usage;
695use Catalyst::Helper;
696
61cfdd57 697my $help = 0;
fc7ec1d9 698
699GetOptions( 'help|?' => \$help );
700
61cfdd57 701pod2usage(1) if ( $help || !$ARGV[0] );
fc7ec1d9 702
61cfdd57 703my $helper = Catalyst::Helper->new;
704pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
fc7ec1d9 705
7061;
fc7ec1d9 707
708=head1 NAME
709
710create - Create a new Catalyst Component
711
712=head1 SYNOPSIS
713
91864987 714create.pl [options] model|view|controller name [helper] [options]
fc7ec1d9 715
716 Options:
717 -help display this help and exits
718
719 Examples:
91864987 720 create.pl controller My::Controller
721 create.pl view My::View
722 create.pl view MyView TT
723 create.pl view TT TT
724 create.pl model My::Model
725 create.pl model SomeDB CDBI dbi:SQLite:/tmp/my.db
726 create.pl model AnotherDB CDBI dbi:Pg:dbname=foo root 4321
b5524568 727 create.pl Ajax
03a53815 728
729 See also:
730 perldoc Catalyst::Manual
731 perldoc Catalyst::Manual::Intro
fc7ec1d9 732
733=head1 DESCRIPTION
734
735Create a new Catalyst Component.
736
737=head1 AUTHOR
738
739Sebastian Riedel, C<sri\@oook.de>
740
741=head1 COPYRIGHT
742
743Copyright 2004 Sebastian Riedel. All rights reserved.
744
b160463f 745This library is free software. You can redistribute it and/or modify
746it under the same terms as perl itself.
fc7ec1d9 747
748=cut
fc7ec1d9 749
61cfdd57 750__compclass__
751package [% class %];
752
753use strict;
754use base 'Catalyst::Base';
fc7ec1d9 755
61cfdd57 756[% IF type == 'C' %]
5a8ed4fe 757sub default : Private {
ffa15401 758 my ( $self, $c ) = @_;
61cfdd57 759 $c->res->output('Congratulations, [% class %] is on Catalyst!');
5a8ed4fe 760}
fc7ec1d9 761
61cfdd57 762[% END %]
fc7ec1d9 763=head1 NAME
764
61cfdd57 765[% class %] - A Component
fc7ec1d9 766
767=head1 SYNOPSIS
768
769 Very simple to use
770
771=head1 DESCRIPTION
772
773Very nice component.
774
775=head1 AUTHOR
776
ddb46924 777[%author%]
fc7ec1d9 778
779=head1 LICENSE
780
b160463f 781This library is free software . You can redistribute it and/or modify
782it under the same terms as perl itself.
fc7ec1d9 783
784=cut
785
7861;
fc7ec1d9 787
61cfdd57 788__comptest__
789[% IF type == 'C' %]
fc7ec1d9 790use Test::More tests => 3;
61cfdd57 791use_ok( Catalyst::Test, '[% app %]' );
792use_ok('[% class %]');
fc7ec1d9 793
61cfdd57 794ok( request('[% prefix %]')->is_success );
795[% ELSE %]
fc7ec1d9 796use Test::More tests => 1;
61cfdd57 797use_ok('[% class %]');
798[% END %]