From fc9466752f05a9a897e009307dc89917562ceda3 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sat, 28 Nov 2015 02:26:37 +0000 Subject: [PATCH] Imported Upstream version 0.22 --- Changes | 3 +++ MANIFEST | 1 + META.yml | 2 +- lib/URI/Template.pm | 5 +++-- t/gh-4.t | 18 ++++++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 t/gh-4.t diff --git a/Changes b/Changes index fd063b5..4c4f3b3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension URI::Template +0.22 2015-04-04 + - Fix regression in variables() when called in list context (GH #4) + 0.21 2015-01-08 - variables() now returns items in their order of appearance (Artem Krivopolenov) diff --git a/MANIFEST b/MANIFEST index 3f58770..875dae3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -23,3 +23,4 @@ t/cases/negative-tests.json t/cases/spec-examples-by-section.json t/cases/spec-examples.json t/cases/transform-json-tests.xslt +t/gh-4.t diff --git a/META.yml b/META.yml index 1f7f984..3ef599d 100644 --- a/META.yml +++ b/META.yml @@ -27,4 +27,4 @@ requires: resources: license: http://dev.perl.org/licenses/ repository: http://github.com/bricas/uri-template -version: 0.21 +version: 0.22 diff --git a/lib/URI/Template.pm b/lib/URI/Template.pm index 0069457..24c01f1 100644 --- a/lib/URI/Template.pm +++ b/lib/URI/Template.pm @@ -3,7 +3,7 @@ package URI::Template; use strict; use warnings; -our $VERSION = '0.21'; +our $VERSION = '0.22'; use URI; use URI::Escape (); @@ -303,7 +303,8 @@ sub template { } sub variables { - return sort {$_[ 0 ]->{ _vars }->{ $a } <=> $_[ 0 ]->{ _vars }->{ $b } } keys %{ $_[ 0 ]->{ _vars } }; + my @vars = sort {$_[ 0 ]->{ _vars }->{ $a } <=> $_[ 0 ]->{ _vars }->{ $b } } keys %{ $_[ 0 ]->{ _vars } }; + return @vars; } sub expansions { diff --git a/t/gh-4.t b/t/gh-4.t new file mode 100644 index 0000000..a0b5e66 --- /dev/null +++ b/t/gh-4.t @@ -0,0 +1,18 @@ +use strict; +use warnings; + +use Test::More tests => 4; + +use_ok( 'URI::Template' ); + +# variables w/ context +{ + my $text = 'http://foo.com/{bar}/{baz}?{foo}=%7B&{abr}=1'; + my $template = URI::Template->new( $text ); + isa_ok( $template, 'URI::Template' ); + my @l_vars = $template->variables; + is_deeply( \@l_vars, [ 'bar', 'baz', 'foo', 'abr' ], 'variables() in list context' ); + my $s_vars = $template->variables; + is( $s_vars, 4, 'variables() in scalar context' ); +} + -- 2.11.0