Imported Upstream version 0.22 upstream upstream/0.22
authorIan Beckwith <ianb@erislabs.net>
Sat, 28 Nov 2015 02:26:37 +0000 (02:26 +0000)
committerIan Beckwith <ianb@erislabs.net>
Sat, 28 Nov 2015 02:26:37 +0000 (02:26 +0000)
Changes
MANIFEST
META.yml
lib/URI/Template.pm
t/gh-4.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index fd063b5..4c4f3b3 100644 (file)
--- 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)
index 3f58770..875dae3 100644 (file)
--- 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
index 1f7f984..3ef599d 100644 (file)
--- 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
index 0069457..24c01f1 100644 (file)
@@ -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 (file)
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' );
+}
+