-
-
18 Apr 2008 10:27:38 UTC
- Distribution: Maypole
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (13)
- Testers (225 / 231 / 1)
- Kwalitee
Bus factor: 0- 65.31% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (149.99KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- CGI::Simple
- CGI::Untaint
- CGI::Untaint::date
- CGI::Untaint::email
- Class::DBI
- Class::DBI::AbstractSearch
- Class::DBI::Loader
- Class::DBI::Loader::Relationship
- Class::DBI::Pager
- Class::DBI::Plugin::RetrieveAll
- Class::DBI::Plugin::Type
- Digest::MD5
- File::MMagic::XS
- HTML::Tree
- HTTP::Body
- Template
- Template::Plugin::Class
- Test::MockModule
- UNIVERSAL::moniker
- UNIVERSAL::require
- URI
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Maypole::CLI - Command line interface to Maypole for testing and debugging
SYNOPSIS
% setenv MAYPOLE_TEMPLATES /var/www/beerdb/ % perl -MMaypole::CLI=BeerDB -e1 http://localhost/beerdb/brewery/frontpage
DESCRIPTION
This module is used to test Maypole sites without going through a web server or modifying them to use a CGI frontend. To use it, you should first either be in the template root for your Maypole site or set the environment variable
MAYPOLE_TEMPLATES
to the right value.Next, you import the
Maypole::CLI
module specifying your base Maypole subclass. The usual way to do this is with the-M
flag:perl -MMaypole::CLI=MyApp
. This is equivalent to:use Maypole::CLI qw(MyApp);
Now Maypole will automatically call your application's handler with the URL specified as the first command line parameter. This should be the full URL, starting from whatever you have defined as the
uri_base
in your application's configuration, and may include query parameters.The Maypole HTML output should then end up on standard output.
Support for testing
The module can also be used as part of a test script.
When used programmatically, rather than from the command line, its behaviour is slightly different.
Although the URL is taken from
@ARGV
as normal, your application'shandler
method is not called automatically, as it is when used on the command line; you need to call it manually. Additionally, whenhandler
is called, the output is not printed to standard output but stored in$Maypole::CLI::buffer
, to allow you to check the contents more easily.For instance, a test script could look like this:
use Test::More tests => 3; use Maypole::CLI qw(BeerDB); use Maypole::Constants; $ENV{MAYPOLE_TEMPLATES} = "t/templates"; # Hack because isa_ok only supports object isa not class isa isa_ok( (bless {},"BeerDB") , "Maypole"); like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, "Got the front page"); like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list");
METHODS
- call_url
-
for use in scripts. takes an url as argument, and returns the buffer.
Implementation
This class overrides a set of methods in the base Maypole class to provide it's functionality. See Maypole for these:
- get_template_root
- parse_args
- parse_location
- send_output
- warn
Module Install Instructions
To install Maypole, copy and paste the appropriate command in to your terminal.
cpanm Maypole
perl -MCPAN -e shell install Maypole
For more information on module installation, please visit the detailed CPAN module installation guide.