ASP4
view release on metacpan or search on metacpan
- No longer have to do this:
use ASP4::API;
my $api; BEGIN { $api = ASP4::API->new }
# Now load classes:
use MyApp::Foo;
- You can do this instead:
use ASP4::API;
use MyApp::Foo;
my $api = ASP4::API->new;
- Also no need for BEGIN { ASP4::API->init }
- Added requirement Data::Properties::JSON.
- JSON is a better format for test fixtures.
- YAML can still be used.
2011-10-31 1.058
- Added experimental deployment tools `asp4-prep` and `asp4-deploy`.
* asp4-prep does an `svn export` and then gzips the folder and prints the *.tar.gz filename.
* asp4-deploy decompresses the *.tar.gz, creates a symbolic link 'deploying'
to the new folder, copies the existing config files from latest/*/conf/*
(if it exists) or copies conf/*.template config files and renames them without
the *.template suffix. If a 'latest/*' folder was found, asp4-deploy will
run any unit tests found. If all tests pass, then 'deploying' is removed
Cwd: 0
Digest::MD5: 0
DBI: 0
Ima::DBI::Contextual: 0
Storable: 0
HTTP::Date: 0
Time::HiRes 0
Mail::Sendmail: 0
CGI: 3.43
HTTP::Body: 0
JSON::XS: 0
no_index:
directory:
- t
- inc
generated_by: Hand
resources:
repository: git://github.com/jdrago999/ASP4.git
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Makefile.PL view on Meta::CPAN
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.
requires 'Ima::DBI::Contextual' => 0; # Session state.
requires 'Storable' => 0; # Session state.
requires 'HTTP::Date' => 0; # For Session timeouts.
requires 'Time::HiRes' => 0; # For Session ids.
requires 'Mail::Sendmail' => 0; # For sending email.
requires 'CGI' => 3.43; # For...cgi stuff...
requires 'HTTP::Body' => 0;
requires 'JSON::XS' => 0; # For Configs
requires 'Term::ReadKey' => 0; # For asphelper script.
recommends 'ASP4x::Router' => 0.020; # For routing.
install_script 'sbin/asp4';
install_script 'sbin/asp4-prep';
install_script 'sbin/asp4-deploy';
install_script 'sbin/asphelper';
resources(
'repository' => 'https://github.com/jdrago999/ASP4'
README.markdown view on Meta::CPAN
Called automatically at the end of every successful request, causes any changes
to the `$Session` to be saved to the database.
### $Session->reset()
Call `$Session->reset()` to clear all the data out of the session and save
it to the database.
## $Config
The ASP4 `$Config` object is stored in a simple JSON format on disk, and accessible
everywhere within your entire ASP4 application as the global `$Config` object.
If ever you find yourself in a place without a `$Config` object, you can get one
like this:
use ASP4::ConfigLoader;
my $Config = ASP4::ConfigLoader->load();
See [ASP4::Config](http://search.cpan.org/perldoc?ASP4::Config) for full details on the ASP4 `$Config` object and its usage.
lib/ASP4.pm view on Meta::CPAN
Called automatically at the end of every successful request, causes any changes
to the C<$Session> to be saved to the database.
=head3 $Session->reset()
Call C<< $Session->reset() >> to clear all the data out of the session and save
it to the database.
=head2 $Config
The ASP4 C<$Config> object is stored in a simple JSON format on disk, and accessible
everywhere within your entire ASP4 application as the global C<$Config> object.
If ever you find yourself in a place without a C<$Config> object, you can get one
like this:
use ASP4::ConfigLoader;
my $Config = ASP4::ConfigLoader->load();
See L<ASP4::Config> for full details on the ASP4 C<$Config> object and its usage.
lib/ASP4/API.pm view on Meta::CPAN
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()
lib/ASP4/Config.pm view on Meta::CPAN
# Data Connections:
foreach my $conn ( map { $Config->data_connections->$_ } qw/ session application main / )
{
my $dbh = DBI->connect(
$conn->dsn,
$conn->username,
$conn->password
);
}# end foreach()
=head1 JSON Config File
ASP4::ASP keeps all of its configuration inside of C</conf/asp4-config.json>
Here is an example:
{
"system": {
"post_processors": [
],
lib/ASP4/ConfigLoader.pm view on Meta::CPAN
package ASP4::ConfigLoader;
use strict;
use warnings 'all';
use Carp 'confess';
use ASP4::ConfigFinder;
use ASP4::ConfigParser;
use JSON::XS;
our $Configs = { };
#==============================================================================
sub load
{
my ($s) = @_;
my $path = ASP4::ConfigFinder->config_path;
lib/ASP4/ConfigNode/Web.pm view on Meta::CPAN
package ASP4::ConfigNode::Web;
use strict;
use warnings 'all';
use base 'ASP4::ConfigNode';
use Carp 'confess';
use JSON::XS;
sub new
{
my $class = shift;
my $s = $class->SUPER::new( @_ );
$s->{handler_resolver} ||= 'ASP4::HTTPContext::HandlerResolver';
$s->{handler_runner} ||= 'ASP4::HTTPContext::HandlerRunner';
$s->{filter_resolver} ||= 'ASP4::HTTPContext::FilterResolver';
lib/ASP4/Error.pm view on Meta::CPAN
package ASP4::Error;
use strict;
use warnings 'all';
use ASP4::HTTPContext;
use JSON::XS;
sub new
{
my $class = shift;
my ($err_str, %args);
if( @_ )
{
if( @_ == 1 )
{
lib/ASP4/Error.pm view on Meta::CPAN
=head2 message
Defaults to the first part of C<$@> unless otherwise specified.
=head2 stacktrace
A string - defaults to the value of C<$@>.
=head2 form_data
JSON-encoded C<$Form> object.
=head2 session_data
JSON-encoded C<$Session> object.
=head2 http_referer
Default value is C<$ENV{HTTP_REFERER}>
=head2 user_agent
Default value is C<$ENV{HTTP_USER_AGENT}>
=head2 http_code
lib/ASP4/ErrorHandler/Remote.pm view on Meta::CPAN
package ASP4::ErrorHandler::Remote;
use strict;
use warnings 'all';
use base 'ASP4::ErrorHandler';
use vars __PACKAGE__->VARS;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Date 'time2iso';
use JSON::XS;
use Data::Dumper;
require ASP4;
our $ua;
sub run
{
my ($s, $context) = @_;
my $error = $Stash->{error};
lib/ASP4/SessionStateManager/Memcached.pm view on Meta::CPAN
package
ASP4::SessionStateManager::Memcached;
# XXX: Experimental memcached session storage.
# TODO: Configuration section is likely to change.
use strict;
use warnings 'all';
use base 'ASP4::SessionStateManager';
use Cache::Memcached;
use JSON::XS;
my $memd;
sub new
{
my ($class, $r) = @_;
my $s = bless { }, $class;
my $conn = ASP4::ConfigLoader->load->data_connections->session;
$memd = Cache::Memcached->new({
servers => [ $conn->dsn ]
( run in 0.757 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )