Skip to content

Commit

Permalink
Merge branch 'release/1.3100'
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Aug 25, 2012
2 parents ceaec5b + cc52b81 commit 60acb1a
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 63 deletions.
13 changes: 13 additions & 0 deletions CHANGES
@@ -1,5 +1,18 @@
{{$NEXT}}

1.3100 25.08.2012

[ BUG FIXES ]
* GH #816: Improve wording when failed to load engine. (Sawyer X)
* GH #817: Fix CODE reference uncloned using Clone::clone.
(David Previous, Sawyer X)

[ ENHANCEMENTS ]
* GH #755: HTTP::Headers accepted by dancer_response. (Roberto Patriarca)

[ DOCUMENTATION ]
* GH #818: Use "MyWeb::App" instead of "mywebapp" in examples. (pdl)

1.3099 11.08.2012

[ BUG FIXES ]
Expand Down
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -48,6 +48,7 @@ WriteMakefile1(
'MIME::Types' => '0',
'URI' => '1.59',
'Try::Tiny' => '0.09',
'Clone' => '0',

# core
'File::Basename' => '0',
Expand Down
18 changes: 9 additions & 9 deletions README
Expand Up @@ -31,19 +31,19 @@ for easy access).
To create a new Dancer application, use the helper script "dancer" provided
with this distribution:

$ dancer -a mywebapp
+ mywebapp
+ mywebapp/config.yml
+ mywebapp/views
+ mywebapp/views/layouts
$ dancer -a MyWeb::App
+ MyWeb-App/bin
+ MyWeb-App/bin/app.pl
+ MyWeb-App/config.yml
+ MyWeb-App/environments
[..]

You then have a new Dancer application in 'mywebapp', which is already a
You then have a new Dancer application in 'MyWeb::App', which is already a
functioning "Hello World" application, ready for you to work upon.

Here is an example of a webapp built with Dancer:

# webapp.pl
# MyWeb-App/bin/app.pl
#!/usr/bin/perl

use Dancer;
Expand All @@ -64,7 +64,7 @@ Here is an example of a webapp built with Dancer:

When running this script, a webserver is running and ready to serve:

$ perl ./webapp.pl
$ perl ./bin/app.pl
>> Listening on 0.0.0.0:3000
== Entering the development dance floor ...

Expand Down Expand Up @@ -105,7 +105,7 @@ This is a work in progress.
Dancer supports PSGI/Plack, to run a Dancer app with PSGI/Plack just bootstrap
your application with the helper script `dancer' like the following:

$ dancer -a MyWebApp
$ dancer -a MyWeb::App

You'll find a file in there called `app.psgi', use this file to configure your
PSGI environment, as explained in the revelant documentation of your PSGI
Expand Down
2 changes: 1 addition & 1 deletion lib/Dancer.pm
Expand Up @@ -5,7 +5,7 @@ use warnings;
use Carp;
use Cwd 'realpath';

our $VERSION = '1.3099';
our $VERSION = '1.3100';
our $AUTHORITY = 'SUKRIA';

