Changeset 1508

Show
Ignore:
Timestamp:
01/15/05 21:13:16
Author:
miyagawa
Message:

0.03 and 0.04

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WebService-Bloglines/trunk/Changes

    r1496 r1508  
    11Revision history for Perl extension WebService::Bloglines 
    22 
    3 0.02 
     30.04  Sat Jan 15 21:09:35 JST 2005 
     4        - $update->items returns arrayref in scalar context. It still 
     5          returns array in a list context. 
     6 
     70.03  Wed Jan 12 18:25:07 JST 2005 
     8        * $bloglines->getitems() returns array of Entries in a list 
     9          context. It allows you to fetch all unread items in a single 
     10          getitems(0) call. 
     11 
     120.02  Thu Sep 30 19:54:36 JST 2004 
    413        - Added XML::RSS to PREREQ_PM 
    5         - Encode module is now optional for Perl 5.8 
     14        - Encode module is now optional for Perl < 5.8 
    615 
    7160.01  Mon Aug 16 22:27:32 2004 
  • WebService-Bloglines/trunk/META.yml

    r1496 r1508  
    22#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX# 
    33name:         WebService-Bloglines 
    4 version:      0.01 
     4version:      0.04 
    55version_from: lib/WebService/Bloglines.pm 
    66installdirs:  site 
    77requires: 
    8     Encode:                        0 
    98    LWP:                           0 
    109    Test::More:                    0.32 
     10    XML::RSS:                      0 
     11    XML::XPath:                    0 
    1112 
    1213distribution_type: module 
  • WebService-Bloglines/trunk/Makefile.PL

    r1496 r1508  
    77        LWP => 0, 
    88        XML::RSS => 0, 
     9        XML::XPath => 0, 
    910    }, 
    1011); 
  • WebService-Bloglines/trunk/lib/WebService/Bloglines.pm

    r1496 r1508  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.02
     5$VERSION = 0.04
    66 
    77use LWP::UserAgent; 
     
    1717    $ua->credentials("rpc.bloglines.com:80", "Bloglines RPC", 
    1818                     $p{username}, $p{password}); 
    19     bless { %p, ua => $ua}, $class; 
     19    bless { %p, ua => $ua }, $class; 
    2020} 
    2121 
     
    8585    } 
    8686 
    87     return WebService::Bloglines::Entries->new($res->content); 
     87    return WebService::Bloglines::Entries->parse($res->content); 
    8888} 
    8989 
     
    157157  } 
    158158 
     159  # get all unread items in a single call 
     160  my @updates = $bloglines->getitems(0); 
     161  for my $update (@updates) { 
     162      my $feed = $update->feed(); 
     163      for my $item ($update->items) { 
     164          ... 
     165      } 
     166  } 
     167 
    159168=head1 DESCRIPTION 
    160169 
     
    173182=item * 
    174183 
    175 Cacheability using Cache::Cache API. 
     184Cleaner API to make users free from the difference between OPML and RSS stuff 
    176185 
    177186=item * 
  • WebService-Bloglines/trunk/lib/WebService/Bloglines/Entries.pm

    r1496 r1508  
    66use strict; 
    77use XML::RSS; 
     8use XML::XPath; 
    89use HTML::Entities; 
     10 
     11sub parse { 
     12    my($class, $xml) = @_; 
     13    my $xp = XML::XPath->new(ioref => $xml); 
     14    my $rssparent = $xp->find("/rss")->get_node(0); 
     15    my $channelnode = $xp->find("/rss/channel"); 
     16 
     17    my @entries; 
     18    for my $node ($channelnode->get_nodelist()) { 
     19        my $xml = $rssparent->toString(1); # norecurse 
     20        my $channel = $node->toString(); 
     21        $xml =~ s!</rss>$!\n$channel\n</rss>!; # wooh 
     22        push @entries, $class->new($xml); 
     23    } 
     24    return wantarray ? @entries : $entries[0]; 
     25} 
    926 
    1027sub new { 
     
    3350sub items { 
    3451    my $self = shift; 
    35     return @{$self->{_rss}->{items}}; 
     52    return wantarray ? @{$self->{_rss}->{items}} : $self->{_rss}->{items}; 
    3653} 
    3754 
  • WebService-Bloglines/trunk/t/03_getitems.t

    r1496 r1508  
    2929ok length($feed->{title}), $feed->{title}; 
    3030like $feed->{link}, qr!^https?://!, $feed->{link}; 
    31 ok $feed->{description}, $feed->{description}; 
     31ok defined($feed->{description}), $feed->{description}; 
    3232like $feed->{bloglines}->{siteid}, qr/^\d+$/, "siteid: $feed->{bloglines}->{siteid}"; 
    3333ok $feed->{language}, $feed->{language}; 
     
    4848    $bloglines->getitems($feed->{BloglinesSubId}); 
    4949}; 
    50 like $@, qr/304/, $@ 
     50like $@, qr/304/, $@; 
    5151 
     52# fetch all in single getitems 
     53my @updates = $bloglines->getitems(0); 
     54for my $update (@updates) { 
     55    ok defined($update->feed->{title}), $update->feed->{title}; 
     56    my $item = ($update->items)[0]; 
     57    ok defined($item->{link}), "link: $item->{link}"; 
     58} 
     59