ASP4

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/ASP4/Request.pm
lib/ASP4/RequestFilter.pm
lib/ASP4/Response.pm
lib/ASP4/Server.pm
lib/ASP4/SessionStateManager.pm
lib/ASP4/SessionStateManager/InMemory.pm
lib/ASP4/SessionStateManager/Memcached.pm
lib/ASP4/SessionStateManager/NonPersisted.pm
lib/ASP4/SimpleCGI.pm
lib/ASP4/StaticHandler.pm
lib/ASP4/Test/Fixtures.pm
lib/ASP4/TransHandler.pm
lib/ASP4/UserAgent.pm
Makefile.PL
MANIFEST			This list of files
META.yml
README.markdown
runprofiler.sh
runtests.sh
sbin/asp4
sbin/asp4-deploy

META.yml  view on Meta::CPAN

--- #YAML:1.0
name:               ASP4
version:            1.087
abstract:           Fast, Simple, Scalable Web Development
author:
    - John Drago <jdrago_999@yahoo.com>
license:            artistic
distribution_type:  module
test_requires:
    Test::More:           0
    Test::Memory::Cycle:  0
    Time::HiRes:          0
    HTML::Form:           0
requires:
    common::sense:            0
    Data::Properties::YAML:   0
    Cwd:                      0
    Digest::MD5:              0
    DBI:                      0
    Ima::DBI::Contextual:     0
    Storable:                 0

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;
use inc::Module::Install;
use 5.008005;

name 'ASP4';
perl_version '5.008005';
license 'perl';
all_from 'lib/ASP4.pm';

test_requires 'Test::More'          => 0;
test_requires 'Test::Memory::Cycle' => 0;
#test_requires 'DBD::SQLite'         => 0;
test_requires 'Time::HiRes'         => 0;
test_requires 'HTML::Form'          => 0;

requires    'common::sense'           => 0;
requires    'Data::Properties::YAML'  => 0;
requires    'Data::Properties::JSON'  => 0;
requires    'Cwd'                     => 0;
requires    'Digest::MD5'             => 0;       # Session state.
requires    'DBI'                     => 0;       # Session state.

lib/ASP4/API.pm  view on Meta::CPAN


package ASP4::API;

use strict;
use warnings 'all';
use ASP4::ConfigLoader;
use ASP4::HTTPContext;
use ASP4::UserAgent;
use ASP4::Test::Fixtures;
BEGIN { ASP4::ConfigLoader->load }