$VERSION = eval $VERSION;
Expand Down
2 changes: 1 addition & 1 deletion lib/Dancer/Engine.pm
Expand Up @@ -44,7 +44,7 @@ sub build {
my $engine_class =
Dancer::ModuleLoader->class_from_setting($class_name => $name);

raise core_engine => "unknown $type engine '$name', "
raise core_engine => "unable to load $type engine '$name', "
. "perhaps you need to install $engine_class?"
unless Dancer::ModuleLoader->load($engine_class);

Expand Down
16 changes: 8 additions & 8 deletions lib/Dancer/Logger.pm
Expand Up @@ -20,14 +20,14 @@ sub _serialize {
my @vars = @_;

return join q{}, map {
ref $_ ?
Data::Dumper->new([$_])
->Terse(1)
->Purity(1)
->Indent(0)
->Sortkeys(1)
->Dump() :
$_
ref $_
? Data::Dumper->new([$_])
->Terse(1)
->Purity(1)
->Indent(0)
->Sortkeys(1)
->Dump()
: (defined($_) ? $_ : 'undef')
} @vars;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Dancer/Template/Abstract.pm
Expand Up @@ -3,7 +3,7 @@ package Dancer::Template::Abstract;
use strict;
use warnings;
use Carp;
use Storable 'dclone';
use Clone;

use Dancer::Logger;
use Dancer::Factory::Hook;
Expand Down Expand Up @@ -146,18 +146,18 @@ sub _prepare_tokens_options {
$tokens ||= {};
$tokens->{perl_version} = $];
$tokens->{dancer_version} = $Dancer::VERSION;
$tokens->{settings} = dclone(Dancer::Config->settings);
$tokens->{settings} = Clone::clone(Dancer::Config->settings);

# If we're processing a request, also add the request object, params and
# vars as tokens:
if (my $request = Dancer::SharedData->request) {
$tokens->{request} = $request;
$tokens->{params} = dclone($request->params);
$tokens->{vars} = dclone(Dancer::SharedData->vars);
$tokens->{params} = Clone::clone($request->params);
$tokens->{vars} = Clone::clone(Dancer::SharedData->vars);
}

Dancer::App->current->setting('session')
and $tokens->{session} = dclone(Dancer::Session->get);
and $tokens->{session} = Clone::clone(Dancer::Session->get);

return ($tokens, $options);
}
Expand Down
12 changes: 10 additions & 2 deletions lib/Dancer/Test.pm
Expand Up @@ -353,17 +353,25 @@ Content-Type: text/plain

my ($params, $body, $headers) = @$args{qw(params body headers)};

if ($headers and (my @headers = @$headers)) {
my $headers_obj;
if ($headers && _isa($headers, 'HTTP::Headers')){
$headers_obj = $headers;
if ($headers->header('Content_Type')) {
$ENV{'CONTENT_TYPE'} = $headers->remove_header('Content_Type');
}
}
elsif ($headers and (my @headers = @$headers)) {
while (my $h = shift @headers) {
if ($h =~ /content-type/i) {
$ENV{'CONTENT_TYPE'} = shift @headers;
}
}
$headers_obj = HTTP::Headers->new(@$headers);
}

my $request = Dancer::Request->new_for_request(
$method => $path,
$params, $body, HTTP::Headers->new(@$headers)
$params, $body, $headers_obj
);

# first, reset the current state
Expand Down
65 changes: 34 additions & 31 deletions script/dancer
Expand Up @@ -1483,40 +1483,43 @@ the framework for a new Dancer application.
Here is an application created with dancer:
$ dancer -a mywebapp
+ mywebapp
+ mywebapp/bin
+ mywebapp/bin/app.pl
+ mywebapp/config.yml
+ mywebapp/environments
+ mywebapp/environments/development.yml
+ mywebapp/environments/production.yml
+ mywebapp/views
+ mywebapp/views/index.tt
+ mywebapp/views/layouts
+ mywebapp/views/layouts/main.tt
+ mywebapp/lib
+ mywebapp/lib/mywebapp.pm
+ mywebapp/public
+ mywebapp/public/css
+ mywebapp/public/css/style.css
+ mywebapp/public/css/error.css
+ mywebapp/public/images
+ mywebapp/public/500.html
+ mywebapp/public/404.html
+ mywebapp/public/dispatch.fcgi
+ mywebapp/public/dispatch.cgi
+ mywebapp/public/javascripts
+ mywebapp/public/javascripts/jquery.js
+ mywebapp/Makefile.PL
+ mywebapp/t
+ mywebapp/t/002_index_route.t
+ mywebapp/t/001_base.t
$ dancer -a MyWeb::App
+ MyWeb-App
+ MyWeb-App/bin
+ MyWeb-App/bin/app.pl
+ MyWeb-App/config.yml
+ MyWeb-App/environments
+ MyWeb-App/environments/development.yml
+ MyWeb-App/environments/production.yml
+ MyWeb-App/views
+ MyWeb-App/views/index.tt
+ MyWeb-App/views/layouts
+ MyWeb-App/views/layouts/main.tt
+ MyWeb-App/MANIFEST.SKIP
+ MyWeb-App/lib
+ MyWeb-App/lib/MyWeb
+ MyWeb-App/lib/MyWeb/App.pm
+ MyWeb-App/public
+ MyWeb-App/public/css
+ MyWeb-App/public/css/style.css
+ MyWeb-App/public/css/error.css
+ MyWeb-App/public/images
+ MyWeb-App/public/500.html
+ MyWeb-App/public/404.html
+ MyWeb-App/public/dispatch.fcgi
+ MyWeb-App/public/dispatch.cgi
+ MyWeb-App/public/javascripts
+ MyWeb-App/public/javascripts/jquery.js
+ MyWeb-App/t
+ MyWeb-App/t/002_index_route.t
+ MyWeb-App/t/001_base.t
+ MyWeb-App/Makefile.PL
The application is ready to serve:
$ cd mywebapp
$ ./mywebapp.pl
$ cd MyWeb-App
$ ./bin/app.pl
>> Listening on 127.0.0.1:3000
== Entering the development dance floor ...
Expand Down
2 changes: 1 addition & 1 deletion t/01_config/03_logger.t
Expand Up @@ -14,7 +14,7 @@ my $dir = File::Temp::tempdir(CLEANUP => 1, TMPDIR => 1);
set appdir => $dir;

eval { set logger => 'foobar' };
like($@, qr/unknown logger/, 'invalid logger detected');
like($@, qr/unable to load logger/, 'invalid logger detected');

ok(set(logger => 'file'), 'file-based logger correctly set');

Expand Down
2 changes: 1 addition & 1 deletion t/08_session/02_dependency_check.t
Expand Up @@ -50,6 +50,6 @@ is($@, '', "the session engine can be set with CGI::Session");

# load an unknown session engine
eval { set(session => 'galactica') };
like $@, qr/unknown session engine 'galactica'/,
like $@, qr/unable to load session engine 'galactica'/,
"Unknown session engine is refused";

2 changes: 1 addition & 1 deletion t/10_template/01_factory.t
Expand Up @@ -15,7 +15,7 @@ use_ok 'Dancer::Template';
ok(Dancer::Template->init, "template init with undef setting");

eval { setting template => 'FOOOBAR' };
like $@, qr/unknown template engine/, "cannot load unknown template engine";
like $@, qr/unable to load template engine/, "cannot load unknown template engine";

setting template => 'simple';
ok(Dancer::Template->init, "template init with 'simple' setting");
Expand Down
2 changes: 1 addition & 1 deletion t/11_logger/02_factory.t
Expand Up @@ -20,7 +20,7 @@ my $engine = Dancer::Logger->logger;
ok !defined($engine), "engine not defined";

eval { Dancer::Logger->init('foo') };
like $@, qr/unknown logger engine 'foo'/,
like $@, qr/unable to load logger engine 'foo'/,
'unknown logger engine detected';

ok(Dancer::Logger->init('file'), 'logger file initialized');
Expand Down
13 changes: 12 additions & 1 deletion t/12_response/09_headers_to_array.t
@@ -1,7 +1,7 @@
package main;
use strict;
use warnings;
use Test::More tests => 1, import => ['!pass'];
use Test::More tests => 3, import => ['!pass'];

{

Expand All @@ -18,4 +18,15 @@ use Dancer::Test;
response_headers_include [GET => '/'] =>
[ 'Content-Type' => 'text/html', 'A' => 1, 'A' => 2, 'B' => 3 ];

# Dancer::Test::dancer_response does accept an HTTP::Headers object now (issue 755)
use HTTP::Headers;

my $res1 = dancer_response(GET => '/', { headers => HTTP::Headers->new('Content-Type' => 'text/ascii', 'XY' => 'Z')});
is($res1->header('Content-Type'), 'text/html', "Content-Type looks good for dancer_response accepting HTTP::Headers");

my $res2 = dancer_response(GET => '/', { headers => ['Content-Type' => 'text/ascii', 'XY' => 'Z']});

is_deeply($res1->headers_to_array, $res2->headers_to_array, "Headers look good for dancer_response accepting HTTP::Headers");


1;
2 changes: 1 addition & 1 deletion t/14_serializer/01_helpers.t
Expand Up @@ -11,7 +11,7 @@ my $struct = {eris => 23};
# test an unknown serializer
eval { setting serializer => 'FooBar'; };
like $@,
qr/unknown serializer engine 'FooBar', perhaps you need to install Dancer::Serializer::FooBar/,
qr/unable to load serializer engine 'FooBar', perhaps you need to install Dancer::Serializer::FooBar/,
"Foobar is not a valid serializer";
}

Expand Down

0 comments on commit 60acb1a

Please sign in to comment.