[Bps-public-commit] r17605 - in Net-Google-Code/trunk: lib/Net/Google/Code
fayland at bestpractical.com
fayland at bestpractical.com
Wed Jan 7 02:00:57 EST 2009
Author: fayland
Date: Wed Jan 7 02:00:57 2009
New Revision: 17605
Modified:
Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm
Net-Google-Code/trunk/t/10.downloads.t
Log:
more entry things.
Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm (original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm Wed Jan 7 02:00:57 2009
@@ -53,7 +53,16 @@
my $url = "http://code.google.com/p/$project/downloads/detail?name=$filename";
my $content = $connection->_fetch( $url );
-
+ require HTML::TreeBuilder;
+ my $tree = HTML::TreeBuilder->new;
+ $tree->parse_content($content);
+ $tree->elementify;
+
+ my ($upload_time) = $tree->look_down(class => 'date')->attr('title');
+
+ return {
+ upload_time => $upload_time,
+ };
}
no Moose;
@@ -87,6 +96,12 @@
Get all download entries from the Atom feed
+=head2 entry
+
+ $download->entry( $entries[0]->{filename} ); # 'Net-Google-Code-0.01.tar.gz'
+
+get an entry details
+
=head1 AUTHOR
Fayland Lam, C<< <fayland at gmail.com> >>
Modified: Net-Google-Code/trunk/t/10.downloads.t
==============================================================================
--- Net-Google-Code/trunk/t/10.downloads.t (original)
+++ Net-Google-Code/trunk/t/10.downloads.t Wed Jan 7 02:00:57 2009
@@ -3,12 +3,10 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::MockModule;
use FindBin qw/$Bin/;
-# http://code.google.com/feeds/p/net-google-code/downloads/basic
-
my $feed_file = "$Bin/sample/10.download.xml";
my $down_file = "$Bin/sample/10.download.html";
@@ -30,7 +28,7 @@
( undef, my $uri ) = @_;
if ( $uri eq 'http://code.google.com/feeds/p/net-google-code/downloads/basic' ) {
return $feed_content;
- } elsif ( $uri eq 'http://code.google.com/p/net-google-code/downloads/detail?name=Net-Google-Code-0.01.tar.gz#makechanges' ) {
+ } elsif ( $uri eq 'http://code.google.com/p/net-google-code/downloads/detail?name=Net-Google-Code-0.01.tar.gz' ) {
return $download_content;
}
}
@@ -41,7 +39,7 @@
my $connection = Net::Google::Code::Connection->new( project => 'net-google-code' );
my $downloads = Net::Google::Code::Downloads->new( connection => $connection );
isa_ok( $downloads, 'Net::Google::Code::Downloads' );
-isa_ok( $downloads->connection, 'Net::Google::Code::Connection', '$ticket->connection' );
+isa_ok( $downloads->connection, 'Net::Google::Code::Connection' );
my @entries = $downloads->all_entries;
is( scalar @entries, 1 );
@@ -51,6 +49,6 @@
is $entries[0]->{link}, 'http://code.google.com/p/net-google-code/downloads/detail?name=Net-Google-Code-0.01.tar.gz';
my $entry = $downloads->entry( 'Net-Google-Code-0.01.tar.gz' );
-
+is $entry->{upload_time}, 'Tue Jan 6 00:16:06 2009';
1;
\ No newline at end of file
More information about the Bps-public-commit
mailing list