Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/1.3079_03'

  • Loading branch information...
commit e89439346f873fdc70f9eea7a647674dfccca488 2 parents 3a02025 + f42ee0a
Alexis Sukrieh authored
View
13 CHANGES
@@ -1,4 +1,15 @@
-{{$NEXT}}
+1.3079_03 10.09.2011
+
+ [ ENHANCEMENTS ]
+ * Support XML::Simple configuration for serializing/deserializing
+ (Alberto Simões)
+ * Hard deprecate lots of stuff (Alberto Simões)
+
+ [ BUG FIXES ]
+ * Don't clobber TT INCLUDE_PATH if the user set it specifically in the
+ config file - Issue 643 (David Precious, reported by meraxes)
+ * Don't require a space after semi-colon delimiting multiple name=value
+ cookie pairs - Issue 642 (David Precious, reported by travisbeck)
1.3079_02 28.08.2011
View
19 lib/Dancer.pm
@@ -5,7 +5,7 @@ use warnings;
use Carp;
use Cwd 'realpath';
-our $VERSION = '1.3079_02';
+our $VERSION = '1.3079_03';
our $AUTHORITY = 'SUKRIA';
use Dancer::App;
@@ -129,13 +129,13 @@ sub hook { Dancer::Hook->new(@_) }
sub layout {
Dancer::Deprecation->deprecated(reason => "use 'set layout => \"value\"'",
version => '1.3050',
- fatal => 0);
- set(layout => shift) }
+ fatal => 1);
+}
sub load { require $_ for @_ }
sub load_app { goto &_load_app } # goto doesn't add a call frame. So caller() will work as expected
sub logger {
- Dancer::Deprecation->deprecated(reason => "use 'set logger'",fatal => 0,version=>'1.3050');
- set(logger => @_)
+ Dancer::Deprecation->deprecated(reason => "use 'set logger => \"value\"'",
+ fatal => 1,version=>'1.3050');
}
sub mime { Dancer::MIME->instance() }
sub options { Dancer::App->current->registry->universal_add('options', @_) }
@@ -258,10 +258,11 @@ sub _init_script_dir {
my $LAYOUT_PRE_DANCER_1_2 = 1;
- # in bin/ or public/ we need to go one level upper to find the appdir
+ # in bin/ or public/ or t/ we need to go one level upper to find the appdir
$LAYOUT_PRE_DANCER_1_2 = 0
if ($script_dirs[$#script_dirs - 1] eq 'bin')
- or ($script_dirs[$#script_dirs - 1] eq 'public');
+ or ($script_dirs[$#script_dirs - 1] eq 'public')
+ or ($script_dirs[$#script_dirs - 1] eq 't');
my $appdir = $ENV{DANCER_APPDIR} || (
$LAYOUT_PRE_DANCER_1_2
@@ -1071,10 +1072,6 @@ To load multiple apps repeat load_app:
The old way of loading multiple apps in one go (load_app 'one', 'two';) is
deprecated.
-=head2 mime_type
-
-Deprecated. See L</mime>.
-
=head2 mime
Shortcut to access the instance object of L<Dancer::MIME>. You should
View
2  lib/Dancer/Cookbook.pod
@@ -492,7 +492,7 @@ interpolate in the view (note that for convenience, the request, session, params
and vars are automatically accessible in the view, named C<request>, C<session>,
C<params> and C<vars>) - for example:
- before => sub { var time => localtime() };
+ before => sub { var time => scalar(localtime) };
get '/hello/:name' => sub {
my $name = params->{name};
View
2  lib/Dancer/Cookies.pm
@@ -31,7 +31,7 @@ sub parse_cookie_from_env {
return {} unless defined $env_str;
my $cookies = {};
- foreach my $cookie ( split( /[,;]\s/, $env_str ) ) {
+ foreach my $cookie ( split( /[,;]\s?/, $env_str ) ) {
# here, we don't want more than the 2 first elements
# a cookie string can contains something like:
# cookie_name="foo=bar"
View
20 lib/Dancer/Deployment.pod
@@ -21,23 +21,27 @@ sites-available/*site*):
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /srv/www.example.com/public
- ServerAdmin you@example.com
+ ServerAdmin you@example.com
- <Directory "/srv/www.example.com/public">
+ <Directory "/srv/www.example.com/public">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
- </Directory>
+ </Directory>
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^(.*)$ /dispatch.fcgi$1 [QSA,L]
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.*)$ /dispatch.cgi$1 [QSA,L]
ErrorLog /var/log/apache2/www.example.com-error.log
CustomLog /var/log/apache2/www.example.com-access_log common
- </VirtualHost>
+ </VirtualHost>
+
+Note that when using fast-cgi your rewrite rule should be:
+
+ RewriteRule ^(.*)$ /dispatch.fcgi$1 [QSA,L]
Here, the mod_rewrite magic for Pretty-URLs is directly put in Apache's configuration.
But if your web server supports .htaccess files, you can drop those lines in a .htaccess file.
@@ -77,7 +81,7 @@ Of course remember to update your rewrite rules, if you have set any:
=head2 Running stand-alone
At the simplest, your Dancer app can run standalone, operating as its own
-webserver using HTTP::Simple::PSGI.
+webserver using HTTP::Server::Simple::PSGI.
Simply fire up your app:
View
3  lib/Dancer/FileUtils.pm
@@ -102,8 +102,7 @@ sub normalize_path {
}x;
$path =~ s{/\./}{/}g;
- $path =~ s{$seqregex}{}g;
- $path =~ s{$seqregex}{};
+ while ( $path =~ s{$seqregex}{} ) {}
return $path;
}
View
2  lib/Dancer/Introduction.pod
@@ -621,7 +621,7 @@ This is a possible webapp created with Dancer:
};
get '/hello/:name' => sub {
- "Hello ".params->{name}"
+ "Hello ".params->{name};
};
# run the webserver
View
33 lib/Dancer/MIME.pm
@@ -5,7 +5,6 @@ use warnings;
use base 'Dancer::Object::Singleton';
use Dancer::Config;
-use Dancer::Deprecation;
use Carp;
use MIME::Types;
@@ -65,24 +64,6 @@ sub for_name {
return $self->custom_types->{lc $name} || $self->mime_type->mimeTypeOf(lc $name) || $self->default;
}
-sub add_mime_type {
- Dancer::Deprecation->deprecated(feature => 'add_mime_type',
- fatal => 1,
- reason => 'use the new "add" method');
-}
-
-sub add_mime_alias {
- Dancer::Deprecation->deprecated(feature => 'add_mime_alias',
- fatal => 1,
- reason => 'use the new "add_alias" method');
-}
-
-sub mime_type_for {
- Dancer::Deprecation->deprecated(feature => 'mime_type_for',
- fatal => 1,
- reason => 'use the new "name_or_type" method');
-}
-
42;
@@ -165,20 +146,6 @@ Retrieve the full hash table of added mime types.
Resolves the $thing into a content $type whether it's the name of a
MIME type like "txt" or already a mime type like "text/plain".
-=head1 DEPRECATED API
-
-=head2 add_mime_type
-
-Check the new C<add> method.
-
-=head2 add_mime_alias
-
-Check the new C<add> method.
-
-=head2 mime_type_for
-
-Check the new C<for_name> and C<name_or_type> methods.
-
=head1 AUTHORS
This module has been written and rewritten by different people from
View
25 lib/Dancer/Plugin.pm
@@ -34,14 +34,20 @@ sub register($&) {
my $plugin_name = caller();
$keyword =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/
- or croak "You can't use '$keyword', it is an invalid name (it should match ^[a-zA-Z_]+[a-zA-Z0-9_]*$ )";
-
- if (grep { $_ eq $keyword } map { s/^(?:\$|%|&|@|\*)//; $_ } (@Dancer::EXPORT, @Dancer::EXPORT_OK)) {
+ or croak "You can't use '$keyword', it is an invalid name"
+ . " (it should match ^[a-zA-Z_]+[a-zA-Z0-9_]*$ )";
+
+ if (
+ grep { $_ eq $keyword }
+ map { s/^(?:\$|%|&|@|\*)//; $_ }
+ (@Dancer::EXPORT, @Dancer::EXPORT_OK)
+ ) {
croak "You can't use '$keyword', this is a reserved keyword";
}
while (my ($plugin, $keywords) = each %$_keywords) {
if (grep { $_->[0] eq $keyword } @$keywords) {
- croak "You can't use $keyword, this is a keyword reserved by $plugin";
+ croak "You can't use $keyword, "
+ . "this is a keyword reserved by $plugin";
}
}
@@ -151,13 +157,20 @@ A Dancer plugin inherits from Dancer::Plugin and Exporter transparently.
=item B<plugin_setting>
-Configuration for plugin should be structured like this in the config.yaml of the application:
+Configuration for plugin should be structured like this in the config.yml of
+the application:
plugins:
plugin_name:
key: value
-If plugin_setting is called inside a plugin, the appropriate configuration will be returned. The plugin_name should be the name of the package, or, if the plugin name is under the B<Dancer::Plugin::> namespace, the remaining part of the plugin name. Enclose the remaining part in quotes if it contains ::, e.g. for B<Dancer::Plugin::Foo::Bar>, use:
+If C<plugin_setting> is called inside a plugin, the appropriate configuration
+will be returned. The C<plugin_name> should be the name of the package, or,
+if the plugin name is under the B<Dancer::Plugin::> namespace (which is
+recommended), the remaining part of the plugin name.
+
+Enclose the remaining part in quotes if it contains ::, e.g.
+for B<Dancer::Plugin::Foo::Bar>, use:
plugins:
"Foo::Bar":
View
2  lib/Dancer/Request.pm
@@ -37,7 +37,7 @@ sub new {
if (@args == 1) {
@args = ('env' => $args[0]);
Dancer::Deprecation->deprecated(
- fatal => 0,
+ fatal => 1,
feature => 'Calling Dancer::Request->new($env)',
version => 1.3059,
reason => 'Please use Dancer::Request->new( env => $env ) instead',
View
2  lib/Dancer/Serializer/JSON.pm
@@ -77,9 +77,9 @@ sub _options_as_hashref {
else {
Dancer::Deprecation->deprecated(
version => '1.3002',
+ fatal => 1,
message => 'options as hash for to_json/from_json is DEPRECATED. please pass a hashref',
);
- return { @_ };
}
}
View
35 lib/Dancer/Serializer/XML.pm
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Carp;
use Dancer::ModuleLoader;
+use Dancer::Config 'setting';
use base 'Dancer::Serializer::Abstract';
# singleton for the XML::Simple object
@@ -45,13 +46,31 @@ sub init {
sub serialize {
my $self = shift;
my $entity = shift;
- my %options = (RootName => 'data', @_);
+ my %options = (RootName => 'data');
+
+ my $s = setting('engines') || {};
+ if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{serialize})) {
+ %options = (%options, %{$s->{XMLSerializer}{serialize}});
+ }
+
+ %options = (%options, @_);
+
+
$_xs->XMLout($entity, %options);
}
sub deserialize {
my $self = shift;
- $_xs->XMLin(@_);
+ my $xml = shift;
+ my %options = ();
+
+ my $s = setting('engines') || {};
+ if (exists($s->{XMLSerializer}) && exists($s->{XMLSerializer}{deserialize})) {
+ %options = (%options, %{$s->{XMLSerializer}{deserialize}});
+ }
+
+ %options = (%options, @_);
+ $_xs->XMLin($xml, %options);
}
sub content_type {'text/xml'}
@@ -80,3 +99,15 @@ Deserialize a XML structure to a data structure
=head2 content_type
Return 'text/xml'
+
+=head2 CONFIG FILE
+
+You can set XML::Simple options for serialize and deserialize in the
+config file:
+
+ engines:
+ XMLSerializer:
+ serialize:
+ AttrIndent: 1
+ deserialize:
+ ForceArray: 1
View
12 lib/Dancer/Template/Abstract.pm
@@ -5,7 +5,6 @@ use warnings;
use Carp;
use Dancer::Factory::Hook;
-use Dancer::Deprecation;
use Dancer::FileUtils 'path';
use base 'Dancer::Engine';
@@ -123,17 +122,6 @@ sub _prepare_tokens_options {
return ($tokens, $options);
}
-sub _render_with_layout {
- my ($class, $content, $tokens, $options) = @_;
-
- Dancer::Deprecation::deprecated(
- feature => 'render_with_layout',
- version => '1.3000',
- fatal => 1,
- reason => "use the 'engine' keyword to get the template engine, and use 'apply_layout' on the result",
- );
-}
-
sub template {
my ($class, $view, $tokens, $options) = @_;
my ($content, $full_content);
View
2  lib/Dancer/Template/TemplateToolkit.pm
@@ -38,7 +38,7 @@ sub init {
$tt_config->{START_TAG} = $start_tag if $start_tag ne '[%';
$tt_config->{END_TAG} = $stop_tag if $stop_tag ne '%]';
- $tt_config->{INCLUDE_PATH} = setting('views');
+ $tt_config->{INCLUDE_PATH} ||= setting('views');
$_engine = $class->new(%$tt_config);
}
View
37 lib/Dancer/Test.pm
@@ -122,38 +122,18 @@ sub route_doesnt_exist {
sub response_exists {
Dancer::Deprecation->deprecated(
- fatal => 0,
+ fatal => 1,
feature => 'response_exists',
reason => 'Use response_status_isnt and check for status 404.'
);
- my ($req, $test_name) = @_;
-
- $test_name ||= "a response is found for " . _req_label($req);
-
- my $response = _req_to_response( $req );
-
- # goto used so that the test reports
- # the correct test line
- @_ = ( $response, 404, $test_name );
- goto &response_status_isnt;
}
sub response_doesnt_exist {
Dancer::Deprecation->deprecated(
- fatal => 0,
+ fatal => 1,
feature => 'response_doesnt_exist',
reason => 'Use response_status_is and check for status 404.',
);
- my ($req, $test_name) = @_;
-
- $test_name ||= "no response found for " . _req_label($req);
-
- my $response = _req_to_response($req);
-
- # goto used so that the test reports
- # the correct test line
- @_ = ( $response, 404, $test_name );
- goto &response_status_is;
}
sub response_status_is {
@@ -384,14 +364,6 @@ Content-Type: text/plain
(defined $response && $response->exists) ? return $response : return undef;
}
-sub get_response {
- Dancer::Deprecation->deprecated(
- fatal => 1,
- feature => 'get_response',
- reason => 'Use dancer_response() instead.',
- );
-}
-
# private
sub _url_encode {
@@ -594,11 +566,6 @@ It's possible to test file uploads:
$response = dancer_reponse(POST => '/upload', {files => [{name => 'image', filename => '/path/to/image.jpg}]});
-=head2 get_response([$method, $path])
-
-This method is B<DEPRECATED>. Use dancer_response() instead.
-
-
=head2 read_logs
my $logs = read_logs;
View
5 t/00_base/normalize_path.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 10;
use Dancer::FileUtils 'normalize_path';
my %paths = (
@@ -12,6 +12,9 @@ my %paths = (
'one/two/three/../' => 'one/two/',
'/one/two/three/../' => '/one/two/',
'one/./two/./three/' => 'one/two/three/',
+ 'a/../b' => 'b',
+ 'a/b/../../c' => 'c',
+ 'a/b/c/../../../d' => 'd',
);
foreach my $path ( keys %paths ) {
View
28 t/14_serializer/01_helpers.t
@@ -3,7 +3,7 @@ use strict;
use warnings;
use Dancer ':tests';
-plan tests => 55;
+plan tests => 52;
my $struct = {eris => 23};
@@ -43,7 +43,7 @@ SKIP: {
}
SKIP: {
- skip 'JSON is needed to run this test', 16
+ skip 'JSON is needed to run this test', 11
unless Dancer::ModuleLoader->load('JSON');
# helpers syntax
@@ -89,18 +89,18 @@ SKIP: {
my $res = $s->serialize($data);
is_deeply( $data, JSON::decode_json($res), 'data is correctly serialized' );
- # XXX tests for deprecation
- my $warn;
- local $SIG{__WARN__} = sub { $warn = $_[0] };
- $s->_options_as_hashref( foo => 'bar' );
- ok $warn, 'deprecation warning';
- undef $warn;
+ # # XXX tests for deprecation
+ # my $warn;
+ # local $SIG{__WARN__} = sub { $warn = $_[0] };
+ # $s->_options_as_hashref( foo => 'bar' );
+ # ok $warn, 'deprecation warning';
+ # undef $warn;
- $s->_options_as_hashref( { foo => 'bar' } );
- ok !$warn, 'no deprecation warning';
+ # $s->_options_as_hashref( { foo => 'bar' } );
+ # ok !$warn, 'no deprecation warning';
- to_json( { foo => 'bar' }, indent => 0 );
- ok $warn, 'deprecation warning';
+ # to_json( { foo => 'bar' }, { indent => 0 } );
+ # ok $warn, 'deprecation warning';
}
SKIP: {
@@ -120,7 +120,7 @@ SKIP: {
like $xml, qr/<eris>23<\/eris>/, "data is correctly serialized";
my $data = from_xml($xml);
- is $data, 23, "data is correctly serialized";
+ is $data, 23, "data is correctly deserialized";
$data = {
task => {
@@ -133,7 +133,7 @@ SKIP: {
};
$xml = to_xml($data, RootName => undef, AttrIndent => 1);
- like $xml, qr/type="files">46210660-b78f-11df-8d81-0800200c9a66<files>/, 'xml attributes are indented';
+ like $xml, qr/\n\s+\w+="\w+">46210660-b78f-11df-8d81-0800200c9a66<files>/, 'xml attributes are indented';
# OO API
setting( 'serializer' => 'XML' );
View
5 t/23_dancer_tests/01_basic.t
@@ -1,4 +1,4 @@
-use Test::More import => ['!pass'], tests => 21;
+use Test::More import => ['!pass'], tests => 20;
use strict;
use warnings;
@@ -34,9 +34,6 @@ response_content_unlike $req => qr{Goodbye};
response_headers_include [GET => '/with_headers'], [ 'Content-Type' => 'text/html' ];
response_headers_include [GET => '/with_headers'], [ 'X-Foo-Dancer' => '42' ];
-eval { get_response($req) };
-like $@, qr/get_response.*has been deprecated. use dancer_response.*instead/i,
- "DEPRECATED warning triggered by get_response()";
my $resp = dancer_response(@$req);
is $resp->{status}, 200, "response status from dancer_response looks good";
Please sign in to comment.
Something went wrong with that request. Please try again.