[libcatmandu-perl] 53/101: switch to URI::Escape, rename and cleanup

Jonas Smedegaard dr at jones.dk
Tue Feb 23 13:43:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcatmandu-perl.

commit 2d9b3072c82eda5d29da945c6f5e69578ba6f6a3
Author: Nicolas Steenlant <nicolas.steenlant at ugent.be>
Date:   Tue Jan 19 11:11:32 2016 +0100

    switch to URI::Escape, rename and cleanup
---
 cpanfile                                           |  3 +--
 lib/Catmandu/Fix/{url_decode.pm => uri_decode.pm}  | 22 +++++++++++-----------
 lib/Catmandu/Fix/{url_encode.pm => uri_encode.pm}  | 22 +++++++++++-----------
 ...-Fix-url_decode.t => Catmandu-Fix-uri_decode.t} |  4 ++--
 ...-Fix-url_encode.t => Catmandu-Fix-uri_encode.t} |  4 ++--
 ...e_decode.t => Catmandu-Fix-uri_encode_decode.t} |  6 +++---
 6 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/cpanfile b/cpanfile
index 843d651..aa872a6 100644
--- a/cpanfile
+++ b/cpanfile
@@ -41,11 +41,10 @@ requires 'Time::HiRes', 0; # not always installed?
 requires 'Throwable', '0.200004';
 requires 'Try::Tiny::ByClass', '0.01';
 requires 'URI', 0;
+requires 'URI::Escape', 0;
 requires 'URI::Template', 0;
 requires 'YAML::XS', '0.41';
-requires 'URL::Encode','0';
 
-recommends 'URL::Encode::XS','0';
 recommends 'Log::Log4perl', '1.44';
 recommends 'Log::Any::Adapter::Log4perl', '0.06';
 
diff --git a/lib/Catmandu/Fix/url_decode.pm b/lib/Catmandu/Fix/uri_decode.pm
similarity index 56%
rename from lib/Catmandu/Fix/url_decode.pm
rename to lib/Catmandu/Fix/uri_decode.pm
index a6ec8d9..5b5470a 100644
--- a/lib/Catmandu/Fix/url_decode.pm
+++ b/lib/Catmandu/Fix/uri_decode.pm
@@ -1,8 +1,10 @@
-package Catmandu::Fix::url_decode;
+package Catmandu::Fix::uri_decode;
+
 use Catmandu::Sane;
 use Moo;
+use URI::Escape ();
+use namespace::clean;
 use Catmandu::Fix::Has;
-use URL::Encode;
 
 has path => (fix_arg => 1);
 
@@ -10,31 +12,29 @@ with 'Catmandu::Fix::SimpleGetValue';
 
 sub emit_value {
     my ($self, $var) = @_;
-    "${var} = URL::Encode::url_decode_utf8( ${var} );";
+    "${var} = URI::Escape::uri_unescape(${var});";
 }
 
 1;
 
+__END__
+
 =pod
 
 =head1 NAME
 
-Catmandu::Fix::url_decode - url decode a string
+Catmandu::Fix::uri_decode - percent decode a URI
 
 =head1 SYNOPSIS
 
     # '3%A9' => 'café'
-    url_decode(place)
+    uri_decode(place)
 
     # '%E1%BD%81+%CF%84%E1%BF%B6%CE%BD+%CE%A0%CE%AD%CF%81%CF%83%CF%89%CE%BD+%CE%B2%CE%B1%CF%83%CE%B9%CE%BB%CE%B5%CF%8D%CF%82' => 'ὁ τῶν Πέρσων βασιλεύς'
-    url_decode(title)
+    uri_decode(title)
 
 =head1 SEE ALSO
 
-L<Catmandu::Fix>, L<Catmandu::Fix::url_encode>, L<URL::Encode>
-
-=head1 AUTHOR
-
-Nicolas Franck, C<< <nicolas.franck at ugent.be> >>
+L<Catmandu::Fix>, L<Catmandu::Fix::uri_encode>, L<URI::Escape>
 
 =cut
diff --git a/lib/Catmandu/Fix/url_encode.pm b/lib/Catmandu/Fix/uri_encode.pm
similarity index 56%
rename from lib/Catmandu/Fix/url_encode.pm
rename to lib/Catmandu/Fix/uri_encode.pm
index af64afd..88ddb70 100644
--- a/lib/Catmandu/Fix/url_encode.pm
+++ b/lib/Catmandu/Fix/uri_encode.pm
@@ -1,8 +1,10 @@
-package Catmandu::Fix::url_encode;
+package Catmandu::Fix::uri_encode;
+
 use Catmandu::Sane;
 use Moo;
+use URI::Escape ();
+use namespace::clean;
 use Catmandu::Fix::Has;
-use URL::Encode;
 
 has path => (fix_arg => 1);
 
@@ -10,32 +12,30 @@ with 'Catmandu::Fix::SimpleGetValue';
 
 sub emit_value {
     my ($self, $var) = @_;
-    "${var} = URL::Encode::url_encode_utf8( ${var} );";
+    "${var} = URI::Escape::uri_escape_utf8(${var});";
 }
 
 1;
 
+__END__
+
 =pod
 
 =head1 NAME
 
-Catmandu::Fix::url_encode - url encode a string
+Catmandu::Fix::uri_encode - percent encode a URI
 
 =head1 SYNOPSIS
 
     # 'café' => '3%A9'
-    url_encode(place)
+    uri_encode(place)
 
     # 'ὁ τῶν Πέρσων βασιλεύς' => '%E1%BD%81+%CF%84%E1%BF%B6%CE%BD+%CE%A0%CE%AD%CF%81%CF%83%CF%89%CE%BD+%CE%B2%CE%B1%CF%83%CE%B9%CE%BB%CE%B5%CF%8D%CF%82'
-    url_encode(title)
+    uri_encode(title)
 
 =head1 SEE ALSO
 
-L<Catmandu::Fix>, L<Catmandu::Fix::url_decode>, L<URL::Encode>
-
-=head1 AUTHOR
-
-Nicolas Franck, C<< <nicolas.franck at ugent.be> >>
+L<Catmandu::Fix>, L<Catmandu::Fix::uri_decode>, L<URI::Escape>
 
 =cut
 
diff --git a/t/Catmandu-Fix-url_decode.t b/t/Catmandu-Fix-uri_decode.t
similarity index 90%
rename from t/Catmandu-Fix-url_decode.t
rename to t/Catmandu-Fix-uri_decode.t
index 6779e79..97472ab 100644
--- a/t/Catmandu-Fix-url_decode.t
+++ b/t/Catmandu-Fix-uri_decode.t
@@ -7,7 +7,7 @@ use Test::Exception;
 
 my $pkg;
 BEGIN {
-    $pkg = 'Catmandu::Fix::url_decode';
+    $pkg = 'Catmandu::Fix::uri_decode';
     use_ok $pkg;
 }
 
@@ -21,4 +21,4 @@ is_deeply
     {name => "ὁ τῶν Πέρσων βασιλεύς"},
     "unescape utf8 string from Greek";
 
-done_testing 3;
+done_testing;
diff --git a/t/Catmandu-Fix-url_encode.t b/t/Catmandu-Fix-uri_encode.t
similarity index 90%
rename from t/Catmandu-Fix-url_encode.t
rename to t/Catmandu-Fix-uri_encode.t
index ae1d3d1..899f649 100644
--- a/t/Catmandu-Fix-url_encode.t
+++ b/t/Catmandu-Fix-uri_encode.t
@@ -7,7 +7,7 @@ use Test::Exception;
 
 my $pkg;
 BEGIN {
-    $pkg = 'Catmandu::Fix::url_encode';
+    $pkg = 'Catmandu::Fix::uri_encode';
     use_ok $pkg;
 }
 
@@ -21,4 +21,4 @@ is_deeply
     {name => "%E1%BD%81+%CF%84%E1%BF%B6%CE%BD+%CE%A0%CE%AD%CF%81%CF%83%CF%89%CE%BD+%CE%B2%CE%B1%CF%83%CE%B9%CE%BB%CE%B5%CF%8D%CF%82"},
     "escape utf8 string from Greek";
 
-done_testing 3;
+done_testing;
diff --git a/t/Catmandu-Fix-url_encode_decode.t b/t/Catmandu-Fix-uri_encode_decode.t
similarity index 85%
rename from t/Catmandu-Fix-url_encode_decode.t
rename to t/Catmandu-Fix-uri_encode_decode.t
index 9771b70..62c4875 100644
--- a/t/Catmandu-Fix-url_encode_decode.t
+++ b/t/Catmandu-Fix-uri_encode_decode.t
@@ -8,9 +8,9 @@ use Test::Exception;
 my $pkg1;
 my $pkg2;
 BEGIN {
-    $pkg1 = 'Catmandu::Fix::url_encode';
+    $pkg1 = 'Catmandu::Fix::uri_encode';
     use_ok $pkg1;
-    $pkg2 = 'Catmandu::Fix::url_decode';
+    $pkg2 = 'Catmandu::Fix::uri_decode';
     use_ok $pkg2;
 }
 
@@ -29,4 +29,4 @@ is_deeply
     { name => "ὁ τῶν Πέρσων βασιλεύς" },
     "escape and unescape Greek";
 
-done_testing 4;
+done_testing;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git



More information about the Pkg-perl-cvs-commits mailing list