sub new
{
  my ($class) = @_;;
  
  my $config = ASP4::ConfigLoader->load;
  
  # Our test fixtures:
  my $test_data;
  if( -f $config->web->application_root . '/etc/test_fixtures.json' )
  {
    eval { require Data::Properties::JSON };
    $test_data = Data::Properties::JSON->new(
      properties_file => $config->web->application_root . '/etc/test_fixtures.json'
    ) unless $@;
  }
  elsif( -f $config->web->application_root . '/etc/test_fixtures.yaml' )
  {
    $test_data = ASP4::Test::Fixtures->new(
      properties_file => $config->web->application_root . '/etc/test_fixtures.yaml'
    );
  }# end if()
  
  # Our diagnostic messages:
  my $properties = Data::Properties::YAML->new(
    properties_file => $config->web->application_root . '/etc/properties.yaml'
  ) if -f $config->web->application_root . '/etc/properties.yaml';
  
  return bless {

lib/ASP4/API.pm  view on Meta::CPAN

  warn $res->properties->contact_form->email->is_missing;
  
  # Access the application config:
  warn $api->config->system->settings->foo;

=head1 DESCRIPTION

C<ASP4::API> is B<very useful for unit tests> - specifically when writing tests
for the actual web pages themselves.

=head2 Example Unit Test

  #!/usr/bin/perl -w
  
  use strict;
  use warnings 'all';
  use Test::More 'no_plan';
  
  use ASP4::API;
  my $api = ASP4::API->new();
  
  ok(
    $api, "Got api"
  );
  like(
    $api->ua->get('/hello.asp')->content => qr/Hello\s+World\!/,
    'Website is friendly'

lib/ASP4/Server.pm  view on Meta::CPAN


=head1 SYNOPSIS

  # Get the full disk path to /contact/form.asp:
  $Server->MapPath("/contact/form.asp");
  
  # Email someone:
  $Server->Mail(
    To      => 'jim@bob.com',
    From    => 'Joe Jangles <joe@jangles.net>',
    Subject => 'Test Email',
    Message => "Hello There!",
  );
  
  # Avoid XSS:
  <input type="text" name="foo" value="<%= $Server->HTMLEncode( $Form->{foo} ) %>" />
  
  # Proper URLs:
  <a href="foo.asp?bar=<%= $Server->URLEncode($Form->{bar}) %>">Click</a>

=head1 DESCRIPTION

lib/ASP4/Test/Fixtures.pm  view on Meta::CPAN


package
ASP4::Test::Fixtures;

use strict;
use warnings 'all';
use base 'Data::Properties::YAML';

sub as_hash
{
  wantarray ? %{ $_[0]->{data} } : $_[0]->{data};
}# end as_hash()

sbin/asp4-deploy  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Getopt::Long;
use Test::Harness;
use Cwd 'cwd';

my $res = GetOptions(
  "src=s"     => \my $src,
  "target=s"  => \my $target
);

$src or die "Usage: $0 --src=</path/to/MyApp_2011-11-29_12.03.34.tar.gz> [--target=/var/www/appname/]\n";

my $start_cwd = cwd();

sbin/asp4-deploy  view on Meta::CPAN

    chdir("deploying/$folder");
    unless( eval { runtests( <t/*/*.t> ) } ) #/
    {
      push @test_errors, $@;
    }# end unless()
  }# end foreach()
  chdir($start_cwd);
  
  if( @test_errors )
  {
    die "Tests failed:\n", join "\n", @test_errors;
  }# end if()
  
  `rm -rf latest`;
  `rm -rf deploying`;
  `ln -s "$id" latest`;
}
else
{
  `tar -zxvf "$src" && ln -s "$id" latest`;
  my @to_update = ( );

sbin/asphelper  view on Meta::CPAN

  $conf =~ s/\%dbName\%/$dbName/igs;
  $conf =~ s/\%dbHost\%/$dbHost/igs;
  $conf =~ s/\%dbUser\%/$dbUser/igs;
  $conf =~ s/\%dbPass\%/$dbPass/igs;
  $conf =~ s/\%email\%/$email/igs;
  print $ofh $conf;
  close($ofh);
}# end unless()


# Test page:
make_path("www/htdocs");
unless( -f "www/htdocs/index.asp" )
{
  warn "www/htdocs/index.asp\n";
  open my $ofh, '>', "www/htdocs/index.asp"
    or die "Cannot open 'www/htdocs/index.asp' for writing: $!";
  print $ofh <<'ASP';
<html>
<body>
<h1>ASP4 Test Page</h1>
<p>
  The date and time is <%= scalar(localtime()) %>.
</p>
<p>
  You have visited this page <%= $Session->{count}++ %> time(s) recently.
</p>
</body>
</html>
ASP
  close($ofh);

sbin/asphelper  view on Meta::CPAN

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

sbin/asphelper  view on Meta::CPAN


    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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

sbin/asphelper  view on Meta::CPAN

  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


t/010-basic/000-setup.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use DBI;
use Digest::MD5 'md5_hex';

my $temp_root = '/tmp';
if( $^O =~ m{win32}i )
{
  $temp_root = $ENV{TEMP} || $ENV{TMP};
}# end if()

t/010-basic/010-compile.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use_ok( 'ASP4::Config' );
use_ok( 'ASP4::ConfigLoader' );
use_ok( 'ASP4::Request' );
use_ok( 'ASP4::Response' );
use_ok( 'ASP4::SessionStateManager' );
use_ok( 'ASP4::Server' );
use_ok( 'ASP4::HTTPContext' );
use_ok( 'ASP4::Page' );
use_ok( 'ASP4::MasterPage' );

t/010-basic/020-pageparser.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use_ok('ASP4::PageParser');
use_ok('ASP4::Page');
use_ok('ASP4::MasterPage' );


{
  my $parser = ASP4::PageParser->new( script_name => '/pageparser/010.asp');
  my $page = $parser->parse();

t/010-basic/030-pageloader.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use_ok('ASP4::PageLoader');


{
  my $page = ASP4::PageLoader->load( script_name => '/pageparser/010.asp');
  
  ok( $page );
  
  is( $page->script_name =>   '/pageparser/010.asp', "Script name is correct");

t/010-basic/040-httpcontextA.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::ConfigLoader;
use ASP4::SimpleCGI;
use ASP4::API;
my $config; BEGIN { $config = ASP4::ConfigLoader->load }

use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('ASP4::HTTPContext');
use_ok('ASP4::Mock::RequestRec');

t/010-basic/050-useragent.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use ASP4::ConfigLoader;
my $config; BEGIN { $config = ASP4::ConfigLoader->load }

use HTML::Form;

use_ok('ASP4::UserAgent');

my $ua = ASP4::UserAgent->new();

t/010-basic/060-api.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

use ASP4::API;

my $api; BEGIN { $api = ASP4::API->new }
ok( $api, 'got api' );

like
  $api->ua->get('/useragent/hello-world.asp')->content, qr/Hello, World\!/,
  "ua.get(...) works"
;

t/010-basic/070-memory-leak.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;
use Test::Memory::Cycle;

my $api; BEGIN { $api = ASP4::API->new }
ok( $api, 'Got an API' );

$api->ua->get("/useragent/hello-world.asp");


for( 1...100 )
{
  $api->ua->get("/useragent/hello-world.asp");

t/010-basic/080-cleanup-handlers.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

ok( my $api = ASP4::API->new, 'got api' );


$::cleanup_called = 0;
ok( $api->ua->get('/register-cleanup.asp') );

ok( $::cleanup_called, "Cleanup handler was called" );

t/010-basic/090-everything.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

my $api = ASP4::API->new;

ok( my $res = $api->ua->get('/everything/step01.asp'), "Got res");

ok(
  $res = $api->ua->get('/handlers/dev.headers'), "Got headers res again"
);
is(

t/020-bench/010-hello.t  view on Meta::CPAN

#!/usr/bin/perl -w

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

ok(1);

{
  my ($time, $persec) = bench('/handlers/dev.simple', 1000);
  warn "\nGET /handlers/dev.simple 1000 times in $time seconds ($persec/second)\n";
}

t/030-filters/010-seo.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use ASP4::API;
use Test::More tests => 5;
my $api; BEGIN { $api = ASP4::API->new }

ok( $api, "Got api");

my $res = $api->ua->get("/seo/123/");

ok( $res->is_success, "request is successful" );

is( $res->content => 'Hello - SEO
', "Got the content we were expecting");

t/040-round2/010-include-missing.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

my $api = ASP4::API->new();


my $res = $api->ua->get("/include-missing.asp");

ok( $res->is_success, "res.is_success" );
like $res->content, qr/Before\s+After/, "res.content looks right";

t/040-round2/020-api-in-handler.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

my $api = ASP4::API->new();

ok( my $res = $api->ua->get('/handlers/dev.api_inside_handler'), 'got res' );


#is $res->content => "Hello, World!\n", "res.content is correct";


t/040-round2/030-redirect-after-trapinclude.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

ok( my $api = ASP4::API->new, 'got api' );

my $res = $api->ua->get('/handlers/dev.redirect_after_trapinclude');

ok $res->header('location'), "got res.header.location";


t/050-encoding/010-default.t  view on Meta::CPAN

#!/usr/bin/perl -w

use utf8;
use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

my $hellos = {
  arabic  => {
    original  => 'مرحبا ، العالم!',
    encoded => 'JiMxNjA1OyYjMTU4NTsmIzE1ODE7JiMxNTc2OyYjMTU3NTsgJiMxNTQ4OyAmIzE1NzU7JiMxNjA0
OyYjMTU5MzsmIzE1NzU7JiMxNjA0OyYjMTYwNTsh'
  },
  armenian  => {
    original  => 'Ô²Õ¡Ö€Õ¥Ö‚, Õ¡Õ·Õ­Õ¡Ö€Õ°Õ«.',

t/999-finish/000-cleanup.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use Test::More 'no_plan';

my $temp_root = $ENV{TEMP} || $ENV{TMP} || '/tmp';
my $filename = "$temp_root/db_asp4";
ok( unlink($filename), "unlink('$filename')" );
map {
  ok(
    unlink($_),
    "unlink('$_')"
  );
} <$temp_root/PAGE_CACHE/DefaultApp/*.pm>;



( run in 0.653 second using v1.01-cache-2.11-cpan-4d50c553e7e )