Permalink
Browse files

Merge branch 'release/0.004'

  • Loading branch information...
2 parents 800c830 + a86cbae commit 63f70a3a884f9611efe538d1da3a0f69a8c0816d @cwimmer committed Oct 30, 2012
Showing with 36 additions and 10 deletions.
  1. +5 −2 Changes
  2. +15 −2 dist.ini
  3. +10 −4 lib/WWW/Shorten/Yahooit.pm
  4. +6 −2 t/001_shorten.t
View
@@ -1,8 +1,11 @@
{{$NEXT}}
-- Created explicit dependence on WWW::Shorten::generi
+- Fixed a new failure in testing. Yahoo! no longer permits shortening URLs which redirect with a 3xx HTTP response code.
+
+0.003
+- Created explicit dependence on WWW::Shorten::generic.
0.002
- Fixed bug with missing variable.
0.001
-- Initial revision includes select and insert functionality with tests.
+- Initial revision includes select and insert functionality with tests.
View
@@ -4,9 +4,21 @@ license = BSD
copyright_holder = Charles A. Wimmer
copyright_year = 2012
-version = 0.003
+version = 0.004
-[@Basic]
+[GatherDir]
+[PruneCruft]
+[ManifestSkip]
+[MetaYAML]
+[License]
+[ExtraTests]
+[ExecDir]
+[ShareDir]
+[MakeMaker]
+[Manifest]
+[TestRelease]
+[ConfirmRelease]
+[UploadToCPAN]
[MetaResources]
repository.web = http://github.com/cwimmer/WWW-Shorten-Yahooit
repository.url = git://github.com/cwimmer/WWW-Shorten-Yahooit.git
@@ -29,3 +41,4 @@ format = %-9v
[PodWeaver]
[PodVersion]
[Test::Compile]
+[ReadmeFromPod]
View
@@ -38,8 +38,11 @@ sub makeashorterlink{
my $yql = WWW::YQL->new();
my $data = $yql->query("insert into yahoo.y.ahoo.it (url) values ('".$url."')");
-
- return $data->{'query'}->{'results'}->{'url'};
+ if (defined $data->{'query'}->{'results'}->{'error'}){
+ die $data->{'query'}->{'results'}->{'error'};
+ }else{
+ return $data->{'query'}->{'results'}->{'url'};
+ }
}
=method makealongerlink
@@ -53,7 +56,10 @@ sub makealongerlink{
my $url = shift or croak 'No URL passed to makeashorterlink';
my $yql = WWW::YQL->new();
my $data = $yql->query("select * from yahoo.y.ahoo.it where url='".$url."'");
- return $data->{'query'}->{'results'}->{'url'};
-
+ if (defined $data->{'query'}->{'results'}->{'error'}){
+ die $data->{'query'}->{'results'}->{'error'};
+ }else{
+ return $data->{'query'}->{'results'}->{'url'};
+ }
}
1;
View
@@ -1,4 +1,4 @@
-use Test::More tests => 7;
+use Test::More tests => 8;
BEGIN { use_ok WWW::Shorten::Yahooit };
@@ -7,11 +7,15 @@ my $return = makeashorterlink($url);
is ( makeashorterlink($url), $return, 'make it shorter');
is ( makealongerlink($return), $url, 'make it longer');
-$url = 'http://wimmer.net/';
+$url = 'http://www.wimmer.net/';
$return = makeashorterlink($url);
is ( makeashorterlink($url), $return, 'make it shorter');
is ( makealongerlink($return), $url, 'make it longer');
+$url = 'http://wimmer.net/';
+eval { &makeashorterlink($url) };
+ok($@, 'makeashorterlink files with a 3xx URL');
+
eval { &makeashorterlink() };
ok($@, 'makeashorterlink fails with no args');
eval { &makealongerlink() };

0 comments on commit 63f70a3

Please sign in to comment.