view release on metacpan or search on metacpan
inc/Module/Install/Makefile.pm view on Meta::CPAN
sub prompt {
shift;
# Infinite loop protection
my @c = caller();
if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
}
# In automated testing, always use defaults
if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
local $ENV{PERL_MM_USE_DEFAULT} = 1;
goto &ExtUtils::MakeMaker::prompt;
} else {
goto &ExtUtils::MakeMaker::prompt;
}
}
sub makemaker_args {
my $self = shift;
inc/Module/Install/Makefile.pm view on Meta::CPAN
my $self = shift;
my $libs = ref $_[0] ? shift : [ shift ];
$self->makemaker_args( LIBS => $libs );
}
sub inc {
my $self = shift;
$self->makemaker_args( INC => shift );
}
my %test_dir = ();
sub _wanted_t {
/\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
}
sub tests_recursive {
my $self = shift;
if ( $self->tests ) {
die "tests_recursive will not work if tests are already defined";
}
my $dir = shift || 't';
unless ( -d $dir ) {
die "tests_recursive dir '$dir' does not exist";
}
%test_dir = ();
require File::Find;
File::Find::find( \&_wanted_t, $dir );
$self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
}
sub write {
my $self = shift;
die "&Makefile->write() takes no arguments\n" if @_;
# Make sure we have a new enough
require ExtUtils::MakeMaker;
# MakeMaker can complain about module versions that include
inc/Module/Install/Makefile.pm view on Meta::CPAN
# for details.
$self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
# Generate the
my $args = $self->makemaker_args;
$args->{DISTNAME} = $self->name;
$args->{NAME} = $self->module_name || $self->name;
$args->{VERSION} = $self->version;
$args->{NAME} =~ s/-/::/g;
if ( $self->tests ) {
$args->{test} = { TESTS => $self->tests };
}
if ($] >= 5.005) {
$args->{ABSTRACT} = $self->abstract;
$args->{AUTHOR} = $self->author;
}
if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
$args->{NO_META} = 1;
}
if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
$args->{SIGN} = 1;
inc/Module/Install/Makefile.pm view on Meta::CPAN
. $self->preamble
: '';
my $postamble = "# Postamble by $top_class $top_version\n"
. ($self->postamble || '');
local *MAKEFILE;
open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
my $makefile = do { local $/; <MAKEFILE> };
close MAKEFILE or die $!;
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
$makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
$makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
$makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
# Module::Install will never be used to build the Core Perl
# Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
# PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
$makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
#$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
inc/Module/Install/Metadata.pm view on Meta::CPAN
@ISA = qw{Module::Install::Base};
}
my @scalar_keys = qw{
name
module_name
abstract
author
version
distribution_type
tests
installdirs
};
my @tuple_keys = qw{
configure_requires
build_requires
requires
recommends
bundles
resources
inc/Module/Install/Metadata.pm view on Meta::CPAN
die("Unsupported reserved lowercase resource '$name'");
}
$self->{values}{resources} ||= [];
push @{ $self->{values}{resources} }, [ $name, $value ];
}
$self->{values}{resources};
}
# Aliases for build_requires that will have alternative
# meanings in some future version of META.yml.
sub test_requires { shift->build_requires(@_) }
sub install_requires { shift->build_requires(@_) }
# Aliases for installdirs options
sub install_as_core { $_[0]->installdirs('perl') }
sub install_as_cpan { $_[0]->installdirs('site') }
sub install_as_site { $_[0]->installdirs('site') }
sub install_as_vendor { $_[0]->installdirs('vendor') }
sub sign {
my $self = shift;
lib/ASP4.pm view on Meta::CPAN
Sends an email via L<Mail::Sendmail>. In fact it simply calls the C<sendmail(...)> function
provided by L<Mail::Sendmail>.
Simple Example:
$Server->Mail(
from => 'foo@bar.com',
to => 'bar@foo.com',
subject => 'Hello, world!',
message => 'this is a test message'
);
To send an HTML email do the following:
use MIME::Base64;
$Server->Mail(
from => 'foo@bar.com',
to => 'bar@foo.com',
subject => 'Hello, world!',
'content-type' => 'text/html',
lib/ASP4.pm view on Meta::CPAN
such as in a RequestFilter - will still be there at the very end of the request -
as in a RegisterCleanup handler.
Use the C<$Stash> as a great place to store a piece of data for the duration of
a single request.
=head1 DATABASE
While ASP4 B<does not require> its users to choose any specific database (eg: MySQL or PostgreSQL)
or ORM (object-relational mapper) the B<recommended> ORM is L<Class::DBI::Lite>
since it has been completely and thoroughly tested to be 100% compatible with ASP4.
For full documentation about L<Class::DBI::Lite> please view its documentation.
B<NOTE:> L<Class::DBI::Lite> must be installed in addition to ASP4 as it is a separate library.
=head1 ASP4 QuickStart
Here is an example project to get things going.
In the C<data_connections.main> section of C<conf/asp4-config.json> you should have
lib/ASP4/API.pm view on Meta::CPAN
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
lib/ASP4/API.pm view on Meta::CPAN
# Create an api object:
my $api = ASP4::API->new;
# Use the API:
my $res = $api->ua->get('/index.asp');
if( $res->is_success ) {
print $res->content;
}
# Access your test data:
warn $res->test_data->contact_form->email;
# Access your properties YAML:
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';
lib/ASP4/API.pm view on Meta::CPAN
=head2 config
Returns the L<ASP4::Config> object for the web application.
=head2 properties
Returns an object representing your C</etc/properties.yaml> file.
=head2 data
Returns an object representing your C</etc/test_fixtures.yaml> file.
=head1 BUGS
It's possible that some bugs have found their way into this release.
Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.
=head1 HOMEPAGE
Please visit the ASP4 homepage at L<http://0x31337.org/code/> to see examples
lib/ASP4/ConfigFinder.pm view on Meta::CPAN
our $CONFIGFILE = 'asp4-config.json';
sub config_path
{
my $path = $CONFIGFILE;
my $root = do { ($ENV{REMOTE_ADDR} || '') eq '' ? fastcwd() : $ENV{DOCUMENT_ROOT} || fastcwd() };
# Try test dir:
if( -f "$root/t/conf/$CONFIGFILE" )
{
return "$root/t/conf/$CONFIGFILE";
}# end if()
# Start moving up:
for( 1...10 )
{
my $path = "$root/conf/$CONFIGFILE";
return $path if -f $path;
lib/ASP4/ErrorHandler/Remote.pm view on Meta::CPAN
1) Makes a simple HTML page and prints it to the browser, telling the user
that an error has just occurred.
2) Sends an error notification to the web address specified in the config.
The data contained within the POST will match the public properties of L<ASP4::Error>, like this:
$VAR1 = {
'remote_addr' => '127.0.0.1',
'request_uri' => '/',
'user_agent' => 'test-useragent v2.0',
'file' => '/home/john/Projects/myapp/www/htdocs/index.asp',
'session_data' => '{}',
'message' => 'A fake error has occurred',
'http_code' => '500',
'stacktrace' => 'A fake error has occurred at /tmp/PAGE_CACHE/TSR_WWW/__index_asp.pm line 2.
',
'domain' => 'www.tsr.local',
'form_data' => '{}',
'http_referer' => '',
'code' => 'line 1: <h1>Hello, world!</h1>
lib/ASP4/HTTPContext.pm view on Meta::CPAN
Returns the current C<ASP4::Config> for the HTTP request.
=head2 cgi
Provided B<Just In Case> - returns the L<CGI> object for the HTTP request.
=head2 r
Provided B<Just In Case> - returns the L<Apache2::RequestRec> for the HTTP request.
B<NOTE:> Under L<ASP4::API> (eg: in a unit test) C<$r> will be an instance of L<ASP4::Mock::RequestRec> instead.
=head1 BUGS
It's possible that some bugs have found their way into this release.
Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.
=head1 HOMEPAGE
Please visit the ASP4 homepage at L<http://0x31337.org/code/> to see examples
lib/ASP4/PageParser.pm view on Meta::CPAN
sub _parse_tag_attrs
{
my ($s, $str) = @_;
my $attr = { };
while( $str =~ m@([^\s\=\"\']+)(\s*=\s*(?:(")(.*?)"|(')(.*?)'|([^'"\s=]+)['"]*))?@sg ) #@
{
my $key = $1;
my $test = $2;
my $val = ( $3 ? $4 : ( $5 ? $6 : $7 ));
if( $test )
{
$attr->{ lc($key) } = $val;
}
else
{
$attr->{ lc($key) } = $key;
}# end if()
}# end while()
return $attr;
lib/ASP4/RequestFilter.pm view on Meta::CPAN
...
},
...
}
=head1 DESCRIPTION
Subclass C<ASP4::RequestFilter> to instantly apply rules to incoming
requests.
These RequestFilters also work for testing via L<ASP4::API>.
=head1 ABSTRACT METHODS
=head2 run( $self, $context )
B<IMPORTANT:> Return C<-1> (or $Response->Declined) to allow the current RequestFilter to be ignored.
Returning anything else...
return $Response->Redirect("/unauthorized/");
lib/ASP4/Server.pm view on Meta::CPAN
Becomes:
<tag/>
=head2 URLEncode( $str )
Converts a string for use within a URL.
eg:
test@test.com
becomes:
test%40test.com
=head2 URLDecode( $str )
Converts a url-encoded string to a normal string.
eg:
test%40test.com
becomes:
test@test.com
=head2 MapPath( $file )
Converts a relative path to a full disk path.
eg:
/contact/form.asp
becomes:
lib/ASP4/SimpleCGI.pm view on Meta::CPAN
my $escaped = $cgi->escape( 'Hello world' );
my $unescaped = $cgi->unescape( 'Hello+world' );
my $upload = $cgi->upload('filename');
my $filehandle = $cgi->upload_info('filename', 'filehandle' );
=head1 DESCRIPTION
This package provides basic CGI functionality and is also used for testing and
in the API enironment.
C<ASP4::SimpleCGI> uses L<HTTP::Body> under the hood.
=head1 PUBLIC METHODS
=head2 new( %args )
Returns a new C<ASP4::SimpleCGI> object.
lib/ASP4/TransHandler.pm view on Meta::CPAN
=head2 RequestFilters vs TransHandlers
The difference between TransHandlers and L<ASP4::RequestFilter>s is that
within a RequestFilter, you have access to all of the normal ASP objects ($Request, $Response, $Session, etc).
In a TransHandler, you only have access to the L<Apache2::RequestRec> C<$r> and the
L<ASP4::Config> (and only then if you load it up yourself via L<ASP4::ConfigLoader>.
B<NOTE>: - TransHandlers are configured in the C<httpd.conf> and are only executed
in a real Apache2 httpd environment. They are not executed during testing or via
L<ASP4::API>.
TransHandlers are a handy way of jumping into "normal" mod_perl handler mode without
losing access to your web application's config.
=head1 BUGS
It's possible that some bugs have found their way into this release.
Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.
lib/ASP4/UserAgent.pm view on Meta::CPAN
$ENV{SCRIPT_FILENAME} = $s->config->web->www_root . $uri_no_args;
if( -d $ENV{SCRIPT_FILENAME} )
{
$ENV{SCRIPT_FILENAME} =~ s{/$}{};
$ENV{SCRIPT_FILENAME} .= "/index.asp";
}# end if()
$ENV{SCRIPT_NAME} = $uri_no_args;
}# end unless()
# User-Agent:
$req->header( 'User-Agent' => 'test-useragent v2.0' );
$ENV{HTTP_USER_AGENT} = 'test-useragent v2.0';
# Cookies:
$req->header( 'Cookie' => $ENV{HTTP_COOKIE} = $s->http_cookie );
if( $ENV{REQUEST_METHOD} =~ m/^post$/i )
{
# Set up the basic params:
return ASP4::SimpleCGI->new(
querystring => $ENV{QUERY_STRING},
body => $req->content,
lib/ASP4/UserAgent.pm view on Meta::CPAN
username => 'willy',
password => 'wonka',
]);
my $res = $api->ua->upload('/handlers/file.upload', [
foo => 'bar',
baz => 'bux',
file => ['/home/john/avatar.jpg']
]);
# Some form testing:
my ($form) = HTML::Form->parse( $res->content, '/' );
$form->find_input('username')->value('bob');
my $res = $api->ua->submit_form( $form );
# Add/remove a cookie:
$api->ua->add_cookie( "the-boss" => "me" );
$api->remove_cookie( "the-boss" );
=head1 DESCRIPTION
Enables unit-testing ASP4 applications by providing the ability to execuite web
pages from your code, without a webserver.
=head1 PUBLIC METHODS
=head2 get( $url )
Calls C<$url> and returns the L<HTTP::Response> result.
=head2 post( $url, $args )
t/handlers/dev/encoding/hello.pm view on Meta::CPAN
package dev::encoding::hello;
use strict;
use warnings 'all';
use base 'ASP4::FormHandler';
use vars __PACKAGE__->VARS;
use MIME::Base64;
use Encode;
use utf8;
# TODO: Encoding tests to make sure we get round-trip encoding integrity.
sub run
{
my ($s, $context) = @_;
my $hellos = {
arabic => {
original => 'Ù
Ø±ØØ¨Ø§ Ø Ø§ÙØ¹Ø§ÙÙ
!',
encoded => 'JiMxNjA1OyYjMTU4NTsmIzE1ODE7JiMxNTc2OyYjMTU3NTsgJiMxNTQ4OyAmIzE1NzU7JiMxNjA0
OyYjMTU5MzsmIzE1NzU7JiMxNjA0OyYjMTYwNTsh'
},
t/handlers/dev/headers.pm view on Meta::CPAN
use strict;
use warnings 'all';
use base 'ASP4::FormHandler';
use vars __PACKAGE__->VARS;
sub run
{
my ($s, $context) = @_;
$Response->ContentType("text/x-test");
$Response->Expires( 500 );
$Response->AddHeader("content-length" => 3000);
$Response->Write( "X"x3000 );
$Response->Flush;
}# end run()
1;# return true: