ASP4

 view release on metacpan or  search on metacpan

sbin/asphelper  view on Meta::CPAN

\=cut

CODE
    close($ofh);
  }# end unless()
}# end if()


unless( -f "www/t/010-basic/010-compile.t" )
{
  warn "www/t/010-basic/010-compile.t\n";
  open my $ofh, '>', "www/t/010-basic/010-compile.t"
    or die "Cannot open 'www/t/010-basic/010-compile.t' for writing: $!";
  print $ofh <<"TEST";
#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;
my \$api = ASP4::API->new;

TEST

  if( $CDBIL_Version )
  {
print $ofh <<"MORE";
@{[ $dbName ? qq(use_ok('$appName\::db::model');) : '' ]}
MORE
  }# end if()
  
  print $ofh <<"TEST";

my \$res = \$api->ua->post("/handlers/$hClass.www.echo", {
  hello => "world"
});
like \$res->content, qr('hello'\\s+\\=\>\\s+'world'), "/handlers/$hClass.www.echo?hello=world works";

ok( \$res = \$api->ua->get("/"), "Got '/'.");
ok( \$res->is_success, "GET / is successful.");
ok( \$res->content, "Got some content also.");


TEST

  if( $dbName && $dbUser )
  {
    print $ofh <<"TEST";
for( 0..10 )
{
  like \$res->content, qr(visited this page \$_ time), "Simple session counter: \$_ visits recorded.";
  \$res = \$api->ua->get("/");
}# end for()

TEST
  }# end if()


    print $ofh <<"TEST";

# More tests can go here or in other files.

TEST
  close($ofh);
}# end unless()

warn "="x60, "\n";
warn "    Running Initial Test Suite...\n";
warn "="x60, "\n";
chdir("www");
`asp4 /` =~ m{You have visited this page}
  or die "Warning: ASP script contents (/index.asp) not what we expected!";
system("prove -rv t");

# Talk about the config now:
warn <<"END";

!!!!!!!!!!!!!!!!!!!!!! CONGRATULATIONS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*** Update your Apache Config ***
  Include $cwd/www/conf/httpd.conf

*** Add This to your /etc/hosts File ***
  127.0.0.1     $domain

*** Restart Apache ***
  Maybe:  sudo /etc/init.d/httpd restart
  Or:     sudo /etc/init.d/apache2 restart
  Or:     service apache2 restart

*** To Test it in Your Browser ***
  Navigate to http://$domain

*** To Run the Unit Tests ***
  cd $cwd/www
  prove -rv t

*** To Run an ASP Script From the Command Line ***
  cd $cwd/www
  asp4 /index.asp

END


sub generic_config
{
  my ($has_db) = @_;

  my $str = <<'EOF';
{
  "system": {
    "post_processors": [
    ],
    "libs": [
      "@ServerRoot@/lib",
      "@ProjectRoot@/common/lib"
    ],
    "load_modules": [
    ],
    "env_vars": {
    },
    "settings": {

sbin/asphelper  view on Meta::CPAN


# Apache2::Reload does not play well with ASP4.
# Uncomment the following line if you get Apache2::Reload errors:
#PerlSetVar ReloadAll Off

# Admin website:
<VirtualHost *:80>

  ServerName    %domain%
  DocumentRoot  %CWD%/www/htdocs
  
  # Set the directory index:
  DirectoryIndex index.asp
  
  # All *.asp files are handled by ASP4::ModPerl
  <Files ~ (\.asp$)>
    SetHandler  perl-script
    PerlResponseHandler ASP4::ModPerl
    SetEnv no-gzip dont-vary
  </Files>
  
  # !IMPORTANT! Prevent anyone from viewing your *.pm files:
  <Files ~ (\.pm$)>
    Order allow,deny
    Deny from all
  </Files>
  
  # All requests to /handlers/* will be handled by their respective handler:
  <Location /handlers>
    SetHandler  perl-script
    PerlResponseHandler ASP4::ModPerl
    SetEnv no-gzip dont-vary
  </Location>
  
</VirtualHost>

EOF
}





=pod

=head1 NAME

asphelper - Generate an ASP4 skeleton web application

=head1 USAGE

  asphelper --app=AppName --domain=example.com --email=you@your-email.com [--host=dbhost --db=dbname  --user=dbusername]

If you specify C<--dbname> and C<--dbuser> it will ask you for a database password - completely optional.

=head1 DESCRIPTION

The C<asphelper> program offers a way to get up-and-running quickly with a new ASP4 web application.

After successfully answering its questions, C<asphelper> will generate a skeleton web application
including config files, full directory structure and a simple unit test.

Use the resulting application as a starting-point for your own development.

If executed with the following arguments:

  asphelper --app=Foo --domain=www.foo.local --email=foo@bar.com --host=localhost --db=foo --user=root

You will get an application matching what is listed below:

  .
    `-- foo
        |-- common
        |   |-- lib
        |   |   `-- Foo
        |   |       `-- db
        |   |           `-- model.pm
        |   `-- sbin
        |       `-- ddl.sql
        `-- www
            |-- conf
            |   |-- asp4-config.json
            |   `-- httpd.conf
            |-- etc
            |-- handlers
            |   `-- foo
            |       `-- www
            |           `-- echo.pm
            |-- htdocs
            |   `-- index.asp
            `-- t
                `-- 010-basic
                    `-- 010-compile.t

B<NOTE:> If L<Class::DBI::Lite> is installed, a base Model class will be created based on
L<Class::DBI::Lite>.  See L<Class::DBI::Lite> for details on how to use it.

=cut



( run in 0.777 second using v1.01-cache-2.11-cpan-39bf76dae61 )