ASP4
view release on metacpan or search on metacpan
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 {
test_fixtures => $test_data,
properties => $properties,
ua => ASP4::UserAgent->new(),
config => $config,
}, $class;
}# end new()
*init = \&new;
sub test_fixtures { shift->{test_fixtures} }
sub properties { shift->{properties} }
sub ua { shift->{ua} }
sub context { ASP4::HTTPContext->current }
sub config { shift->{config} }
sub data { shift->test_fixtures } # XXX: Deprecated! - for Apache2::ASP compat only.
sub test_data { shift->test_fixtures } # XXX: Deprecated!
sub DESTROY
{
my $s = shift;
undef(%$s);
}# end DESTROY()
1;# return true:
=pod
=head1 NAME
ASP4::API - Public Programmatic API to an ASP4 Application
=head1 SYNOPSIS
#!/usr/bin/perl -w
use strict;
use warnings 'all';
# Load up and initialize ASP4::API *before* using your app's classes:
use ASP4::API;
# *Now* you can use your app's other classes:
# because the environment has been initialized (@INC, %ENV, etc):
( run in 0.430 second using v1.01-cache-2.11-cpan-5a3173703d6 )