App-TemplateServer
view release on metacpan or search on metacpan
lib/App/TemplateServer.pm view on Meta::CPAN
package App::TemplateServer;
use 5.010;
use feature ':5.10';
use Moose;
use Moose::Util::TypeConstraints;
use MooseX::Types::Path::Class qw(File);
use HTTP::Daemon;
use HTTP::Headers;
use HTTP::Request;
use HTTP::Response;
use App::TemplateServer::Types;
use App::TemplateServer::Provider::TT;
use App::TemplateServer::Page::Index;
use App::TemplateServer::Context;
use Package::FromData;
use Method::Signatures;
use URI::Escape;
lib/App/TemplateServer/Context.pm view on Meta::CPAN
isa => 'HTTP::Daemon',
);
has 'data' => (
is => 'ro',
isa => 'HashRef',
);
has 'request' => (
is => 'ro',
isa => 'HTTP::Request',
);
1;
t/synopsis.t view on Meta::CPAN
use strict;
use warnings;
use Test::More tests => 13;
use App::TemplateServer;
use YAML::Syck;
use Class::MOP;
use HTTP::Request;
{
package TestProvider;
use Data::Dumper;
use Moose;
with 'App::TemplateServer::Provider';
sub list_templates { qw/1 2 3/ }
sub render_template { Dumper($_[2]->data) }
}
t/synopsis.t view on Meta::CPAN
ok !eval { Test->new }, 'no Test yet';
$serv->_data; # and now it's here
# first, test the created packages
isa_ok my $a = Test->new, 'Test', 'Test->new';
is $a->map_foo_bar('foo'), 'bar';
is $a->map_foo_bar('bar'), 'foo';
is $a->map_foo_bar(qw/foo gorch/), 'INVALID INPUT';
my $req = HTTP::Request->new(GET => '/foo');
my $res = $serv->_req_handler($req);
ok $res->content, 'got content';
my $result = eval 'my '. $res->content.'; $VAR1'; # yeck
ok $result, 'deserialized ok';
isa_ok $result->{another_test_instance}, 'Test', 'another_test_instance';
isa_ok $result->{test_instance}, 'Test', 'test_instance';
is $result->{another_test_instance}->map_foo_bar('foo'), 'bar';
( run in 0.452 second using v1.01-cache-2.11-cpan-de7293f3b23 )