r74675 - in /branches/upstream/libxml-feedpp-perl/current: Changes MANIFEST META.yml README lib/XML/FeedPP.pm t/11_media.t t/26_atom10_parse.t t/46_atom_xhtml.t
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Tue May 17 22:05:02 UTC 2011
Author: periapt-guest
Date: Tue May 17 22:04:49 2011
New Revision: 74675
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=74675
Log:
[svn-upgrade] new version libxml-feedpp-perl (0.43)
Added:
branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t (with props)
Modified:
branches/upstream/libxml-feedpp-perl/current/Changes
branches/upstream/libxml-feedpp-perl/current/MANIFEST
branches/upstream/libxml-feedpp-perl/current/META.yml
branches/upstream/libxml-feedpp-perl/current/README
branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm
branches/upstream/libxml-feedpp-perl/current/t/11_media.t
branches/upstream/libxml-feedpp-perl/current/t/26_atom10_parse.t
Modified: branches/upstream/libxml-feedpp-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/Changes?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/Changes (original)
+++ branches/upstream/libxml-feedpp-perl/current/Changes Tue May 17 22:04:49 2011
@@ -1,4 +1,9 @@
# XML::FeedPP Changes
+
+2011/05/08 (0.43)
+ * fixed #67268: Wrong return value of description() with xhtml content in atom feeds
+ https://rt.cpan.org/Ticket/Display.html?id=67268
+ (thanks to MDOM)
2010/10/31 (0.42)
* fixed #55197: Not a HASH reference at XML/FeedPP.pm line 2260
Modified: branches/upstream/libxml-feedpp-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/MANIFEST?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-feedpp-perl/current/MANIFEST Tue May 17 22:04:49 2011
@@ -48,3 +48,4 @@
t/43_indent_atom.t
t/44_cdata.t
t/45_cdata_multi.t
+t/46_atom_xhtml.t
Modified: branches/upstream/libxml-feedpp-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/META.yml?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/META.yml (original)
+++ branches/upstream/libxml-feedpp-perl/current/META.yml Tue May 17 22:04:49 2011
@@ -1,22 +1,14 @@
--- #YAML:1.0
-name: XML-FeedPP
-version: 0.42
-abstract: ~
-author: []
-license: perl
-distribution_type: module
-configure_requires:
- ExtUtils::MakeMaker: 0
-build_requires:
- ExtUtils::MakeMaker: 0
-requires:
- Test::More: 0
- XML::TreePP: 0.39
-no_index:
- directory:
- - t
- - inc
-generated_by: ExtUtils::MakeMaker version 6.54
+name: XML-FeedPP
+version: 0.43
+abstract: ~
+license: perl
+author: ~
+generated_by: ExtUtils::MakeMaker version 6.42
+distribution_type: module
+requires:
+ Test::More: 0
+ XML::TreePP: 0.39
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Modified: branches/upstream/libxml-feedpp-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/README?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/README (original)
+++ branches/upstream/libxml-feedpp-perl/current/README Tue May 17 22:04:49 2011
@@ -26,7 +26,7 @@
Convert some RSS/RDF files to Atom format:
- my $feed = XML::FeedPP::Atom->new(); # create empty atom file
+ my $feed = XML::FeedPP::Atom::Atom10->new(); # create empty atom file
$feed->merge( "rss.xml" ); # load local RSS file
$feed->merge( "http://www.kawa.net/index.rdf" ); # load remote RDF file
my $now = time();
@@ -145,9 +145,9 @@
This method returns an array of all matched items in array context. This
method returns the first matched item in scalar context.
- $feed->remove_item( $index );
- This method removes an item/entry from $feed, where $index is a valid
- zero-based array index.
+ $feed->remove_item( $index or $link );
+ This method removes an item/entry specified by zero-based array index or
+ link URL.
$feed->clear_item();
This method removes all items/entries from the $feed.
@@ -295,6 +295,18 @@
"1970-01-01T00:00:00Z". You know, this is the native format of Perl's
"time()" function.
+USING MEDIA RSS
+ To publish Media RSS, add the "media" namespace then use "set()" setter
+ method to manipulate "media:content" element, etc.
+
+ my $feed = XML::FeedPP::RSS->new();
+ $feed->xmlns('xmlns:media' => 'http://search.yahoo.com/mrss/');
+ my $item = $feed->add_item('http://www.example.com/index.html');
+ $item->set('media:content at url' => 'http://www.example.com/image.jpg');
+ $item->set('media:content at type' => 'image/jpeg');
+ $item->set('media:content at width' => 640);
+ $item->set('media:content at height' => 480);
+
MODULE DEPENDENCIES
"XML::FeedPP" requires only XML::TreePP which likewise is a pure Perl
implementation. The standard LWP::UserAgent is required to download
@@ -309,7 +321,7 @@
The following copyright notice applies to all the files provided in this
distribution, including binary files, unless explicitly noted otherwise.
- Copyright 2006-2010 Yusuke Kawasaki
+ Copyright 2006-2011 Yusuke Kawasaki
LICENSE
This library is free software; you can redistribute it and/or modify it
Modified: branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm (original)
+++ branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm Tue May 17 22:04:49 2011
@@ -28,7 +28,7 @@
Convert some RSS/RDF files to Atom format:
- my $feed = XML::FeedPP::Atom->new(); # create empty atom file
+ my $feed = XML::FeedPP::Atom::Atom10->new(); # create empty atom file
$feed->merge( "rss.xml" ); # load local RSS file
$feed->merge( "http://www.kawa.net/index.rdf" ); # load remote RDF file
my $now = time();
@@ -64,7 +64,7 @@
=head2 $feed = XML::FeedPP->new( $source, -type => $type );
-The C<-type> argument allows you to specify type of $source
+The C<-type> argument allows you to specify type of $source
from choice of C<'file'>, C<'url'> or C<'string'>.
=head2 $feed = XML::FeedPP->new( $source, utf8_flag => 1 );
@@ -72,7 +72,7 @@
This makes utf8 flag on for every feed elements.
Perl 5.8.1 or later is required to use this.
-Note that any other options for C<XML::TreePP> constructor are also
+Note that any other options for C<XML::TreePP> constructor are also
allowed like this. See more detail on L<XML::TreePP>.
=head2 $feed = XML::FeedPP::RSS->new( $source );
@@ -134,7 +134,7 @@
This makes the output more human readable by indenting appropriately.
This does not strictly follow the XML specification but does looks nice.
-Note that any other options for C<XML::TreePP> constructor are also
+Note that any other options for C<XML::TreePP> constructor are also
allowed like this. See more detail on L<XML::TreePP>.
=head2 $feed->to_file( $filename, $encoding );
@@ -172,10 +172,10 @@
This method returns an array of all matched items in array context.
This method returns the first matched item in scalar context.
-=head2 $feed->remove_item( $index );
-
-This method removes an item/entry from $feed, where $index is a valid
-zero-based array index.
+=head2 $feed->remove_item( $index or $link );
+
+This method removes an item/entry specified by zero-based array index or
+link URL.
=head2 $feed->clear_item();
@@ -363,6 +363,19 @@
The last format is the number of seconds since the epoch,
C<1970-01-01T00:00:00Z>.
You know, this is the native format of Perl's C<time()> function.
+
+=head1 USING MEDIA RSS
+
+To publish Media RSS, add the C<media> namespace then use C<set()>
+setter method to manipulate C<media:content> element, etc.
+
+ my $feed = XML::FeedPP::RSS->new();
+ $feed->xmlns('xmlns:media' => 'http://search.yahoo.com/mrss/');
+ my $item = $feed->add_item('http://www.example.com/index.html');
+ $item->set('media:content at url' => 'http://www.example.com/image.jpg');
+ $item->set('media:content at type' => 'image/jpeg');
+ $item->set('media:content at width' => 640);
+ $item->set('media:content at height' => 480);
=head1 MODULE DEPENDENCIES
@@ -383,7 +396,7 @@
this distribution, including binary files, unless explicitly noted
otherwise.
-Copyright 2006-2010 Yusuke Kawasaki
+Copyright 2006-2011 Yusuke Kawasaki
=head1 LICENSE
@@ -407,7 +420,7 @@
$XMLNS_ATOM10
);
-$VERSION = "0.42";
+$VERSION = "0.43";
$RSS20_VERSION = '2.0';
$ATOM03_VERSION = '0.3';
@@ -858,6 +871,14 @@
$self;
}
+sub channel_class {
+ 'XML::FeedPP::RSS::Channel';
+}
+
+sub item_class {
+ 'XML::FeedPP::RSS::Item';
+}
+
sub validate_feed {
my $self = shift;
my $source = shift || $self;
@@ -875,8 +896,8 @@
}
$self->{rss}->{'-version'} ||= $XML::FeedPP::RSS20_VERSION;
- $self->{rss}->{channel} ||= XML::FeedPP::Element->new();
- XML::FeedPP::Element->ref_bless( $self->{rss}->{channel} );
+ $self->{rss}->{channel} ||= $self->channel_class->new();
+ $self->channel_class->ref_bless( $self->{rss}->{channel} );
$self->{rss}->{channel}->{item} ||= [];
if ( UNIVERSAL::isa( $self->{rss}->{channel}->{item}, 'HASH' ) ) {
@@ -885,7 +906,7 @@
$self->{rss}->{channel}->{item} = [ $self->{rss}->{channel}->{item} ];
}
foreach my $item ( @{ $self->{rss}->{channel}->{item} } ) {
- XML::FeedPP::RSS::Item->ref_bless($item);
+ $self->item_class->ref_bless($item);
}
$self;
@@ -1044,6 +1065,12 @@
}
# ----------------------------------------------------------------
+package XML::FeedPP::RSS::Channel;
+use strict;
+use vars qw( @ISA );
+ at ISA = qw( XML::FeedPP::Element );
+
+# ----------------------------------------------------------------
package XML::FeedPP::RSS::Item;
use strict;
use vars qw( @ISA );
@@ -1145,6 +1172,14 @@
$self;
}
+sub channel_class {
+ 'XML::FeedPP::RDF::Channel';
+}
+
+sub item_class {
+ 'XML::FeedPP::RDF::Item';
+}
+
sub validate_feed {
my $self = shift;
my $source = shift || $self;
@@ -1163,8 +1198,8 @@
$self->xmlns( 'xmlns:rdf' => $XML::FeedPP::XMLNS_RDF );
$self->xmlns( 'xmlns:dc' => $XML::FeedPP::XMLNS_DC );
- $self->{'rdf:RDF'}->{channel} ||= XML::FeedPP::Element->new();
- XML::FeedPP::Element->ref_bless( $self->{'rdf:RDF'}->{channel} );
+ $self->{'rdf:RDF'}->{channel} ||= $self->channel_class->new();
+ $self->channel_class->ref_bless( $self->{'rdf:RDF'}->{channel} );
$self->{'rdf:RDF'}->{channel}->{items} ||= {};
$self->{'rdf:RDF'}->{channel}->{items}->{'rdf:Seq'} ||= {};
@@ -1194,7 +1229,7 @@
$self->{'rdf:RDF'}->{item} = [ $self->{'rdf:RDF'}->{item} ];
}
foreach my $item ( @{ $self->{'rdf:RDF'}->{item} } ) {
- XML::FeedPP::RDF::Item->ref_bless($item);
+ $self->item_class->ref_bless($item);
}
$self;
@@ -1222,7 +1257,7 @@
return $self->add_clone_item( $link );
}
- my $rdfli = XML::FeedPP::Element->new();
+ my $rdfli = $self->item_class->new();
$rdfli->{'-rdf:resource'} = $link;
$self->{'rdf:RDF'}->{channel}->{items}->{'rdf:Seq'}->{'rdf:li'} ||= [];
push(
@@ -1389,6 +1424,12 @@
}
# ----------------------------------------------------------------
+package XML::FeedPP::RDF::Channel;
+use strict;
+use vars qw( @ISA );
+ at ISA = qw( XML::FeedPP::Element );
+
+# ----------------------------------------------------------------
package XML::FeedPP::RDF::Item;
use strict;
use vars qw( @ISA );
@@ -1474,7 +1515,7 @@
return $self->add_clone_item( $link );
}
- my $item = $self->_entry_new(@rest);
+ my $item = $self->item_class->new(@rest);
$item->link($link) if $link;
$item->elements(@$init) if ref $init;
push( @{ $self->{feed}->{entry} }, $item );
@@ -1625,16 +1666,19 @@
use vars qw( @ISA );
@ISA = qw( XML::FeedPP::Atom::Common );
-sub _entry_new {
- my $self = shift;
- XML::FeedPP::Atom::Atom03::Entry->new(@_);
+sub channel_class {
+ 'XML::FeedPP::Atom::Atom03::Feed';
+}
+
+sub item_class {
+ 'XML::FeedPP::Atom::Atom03::Entry';
}
sub init_feed {
my $self = shift or return;
- $self->{feed} ||= XML::FeedPP::Element->new();
- XML::FeedPP::Element->ref_bless( $self->{feed} );
+ $self->{feed} ||= $self->channel_class->new();
+ $self->channel_class->ref_bless( $self->{feed} );
if ( ! UNIVERSAL::isa( $self->{feed}, 'HASH' ) ) {
Carp::croak "Invalid Atom 0.3 format: $self->{feed}";
@@ -1649,7 +1693,7 @@
$self->{feed}->{entry} = [ $self->{feed}->{entry} ];
}
foreach my $item ( @{ $self->{feed}->{entry} } ) {
- XML::FeedPP::Atom::Atom03::Entry->ref_bless($item);
+ $self->item_class->ref_bless($item);
}
$self->{feed}->{author} ||= { name => '' }; # dummy for validation
$self;
@@ -1743,16 +1787,19 @@
use vars qw( @ISA );
@ISA = qw( XML::FeedPP::Atom::Common );
-sub _entry_new {
- my $self = shift;
- XML::FeedPP::Atom::Atom10::Entry->new(@_);
+sub channel_class {
+ 'XML::FeedPP::Atom::Atom10::Feed';
+}
+
+sub item_class {
+ 'XML::FeedPP::Atom::Atom10::Entry';
}
sub init_feed {
my $self = shift or return;
- $self->{feed} ||= XML::FeedPP::Element->new();
- XML::FeedPP::Element->ref_bless( $self->{feed} );
+ $self->{feed} ||= $self->channel_class->new();
+ $self->channel_class->ref_bless( $self->{feed} );
if ( ! UNIVERSAL::isa( $self->{feed}, 'HASH' ) ) {
Carp::croak "Invalid Atom 1.0 format: $self->{feed}";
@@ -1767,7 +1814,7 @@
$self->{feed}->{entry} = [ $self->{feed}->{entry} ];
}
foreach my $item ( @{ $self->{feed}->{entry} } ) {
- XML::FeedPP::Atom::Atom10::Entry->ref_bless($item);
+ $self->item_class->ref_bless($item);
}
# $self->{feed}->{author} ||= { name => '' }; # dummy for validation
$self;
@@ -1862,6 +1909,50 @@
# @ISA = qw( XML::FeedPP::Atom::Atom10 ); # if Atom 1.0 for default
# ----------------------------------------------------------------
+package XML::FeedPP::Atom::Common::Feed;
+use strict;
+use vars qw( @ISA );
+ at ISA = qw( XML::FeedPP::Element );
+
+# <content type="xhtml"><div>...</div></content>
+# http://www.ietf.org/rfc/rfc4287.txt
+# 3. If the value of "type" is "xhtml", the content of atom:content
+# MUST be a single XHTML div element [XHTML] and SHOULD be suitable
+# for handling as XHTML. The XHTML div element itself MUST NOT be
+# considered part of the content.
+
+sub _fetch_value {
+ my $self = shift;
+ my $value = shift;
+
+ if ( UNIVERSAL::isa( $value, 'HASH' )
+ && exists $value->{'-type'}
+ && ($value->{'-type'} eq "xhtml")) {
+ my $child = [ grep { /^[^\-\#]/ } keys %$value ];
+ if (scalar @$child == 1) {
+ my $div = shift @$child;
+ if ($div =~ /^([^:]+:)?div$/i) {
+ return $value->{$div};
+ }
+ }
+ }
+
+ $self->SUPER::_fetch_value($value);
+}
+
+# ----------------------------------------------------------------
+package XML::FeedPP::Atom::Atom03::Feed;
+use strict;
+use vars qw( @ISA );
+ at ISA = qw( XML::FeedPP::Atom::Common::Feed );
+
+# ----------------------------------------------------------------
+package XML::FeedPP::Atom::Atom10::Feed;
+use strict;
+use vars qw( @ISA );
+ at ISA = qw( XML::FeedPP::Atom::Common::Feed );
+
+# ----------------------------------------------------------------
package XML::FeedPP::Atom::Common::Entry;
use strict;
use vars qw( @ISA );
@@ -1879,6 +1970,8 @@
}
sub guid { shift->get_or_set( 'id', @_ ); }
+
+*_fetch_value = \&XML::FeedPP::Atom::Common::Feed::_fetch_value;
# ----------------------------------------------------------------
package XML::FeedPP::Atom::Atom03::Entry;
@@ -2068,12 +2161,6 @@
}
# ----------------------------------------------------------------
-package XML::FeedPP::Atom::Entry;
-use strict;
-use vars qw( @ISA );
- at ISA = qw( XML::FeedPP::Atom::Atom03::Entry );
-
-# ----------------------------------------------------------------
package XML::FeedPP::Element;
use strict;
@@ -2116,7 +2203,7 @@
$node->{ '-' . $attr } = $val;
}
elsif ( defined $attr ) {
- if ( ref $node->{$tagname} &&
+ if ( ref $node->{$tagname} &&
UNIVERSAL::isa( $node->{$tagname}, 'ARRAY' )) {
$node->{$tagname} = shift @{$node->{$tagname}};
}
@@ -2135,7 +2222,7 @@
}
}
elsif ( defined $tagname ) {
- if ( ref $node->{$tagname} &&
+ if ( ref $node->{$tagname} &&
UNIVERSAL::isa( $node->{$tagname}, 'ARRAY' )) {
$node->{$tagname} = shift @{$node->{$tagname}};
}
@@ -2220,41 +2307,35 @@
my $self = shift;
my $elem = shift;
return unless exists $self->{$elem};
- my $value = $self->{$elem} or return;
+ my $value = $self->{$elem};
return $value unless ref $value;
# multiple elements
if ( UNIVERSAL::isa( $value, 'ARRAY' )) {
if ( wantarray ) {
- return map { &get_avalue($_) } @$value;
+ return map { $self->_fetch_value($_) } @$value;
} else {
- return &get_avalue($value->[0]);
- }
- }
-
- # a hack for atom: <content type="xhtml"><div>...</div></content>
- if ( UNIVERSAL::isa( $value, 'HASH' )
- && exists $value->{'-type'}
- && ($value->{'-type'} eq "xhtml")) {
- my $child = [ grep { /^[^_-_#]/ } keys %$value ];
- if (scalar @$child == 1) {
- return &get_value( $value, $child->[0] );
- }
- }
- return &get_avalue($value);
-}
-
-sub get_avalue {
+ return $self->_fetch_value($value->[0]);
+ }
+ }
+
+ return $self->_fetch_value($value);
+}
+
+sub _fetch_value {
+ my $self = shift;
my $value = shift;
-
+
if ( UNIVERSAL::isa( $value, 'HASH' )) {
# text node of an element with attributes
- return &get_avalue($value->{'#text'}) if exists $value->{'#text'};
+ if ( exists $value->{'#text'} ) {
+ return $self->_fetch_value($value->{'#text'})
+ }
} elsif ( UNIVERSAL::isa( $value, 'SCALAR' )) {
# CDATA section as a scalar reference
return $$value;
}
-
+
return $value;
}
Modified: branches/upstream/libxml-feedpp-perl/current/t/11_media.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/11_media.t?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/11_media.t (original)
+++ branches/upstream/libxml-feedpp-perl/current/t/11_media.t Tue May 17 22:04:49 2011
@@ -1,60 +1,116 @@
# ----------------------------------------------------------------
use strict;
- use Test::More tests => 26;
+ use Test::More tests => 37;
BEGIN { use_ok('XML::FeedPP') };
# ----------------------------------------------------------------
my $ftitle = "Title of the site";
my $fdesc = "Description of the site";
- my $link1 = "http://www.perl.org/";
+ my $link1 = "http://www.perl.org/";
# ----------------------------------------------------------------
- my $xmlns_media = 'http://search.yahoo.com/mrss';
- my $media_content_url = "http://www.kawa.net/xp/images/xp-title-512.gif";
- my $media_content_type = "image/gif";
- my $media_content_width = 512;
- my $media_content_height = 96;
- my $media_title_value = "media title";
- my $media_text_value = "media value";
- my $media_text_type = "html";
- my $media_thumbnail_url = "http://www.kawa.net/xp/images/xp-title-256.gif";
- my $media_thumbnail_width = 256;
- my $media_thumbnail_height = 48;
- my $media_credit_value = "credit value";
- my $media_credit_scheme = "urn:kawanet:tags";
+ my $xmlns_media = 'http://search.yahoo.com/mrss/';
+ my $media_content_url = "http://www.kawa.net/xp/images/xp-title-512.gif";
+ my $media_content_type = "image/gif";
+ my $media_content_width = 512;
+ my $media_content_height = 96;
+ my $media_title_value = "media title";
+ my $media_text_value = "media value";
+ my $media_text_type = "html";
+ my $media_thumbnail_url = "http://www.kawa.net/xp/images/xp-title-256.gif";
+ my $media_thumbnail_width = 256;
+ my $media_thumbnail_height = 48;
+ my $media_credit_value = "credit value";
+ my $media_credit_scheme = "urn:kawanet:tags";
# ----------------------------------------------------------------
- my $media_hash = {
- 'media:content at url' => $media_content_url,
- 'media:content at type' => $media_content_type,
- 'media:content at width' => $media_content_width,
- 'media:content at height' => $media_content_height,
- 'media:title' => $media_title_value,
- 'media:text' => $media_text_value,
- 'media:text at type' => $media_text_type,
- 'media:thumbnail at url' => $media_thumbnail_url,
- 'media:thumbnail at width' => $media_thumbnail_width,
- 'media:thumbnail at height' => $media_thumbnail_height,
- 'media:credit at scheme' => $media_credit_scheme,
- 'media:credit' => $media_credit_value,
- };
+ my $media_hash = {
+ 'media:content at url' => $media_content_url,
+ 'media:content at type' => $media_content_type,
+ 'media:content at width' => $media_content_width,
+ 'media:content at height' => $media_content_height,
+ 'media:title' => $media_title_value,
+ 'media:text' => $media_text_value,
+ 'media:text at type' => $media_text_type,
+ 'media:thumbnail at url' => $media_thumbnail_url,
+ 'media:thumbnail at width' => $media_thumbnail_width,
+ 'media:thumbnail at height' => $media_thumbnail_height,
+ 'media:credit at scheme' => $media_credit_scheme,
+ 'media:credit' => $media_credit_value,
+ };
# ----------------------------------------------------------------
+{
my $feed1 = XML::FeedPP::RSS->new();
$feed1->title( $ftitle );
+ $feed1->xmlns( 'xmlns:media' => $xmlns_media );
+ is( $feed1->xmlns('xmlns:media'), $xmlns_media, '1. xmlns:media' );
+
+ my $item1 = $feed1->add_item( $link1 );
+ $item1->set( %$media_hash );
+
+ foreach my $key ( sort keys %$media_hash ) {
+ is( $item1->get($key), $media_hash->{$key}, '1. '.$key );
+ }
+
+ my $source1 = $feed1->to_string();
+ my $feed2 = XML::FeedPP::RDF->new();
+ $feed2->merge( $source1 );
+
+ my $item2 = $feed2->get_item(0);
+ foreach my $key ( sort keys %$media_hash ) {
+ is( $item2->get($key), $media_hash->{$key}, '2.'.$key );
+ }
+}
# ----------------------------------------------------------------
- $feed1->xmlns( 'xmlns:media' => $xmlns_media );
- is( $xmlns_media, $feed1->xmlns('xmlns:media'), 'xmlns:media' );
+{
+ my $feed = XML::FeedPP::RSS->new();
+ $feed->xmlns('xmlns:media' => 'http://search.yahoo.com/mrss/');
+ my $item = $feed->add_item('http://www.example.com/index.html');
+ $item->set('media:content at url' => 'http://www.example.com/image.jpg');
+ $item->set('media:content at type' => 'image/jpeg');
+ $item->set('media:content at width' => 640);
+ $item->set('media:content at height' => 480);
+
+ my $source3 = $feed->to_string();
+ my $feed3 = XML::FeedPP->new($source3);
+ is($feed3->xmlns('xmlns:media'), $xmlns_media, '3. xmlns:media');
+
+ my $item3 = $feed3->get_item(0);
+ is($item3->link, 'http://www.example.com/index.html', '3. link');
+ is($item3->get('media:content at url'), 'http://www.example.com/image.jpg', '3. media:content at url');
+ is($item3->get('media:content at type'), 'image/jpeg', '3. media:content at type');
+ is($item3->get('media:content at width'), '640', '3. media:content at width');
+ is($item3->get('media:content at height'), '480', '3. media:content at height');
+}
# ----------------------------------------------------------------
- my $item1 = $feed1->add_item( $link1 );
- $item1->set( %$media_hash );
- foreach my $key ( sort keys %$media_hash ) {
- is( $item1->get($key), $media_hash->{$key}, $key );
- }
-# ----------------------------------------------------------------
- my $source1 = $feed1->to_string();
- my $feed2 = XML::FeedPP::RDF->new();
- $feed2->merge( $source1 );
- my $item2 = $feed2->get_item(0);
- foreach my $key ( sort keys %$media_hash ) {
- is( $item2->get($key), $media_hash->{$key}, $key );
- }
+{
+ # SEE http://video.search.yahoo.com/mrss
+ my $source4 = <<EOT;
+<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"
+xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
+<channel>
+<title>My Movie Review Site</title>
+<link>http://www.foo.com</link>
+<description>I review movies.</description>
+ <item>
+ <title>Movie Title: Is this a good movie?</title>
+ <link>http://www.foo.com/item1.htm</link>
+ <media:content url="http://www.foo.com/trailer.mov"
+ fileSize="12216320" type="video/quicktime" expression="sample"/>
+ <creativeCommons:license>
+ http://www.creativecommons.org/licenses/by-nc/1.0
+ </creativeCommons:license>
+ <media:rating>nonadult</media:rating>
+ </item>
+</channel>
+</rss>
+EOT
+ my $feed4 = XML::FeedPP->new($source4);
+ is($feed4->xmlns('xmlns:media'), $xmlns_media, '4. xmlns:media');
+
+ my $item4 = $feed4->get_item(0);
+ is($item4->link, 'http://www.foo.com/item1.htm', '4. link');
+ is($item4->get('media:content at url'), 'http://www.foo.com/trailer.mov', '4. media:content at url');
+ is($item4->get('media:content at fileSize'), '12216320', '4. media:content at fileSize');
+ is($item4->get('media:content at type'), 'video/quicktime', '4. media:content at type');
+}
# ----------------------------------------------------------------
;1;
# ----------------------------------------------------------------
Modified: branches/upstream/libxml-feedpp-perl/current/t/26_atom10_parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/26_atom10_parse.t?rev=74675&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/26_atom10_parse.t (original)
+++ branches/upstream/libxml-feedpp-perl/current/t/26_atom10_parse.t Tue May 17 22:04:49 2011
@@ -99,6 +99,10 @@
ok( $feed->isa( 'XML::FeedPP::Atom::Atom10' ), 'XML::FeedPP::Atom::Atom10' );
is( $feed->title, 'dive into mark', 'feed title' );
like( $feed->description, qr/effortless/, 'feed description' );
+
+my $desc = $feed->description;
+print "[$desc]\n";
+
is( $feed->pubDate, '2005-07-31T12:29:29Z', 'feed pubDate' );
# is( $feed->guid, 'tag:example.org,2003:3', 'feed guid' );
is( $feed->link, 'http://example.org/', 'feed link' );
@@ -112,6 +116,12 @@
is( $item->guid, 'tag:example.org,2003:3.2397', 'item guid' );
is( $item->pubDate, '2005-07-31T12:29:29Z', 'item pubDate' );
is( $item->author, 'Mark Pilgrim', 'item author' );
+
+$desc = $item->description;
+print "[$desc]\n";
+use Data::Dumper;
+print Dumper($desc);
+
}
# ----------------------------------------------------------------
;1;
Added: branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t?rev=74675&op=file
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t (added)
+++ branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t Tue May 17 22:04:49 2011
@@ -1,0 +1,92 @@
+# ----------------------------------------------------------------
+ use strict;
+ use Test::More tests => 20;
+ BEGIN { use_ok('XML::FeedPP') };
+# ----------------------------------------------------------------
+{
+ my $sample = <<'EOT';
+<?xml version="1.0" encoding="UTF-8" ?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ <xhtml:div>
+ Less: <xhtml:em><</xhtml:em>
+ </xhtml:div>
+ </title>
+ <entry>
+ <content type="xhtml" xml:lang="en"
+ xml:base="http://diveintomark.org/">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <p><i>[Update: The Atom draft is finished.]</i></p>
+ </div>
+ </content>
+ </entry>
+ <entry>
+ <content type="xhtml">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ This is <b>XHTML</b> content.
+ </div>
+ </content>
+ </entry>
+ <entry>
+ <content type="xhtml">
+ <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ This is <xhtml:b>XHTML</xhtml:b> content.
+ </xhtml:div>
+ </content>
+ </entry>
+ <entry>
+ <content type="xhtml">
+ <xh:div>
+ This is <xh:b>XHTML</xh:b> content.
+ </xh:div>
+ </content>
+ </entry>
+</feed>
+EOT
+
+ my $feed = XML::FeedPP->new( $sample );
+
+ my $title = $feed->title;
+ is(ref $title, 'HASH', 'feed title is HASH');
+ ok(! exists $title->{'xhtml:div'}, 'feed title does NOT have div');
+ like($title->{'xhtml:em'}, qr/</, 'feed title /xhtml:div/xhtml:em');
+
+ my $item;
+ my $desc;
+ my @entry = $feed->get_item;
+ is( scalar(@entry), 4, 'feed get_item' );
+
+ # entry 1
+ $item = shift @entry;
+ $desc = $item->description;
+ is(ref $desc, 'HASH', 'entry 1 /content is HASH');
+ ok(! exists $desc->{'div'}, 'entry 1 /content does NOT have /div');
+ ok(exists $desc->{p}, 'entry 1 /content/div/p');
+ is($desc->{-xmlns}, 'http://www.w3.org/1999/xhtml', 'entry 1 /content/div/@xmlns');
+ is($desc->{p}->{i}, '[Update: The Atom draft is finished.]', 'entry 1 /content/div/p/i');
+
+ # entry 2
+ $item = shift @entry;
+ $desc = $item->description;
+ is(ref $desc, 'HASH', 'entry 2 /content is HASH');
+ ok(! exists $desc->{'div'}, 'entry 2 /content does NOT have /div');
+ is($desc->{-xmlns}, 'http://www.w3.org/1999/xhtml', 'entry 2 /content/div/@xmlns');
+ is($desc->{b}, 'XHTML', 'entry 2 /content/div/b');
+
+ # entry 3
+ $item = shift @entry;
+ $desc = $item->description;
+ is(ref $desc, 'HASH', 'entry 3 /content is HASH');
+ ok(! exists $desc->{'xhtml:div'}, 'entry 3 /content does NOT have /xhtml:div');
+ is($desc->{'xhtml:b'}, 'XHTML', 'entry 3 /content/div/b');
+
+ # entry 4
+ $item = shift @entry;
+ $desc = $item->description;
+ is(ref $desc, 'HASH', 'entry 4 /content is HASH');
+ ok(! exists $desc->{'xh:div'}, 'entry 4 /content does NOT have /xh:div');
+ is($desc->{'xh:b'}, 'XHTML', 'entry 4 /content/div/b');
+}
+# ----------------------------------------------------------------
+;1;
+# ----------------------------------------------------------------
Propchange: branches/upstream/libxml-feedpp-perl/current/t/46_atom_xhtml.t
------------------------------------------------------------------------------
svn:executable = *
More information about the Pkg-perl-cvs-commits
mailing list