$self->{prefix} = $prefix;
$prefix = lc $prefix;
$prefix =~ s/-/\//g;
- $self->{uri} = $prefix;
+ $self->{uri} = "/$prefix";
}
my $dir = $self->{test_dir};
my $type = lc $self->{type};
Catalyst::Helper::View::TT->mk_compclass and
Catalyst::Helper::View::TT->mk_comptest.
-See L<Catalyst::Helper::View::TT> and L<Catalyst::Helper::Model::CDBI> for
+See L<Catalyst::Helper::View::TT> and L<Catalyst::Helper::Model::DBIC> for
examples.
All helper classes should be under one of the following namespaces.
# Set flags and add plugins for the application
#
# -Debug: activates the debug mode for very useful log messages
+# ConfigLoader: will load the configuration from a YAML file in the
+# application's home directory
# Static::Simple: will serve static files from the application's root
-# directory
+# directory
#
use Catalyst qw/-Debug ConfigLoader Static::Simple/;
our $VERSION = '0.01';
#
+# Configure the application
+#
+__PACKAGE__->config( name => '[% name %]' );
+
+#
# Start the application
#
__PACKAGE__->setup;
use FindBin;
use lib "$FindBin::Bin/../lib";
-my $debug = 0;
-my $fork = 0;
-my $help = 0;
-my $host = undef;
-my $port = 3000;
-my $keepalive = 0;
-my $restart = 0;
-my $restart_delay = 1;
-my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = 3000;
+my $keepalive = 0;
+my $restart = 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
my @argv = @ARGV;
GetOptions(
- 'debug|d' => \$debug,
- 'fork' => \$fork,
- 'help|?' => \$help,
- 'host=s' => \$host,
- 'port=s' => \$port,
- 'keepalive|k' => \$keepalive,
- 'restart|r' => \$restart,
- 'restartdelay|rd=s' => \$restart_delay,
- 'restartregex|rr=s' => \$restart_regex
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
);
pod2usage(1) if $help;
require [% name %];
[% name %]->run( $port, $host, {
- argv => \@argv,
- 'fork' => $fork,
- keepalive => $keepalive,
- restart => $restart,
- restart_delay => $restart_delay,
- restart_regex => qr/$restart_regex/
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
} );
1;
-rr -restartregex regex match files that trigger
a restart when modified
(defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
See also:
perldoc Catalyst::Manual
use Catalyst::Helper;
my $force = 0;
+my $mech = 0;
my $help = 0;
GetOptions(
- 'nonew|force' => \$force,
- 'help|?' => \$help
+ 'nonew|force' => \$force,
+ 'mech|mechanize' => \$mech,
+ 'help|?' => \$help
);
pod2usage(1) if ( $help || !$ARGV[0] );
-my $helper = Catalyst::Helper->new( { '.newfiles' => !$force } );
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
[% appprefix %]_create.pl [options] model|view|controller name [helper] [options]
Options:
- -force don't create a .new file where a file to be created exists
- -help display this help and exits
+ -force don't create a .new file where a file to be created exists
+ -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
+ -help display this help and exits
Examples:
[% appprefix %]_create.pl controller My::Controller
+ [% appprefix %]_create.pl -mechanize controller My::Controller
[% appprefix %]_create.pl view My::View
[% appprefix %]_create.pl view MyView TT
[% appprefix %]_create.pl view TT TT
[% appprefix %]_create.pl model My::Model
- [% appprefix %]_create.pl model SomeDB CDBI dbi:SQLite:/tmp/my.db
- [% appprefix %]_create.pl model AnotherDB CDBI dbi:Pg:dbname=foo root 4321
+ [% appprefix %]_create.pl model SomeDB DBIC::SchemaLoader dbi:SQLite:/tmp/my.db
+ [% appprefix %]_create.pl model AnotherDB DBIC::SchemaLoader dbi:Pg:dbname=foo root 4321
See also:
perldoc Catalyst::Manual
__comptest__
use strict;
use warnings;
-[% IF long_type == 'Controller' %]use Test::More tests => 3;
+[% IF long_type == 'Controller' %][% IF mech %]use Test::More;
+
+eval "use Test::WWW::Mechanize::Catalyst '[% app %]'";
+plan $@
+ ? ( skip_all => 'Test::WWW::Mechanize::Catalyst required' )
+ : ( tests => 2 );
+
+ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
+
+$mech->get_ok( 'http://localhost[% uri %]' );
+[% ELSE %]use Test::More tests => 3;
BEGIN { use_ok 'Catalyst::Test', '[% app %]' }
BEGIN { use_ok '[% class %]' }
ok( request('[% uri %]')->is_success, 'Request should succeed' );
+[% END %]
[% ELSE %]use Test::More tests => 1;
BEGIN { use_ok '[% class %]' }