From 83c3737484d89a57cfd230d6a4039a269e212035 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sat, 1 Mar 2008 00:36:31 +0000 Subject: [PATCH] Imported upstream version 0.10 --- Changes | 3 ++ MANIFEST | 1 - META.yml | 10 ++++--- Makefile.PL | 5 ++-- README | 62 --------------------------------------- inc/Module/Install.pm | 2 +- inc/Module/Install/AutoInstall.pm | 2 +- inc/Module/Install/Base.pm | 2 +- inc/Module/Install/Can.pm | 2 +- inc/Module/Install/Fetch.pm | 2 +- inc/Module/Install/Include.pm | 2 +- inc/Module/Install/Makefile.pm | 2 +- inc/Module/Install/Metadata.pm | 2 +- inc/Module/Install/Win32.pm | 2 +- inc/Module/Install/WriteAll.pm | 2 +- lib/URI/Template.pm | 17 ++++++----- t/10-basic.t | 12 +++++--- t/11-ordered.t | 8 +++-- t/12-suite.t | 7 +++-- t/20-deparse.t | 12 ++++++-- t/98-pod.t | 2 +- t/99-podcoverage.t | 2 +- 22 files changed, 60 insertions(+), 101 deletions(-) delete mode 100644 README diff --git a/Changes b/Changes index c14ab35..6ba0a19 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension URI::Template +0.10 Wed Jan 16 2007 + - fix test suite for JSON 2.x + 0.09 Tue Aug 28 2007 - minor doc update diff --git a/MANIFEST b/MANIFEST index 31ee7b1..926e9c6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,7 +14,6 @@ lib/URI/Template.pm Makefile.PL MANIFEST This list of files META.yml -README t/01-use.t t/10-basic.t t/11-ordered.t diff --git a/META.yml b/META.yml index 4a4c9cd..9cd5464 100644 --- a/META.yml +++ b/META.yml @@ -1,8 +1,11 @@ --- abstract: Object for handling URI templates -author: Brian Cassidy +author: + - Brian Cassidy +build_requires: + Test::More: 0 distribution_type: module -generated_by: Module::Install version 0.67 +generated_by: Module::Install version 0.68 license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html @@ -13,6 +16,5 @@ no_index: - inc - t requires: - Test::More: 0 URI: 0 -version: 0.09 +version: 0.10 diff --git a/Makefile.PL b/Makefile.PL index 9d387c8..a7295fc 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,10 +1,11 @@ -use inc::Module::Install 0.65; +use inc::Module::Install 0.68; name 'URI-Template'; all_from 'lib/URI/Template.pm'; requires 'URI'; -requires 'Test::More'; + +test_requires 'Test::More'; auto_install; WriteAll; diff --git a/README b/README deleted file mode 100644 index fd4982a..0000000 --- a/README +++ /dev/null @@ -1,62 +0,0 @@ -NAME - URI::Template - Object for handling URI templates - -SYNOPSIS - use URI::Template; - my $template = URI::Template->new( 'http://example.com/{x}' ); - my $uri = $template->process( x => 'y' ); - # uri is a URI object with value 'http://example.com/y' - - my %result = $template->deparse( $uri ); - # %result is ( x => 'y' ) - -DESCRIPTION - This is an initial attempt to provide a wrapper around URI templates as - described at - http://www.ietf.org/internet-drafts/draft-gregorio-uritemplate-01.txt - -INSTALLATION - perl Makefile.PL - make - make test - make install - -METHODS - new( $template ) - Creates a new URI::Template instance with the template passed in as the - first parameter. - - as_string( ) - Returns the original template string. Also used when the object is - stringified. - - variables( ) - Returns an array of unique variable names found in the template. NB: - they are returned in random order. - - all_variables( ) - Returns an array of variable names found as they appear in template -- - in order, duplicates included. - - process( %vars|\@values ) - Given a list of key-value pairs or an array ref of values (for - positional substitution), it will URI escape the values and substitute - them in to the template. Returns a URI object. - - process_to_string( %vars|\@values ) - Processes input like the "process" method, but doesn't inflate the - result to a URI object. - - deparse( $uri ) - Does some rudimentary deparsing of a uri based on the current template. - Returns a hash with the extracted values. - -AUTHOR - Brian Cassidy - -COPYRIGHT AND LICENSE - Copyright 2007 by Brian Cassidy - - This library is free software; you can redistribute it and/or modify it - under the same terms as Perl itself. - diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm index 9d13686..89a8653 100644 --- a/inc/Module/Install.pm +++ b/inc/Module/Install.pm @@ -28,7 +28,7 @@ BEGIN { # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. - $VERSION = '0.67'; + $VERSION = '0.68'; } # Whether or not inc::Module::Install is actually loaded, the diff --git a/inc/Module/Install/AutoInstall.pm b/inc/Module/Install/AutoInstall.pm index c244cb5..3a490fb 100644 --- a/inc/Module/Install/AutoInstall.pm +++ b/inc/Module/Install/AutoInstall.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm index 81fbcb6..49dfde6 100644 --- a/inc/Module/Install/Base.pm +++ b/inc/Module/Install/Base.pm @@ -1,7 +1,7 @@ #line 1 package Module::Install::Base; -$VERSION = '0.67'; +$VERSION = '0.68'; # Suspend handler for "redefined" warnings BEGIN { diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm index 5d1eab8..ec66fdb 100644 --- a/inc/Module/Install/Can.pm +++ b/inc/Module/Install/Can.pm @@ -11,7 +11,7 @@ use ExtUtils::MakeMaker (); use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm index e884477..e0dd6db 100644 --- a/inc/Module/Install/Fetch.pm +++ b/inc/Module/Install/Fetch.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Include.pm b/inc/Module/Install/Include.pm index 574acc8..001d0c6 100644 --- a/inc/Module/Install/Include.pm +++ b/inc/Module/Install/Include.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm index fbc5cb2..17bd8a7 100644 --- a/inc/Module/Install/Makefile.pm +++ b/inc/Module/Install/Makefile.pm @@ -7,7 +7,7 @@ use ExtUtils::MakeMaker (); use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm index b886046..f77d68a 100644 --- a/inc/Module/Install/Metadata.pm +++ b/inc/Module/Install/Metadata.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm index 612dc30..4f808c7 100644 --- a/inc/Module/Install/Win32.pm +++ b/inc/Module/Install/Win32.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm index e1db381..078797c 100644 --- a/inc/Module/Install/WriteAll.pm +++ b/inc/Module/Install/WriteAll.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.68'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/lib/URI/Template.pm b/lib/URI/Template.pm index f31f973..79bffdf 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.09'; +our $VERSION = '0.10'; use URI; use URI::Escape (); @@ -114,7 +114,7 @@ inflate the result to a URI object. sub process_to_string { my $self = shift; - if( ref $_[ 0 ] ) { + if ( ref $_[ 0 ] ) { return $self->_process_by_position( @_ ); } else { @@ -130,7 +130,8 @@ sub _process_by_key { # fix undef vals for my $var ( @vars ) { - $params{ $var } = defined $params{ $var } + $params{ $var } + = defined $params{ $var } ? URI::Escape::uri_escape( $params{ $var }, $unsafe ) : ''; } @@ -167,11 +168,11 @@ sub deparse { my $self = shift; my $uri = shift; - if( !$self->{ deparse_re } ) { - my $templ = $self->as_string; - $self->{ vars_list } = [ $templ =~ /{(.+?)}/g ]; - $templ =~ s/{.+?}/(.+?)/g; - $self->{ deparse_re } = qr/$templ/; + if ( !$self->{ deparse_re } ) { + my $templ = $self->as_string; + $self->{ vars_list } = [ $templ =~ /{(.+?)}/g ]; + $templ =~ s/{.+?}/(.+?)/g; + $self->{ deparse_re } = qr/$templ/; } my @matches = $uri =~ $self->{ deparse_re }; diff --git a/t/10-basic.t b/t/10-basic.t index 4240367..28e8522 100644 --- a/t/10-basic.t +++ b/t/10-basic.t @@ -7,15 +7,19 @@ use_ok( 'URI::Template' ); # fatal - no template provided { - eval { URI::Template->new; }; - ok( $@ ); + eval { URI::Template->new; }; + ok( $@ ); } { my $text = 'http://foo.com/{bar}/{baz}?q=%7B'; my $template = URI::Template->new( $text ); isa_ok( $template, 'URI::Template' ); - is_deeply( [ sort $template->variables ], [ qw( bar baz ) ], 'variables()' ); + is_deeply( + [ sort $template->variables ], + [ qw( bar baz ) ], + 'variables()' + ); is( "$template", $text, 'as_string()' ); { @@ -43,7 +47,7 @@ use_ok( 'URI::Template' ); is( $result, 'http://foo.com/%7Bx%7D/', 'values are uri escaped' ); } { - my $result = $template->process( ); + my $result = $template->process(); is( $result, 'http://foo.com//', 'no value sent' ); } { diff --git a/t/11-ordered.t b/t/11-ordered.t index a160818..c96a184 100644 --- a/t/11-ordered.t +++ b/t/11-ordered.t @@ -9,7 +9,11 @@ use_ok( 'URI::Template' ); my $text = 'http://foo.com/{arg2}/{arg1}'; my $template = URI::Template->new( $text ); isa_ok( $template, 'URI::Template' ); - is_deeply( [ $template->all_variables ], [ qw( arg2 arg1 ) ], 'all_variables()' ); + is_deeply( + [ $template->all_variables ], + [ qw( arg2 arg1 ) ], + 'all_variables()' + ); { my $result = $template->process( [ qw( x y ) ] ); @@ -31,7 +35,7 @@ use_ok( 'URI::Template' ); # test with no values { - my $result = $template->process_to_string( [ ] ); + my $result = $template->process_to_string( [] ); is( $result, 'http://foo.com//', 'process w/ no values' ); } } diff --git a/t/12-suite.t b/t/12-suite.t index 83f0e99..c95931e 100644 --- a/t/12-suite.t +++ b/t/12-suite.t @@ -14,18 +14,19 @@ my @files = glob( 't/data/*.json' ); for my $file ( @files ) { open( my $json, $file ); - my $suite = JSON::jsonToObj( do { local $/; <$json> } ); + my $data = do { local $/; <$json> }; close( $json ); + eval { JSON->VERSION( 2 ) }; + my $suite = $@ ? JSON::jsonToObj( $data ) : JSON::from_json( $data ); my %variables = %{ $suite->{ variables } }; my $count = 0; for my $test ( @{ $suite->{ tests } } ) { my $template = URI::Template->new( $test->{ template } ); - my $result = $template->process( %variables ); + my $result = $template->process( %variables ); $count++; is( $result, $test->{ expected }, "${file}#${count}" ); } } - diff --git a/t/20-deparse.t b/t/20-deparse.t index d6bd543..acb753e 100644 --- a/t/20-deparse.t +++ b/t/20-deparse.t @@ -6,17 +6,23 @@ use Test::More tests => 8; use_ok( 'URI::Template' ); { - my $template = URI::Template->new( 'http://{domain}.com/{dir}/{file}.html' ); + my $template + = URI::Template->new( 'http://{domain}.com/{dir}/{file}.html' ); isa_ok( $template, 'URI::Template' ); my %result = $template->deparse( 'http://example.com/test/1.html' ); - is_deeply( \%result, { domain => 'example', dir => 'test', file => '1' }, 'deparse()' ); + is_deeply( \%result, { domain => 'example', dir => 'test', file => '1' }, + 'deparse()' ); } { my $template = URI::Template->new( 'http://test.com/{x}/{y}/{x}/{y}' ); isa_ok( $template, 'URI::Template' ); my %result = $template->deparse( 'http://test.com/1/2/1/2' ); - is_deeply( \%result, { x => 1, y => 2 }, 'deparse() with multiple values' ); + is_deeply( + \%result, + { x => 1, y => 2 }, + 'deparse() with multiple values' + ); } { diff --git a/t/98-pod.t b/t/98-pod.t index 251640d..4586f7e 100644 --- a/t/98-pod.t +++ b/t/98-pod.t @@ -4,6 +4,6 @@ use Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; +plan skip_all => 'set TEST_POD to enable this test' unless $ENV{ TEST_POD }; all_pod_files_ok(); diff --git a/t/99-podcoverage.t b/t/99-podcoverage.t index ae59d4c..b4b4740 100644 --- a/t/99-podcoverage.t +++ b/t/99-podcoverage.t @@ -4,6 +4,6 @@ use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; +plan skip_all => 'set TEST_POD to enable this test' unless $ENV{ TEST_POD }; all_pod_coverage_ok(); -- 2.11.0