r47610 - in /branches/upstream/libxml-feedpp-perl/current: Changes MANIFEST META.yml Makefile.PL README lib/XML/FeedPP.pm t/17_multi_category.t t/43_indent_atom.t t/44_cdata.t t/45_cdata_multi.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sun Nov 22 03:56:32 UTC 2009
Author: jawnsy-guest
Date: Sun Nov 22 03:56:26 2009
New Revision: 47610
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=47610
Log:
[svn-upgrade] Integrating new upstream version, libxml-feedpp-perl (0.41)
Added:
branches/upstream/libxml-feedpp-perl/current/t/43_indent_atom.t
branches/upstream/libxml-feedpp-perl/current/t/44_cdata.t
branches/upstream/libxml-feedpp-perl/current/t/45_cdata_multi.t
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/Makefile.PL
branches/upstream/libxml-feedpp-perl/current/README
branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm
branches/upstream/libxml-feedpp-perl/current/t/17_multi_category.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=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/Changes (original)
+++ branches/upstream/libxml-feedpp-perl/current/Changes Sun Nov 22 03:56:26 2009
@@ -1,4 +1,11 @@
# XML::FeedPP Changes
+
+2009/11/21 (0.41)
+ * supports generating CDATA section by setting SCALAR ref value like XML::TreePP.
+ (thanks to Mario Domgoergen)
+ * pod added to create an empty Atom 1.0 instance intended:
+ XML::FeedPP::Atom::Atom10->new()
+ (thanks to Andy Piper)
2009/04/07 (0.40)
* fixed #44082: parse method refuses feeds with UTF-8 BOM
Modified: branches/upstream/libxml-feedpp-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/MANIFEST?rev=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-feedpp-perl/current/MANIFEST Sun Nov 22 03:56:26 2009
@@ -45,3 +45,6 @@
t/40_xml_deref.t
t/41_utf8_flag.t
t/42_indent.t
+t/43_indent_atom.t
+t/44_cdata.t
+t/45_cdata_multi.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=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/META.yml (original)
+++ branches/upstream/libxml-feedpp-perl/current/META.yml Sun Nov 22 03:56:26 2009
@@ -1,20 +1,22 @@
--- #YAML:1.0
name: XML-FeedPP
-version: 0.40
+version: 0.41
abstract: ~
author: []
license: perl
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
requires:
Test::More: 0
- XML::TreePP: 0.38
+ XML::TreePP: 0.39
no_index:
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.46
+generated_by: ExtUtils::MakeMaker version 6.54
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libxml-feedpp-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/Makefile.PL?rev=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/Makefile.PL (original)
+++ branches/upstream/libxml-feedpp-perl/current/Makefile.PL Sun Nov 22 03:56:26 2009
@@ -6,7 +6,7 @@
VERSION_FROM => 'lib/XML/FeedPP.pm',
PREREQ_PM => {
'Test::More' => '0',
- 'XML::TreePP' => '0.38',
+ 'XML::TreePP' => '0.39',
},
};
Modified: branches/upstream/libxml-feedpp-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/README?rev=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/README (original)
+++ branches/upstream/libxml-feedpp-perl/current/README Sun Nov 22 03:56:26 2009
@@ -80,12 +80,18 @@
The first argument is optional, but must be an Atom source if specified.
This method returns an empty instance when $source is undefined.
- Atom 1.0 feed is supported since "XML::FeedPP" version 0.30. Atom 0.3 is
- still default however.
+ Atom 1.0 feed is also supported since "XML::FeedPP" version 0.30. Atom
+ 0.3 is still default, however, future version of this module would
+ create Atom 1.0 as default.
+
+ $feed = XML::FeedPP::Atom::Atom03->new();
+ This creates an empty Atom 0.3 instance obviously.
+
+ $feed = XML::FeedPP::Atom::Atom10->new();
+ This creates an empty Atom 1.0 instance intended.
$feed = XML::FeedPP::RSS->new( link => $link, title => $tile, ... );
- This constructor method creates an instance which has "link", "title"
- elements etc.
+ This creates a RSS instance which has "link", "title" elements etc.
$feed->load( $source );
This method loads an RSS/RDF/Atom file, much like "new()" method does.
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=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm (original)
+++ branches/upstream/libxml-feedpp-perl/current/lib/XML/FeedPP.pm Sun Nov 22 03:56:26 2009
@@ -93,13 +93,21 @@
The first argument is optional, but must be an Atom source if specified.
This method returns an empty instance when $source is undefined.
-Atom 1.0 feed is supported since C<XML::FeedPP> version 0.30.
-Atom 0.3 is still default however.
+Atom 1.0 feed is also supported since C<XML::FeedPP> version 0.30.
+Atom 0.3 is still default, however, future version of this module
+would create Atom 1.0 as default.
+
+=head2 $feed = XML::FeedPP::Atom::Atom03->new();
+
+This creates an empty Atom 0.3 instance obviously.
+
+=head2 $feed = XML::FeedPP::Atom::Atom10->new();
+
+This creates an empty Atom 1.0 instance intended.
=head2 $feed = XML::FeedPP::RSS->new( link => $link, title => $tile, ... );
-This constructor method creates an instance
-which has C<link>, C<title> elements etc.
+This creates a RSS instance which has C<link>, C<title> elements etc.
=head2 $feed->load( $source );
@@ -392,7 +400,7 @@
$XMLNS_ATOM10
);
-$VERSION = "0.40";
+$VERSION = "0.41";
$RSS20_VERSION = '2.0';
$ATOM03_VERSION = '0.3';
@@ -2211,25 +2219,36 @@
# multiple elements
if ( UNIVERSAL::isa( $value, 'ARRAY' )) {
if ( wantarray ) {
- return map { ref $_ && exists $_->{'#text'}
- ? $_->{'#text'} : $_ } @$value;
+ return map { &get_avalue($_) } @$value;
} else {
- return ref $value->[0] && exists $value->[0]->{'#text'}
- ? $value->[0]->{'#text'} : $value->[0];
- }
- }
-
- # text node of an element with attributes
- return $value->{'#text'} if exists $value->{'#text'};
+ return &get_avalue($value->[0]);
+ }
+ }
# a hack for atom: <content type="xhtml"><div>...</div></content>
- my $child = [ grep { /^[^\-\#]/ } keys %$value ];
- if ( exists $value->{'-type'}
- && ($value->{'-type'} eq "xhtml")
- && scalar @$child == 1) {
- return &get_value( $value, $child->[0] );
- }
- return;
+ 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 {
+ my $value = shift;
+
+ if ( UNIVERSAL::isa( $value, 'HASH' )) {
+ # text node of an element with attributes
+ return &get_avalue($value->{'#text'}) if exists $value->{'#text'};
+ } elsif ( UNIVERSAL::isa( $value, 'SCALAR' )) {
+ # CDATA section as a scalar reference
+ return $$value;
+ }
+
+ return $value;
}
sub set_value {
@@ -2262,7 +2281,9 @@
my $elem = shift;
my $attr = \@_;
if ( defined $self->{$elem} ) {
- if ( !ref $self->{$elem} ) {
+ my $scalar = ref $self->{$elem};
+ $scalar = undef if ($scalar eq 'SCALAR');
+ if (! $scalar) {
$self->{$elem} = { '#text' => $self->{$elem} };
}
}
@@ -2273,6 +2294,7 @@
my $key = shift @$attr;
my $val = shift @$attr;
if ( defined $val ) {
+# $val = $$val if (ref $val eq 'SCALAR');
$self->{$elem}->{ '-' . $key } = $val;
}
else {
Modified: branches/upstream/libxml-feedpp-perl/current/t/17_multi_category.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/17_multi_category.t?rev=47610&op=diff
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/17_multi_category.t (original)
+++ branches/upstream/libxml-feedpp-perl/current/t/17_multi_category.t Sun Nov 22 03:56:26 2009
@@ -1,6 +1,6 @@
# ----------------------------------------------------------------
use strict;
- use Test::More tests => 32;
+ use Test::More tests => 26;
BEGIN { use_ok('XML::FeedPP') };
# ----------------------------------------------------------------
my $url = "http://www.kawa.net/";
@@ -23,7 +23,7 @@
my $feeds = [
XML::FeedPP::RDF->new(),
XML::FeedPP::RSS->new(),
- XML::FeedPP::RDF->new(),
+ XML::FeedPP::Atom::Atom10->new(),
];
# ----------------------------------------------------------------
foreach my $feed1 ( @$feeds ) {
@@ -31,22 +31,22 @@
$feed1->merge( $source );
my $item1 = $feed1->get_item(0);
my $icate = $item1->category();
- ok( ref $icate, "$type load ref" );
- is( scalar @$icate, $caten, "$type load count" );
+ my $icatn = scalar @$icate if ref $icate;
+ is( $icatn, $caten, "$type load count" );
$item1->category( $cate1 );
is( $item1->category(), $cate1, "$type one" );
- ok( $feed1->to_string() =~ />\s*\Q$cate1\E\s*</s, "$type one source" );
+ ok( $feed1->to_string() =~ /\W\Q$cate1\E\W/s, "$type one source" );
$item1->category( $catem );
my $jcate = $item1->category();
- ok( ref $jcate, "$type multi ref" );
- is( scalar @$jcate, $caten, "$type multi count" );
+ my $jcatn = scalar @$jcate if ref $jcate;
+ is( $jcatn, $caten, "$type multi count" );
$source = $feed1->to_string();
- like( $source, qr/>\s*\Q$cate1\E\s*</s, "$type multi 1/3" );
- like( $source, qr/>\s*\Q$cate2\E\s*</s, "$type multi 2/3" );
- like( $source, qr/>\s*\Q$cate3\E\s*</s, "$type multi 3/3" );
+ like( $source, qr/\W\Q$cate1\E\W/s, "$type multi 1/3" );
+ like( $source, qr/\W\Q$cate2\E\W/s, "$type multi 2/3" );
+ like( $source, qr/\W\Q$cate3\E\W/s, "$type multi 3/3" );
}
# ----------------------------------------------------------------
;1;
Added: branches/upstream/libxml-feedpp-perl/current/t/43_indent_atom.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/43_indent_atom.t?rev=47610&op=file
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/43_indent_atom.t (added)
+++ branches/upstream/libxml-feedpp-perl/current/t/43_indent_atom.t Sun Nov 22 03:56:26 2009
@@ -1,0 +1,39 @@
+# ----------------------------------------------------------------
+ use strict;
+ use Test::More;
+# ----------------------------------------------------------------
+ my $link = "http://www.kawa.net/";
+ my $title = "foobar";
+# ----------------------------------------------------------------
+{
+ plan tests => 9;
+ use_ok('XML::FeedPP');
+
+ my $feeds = [
+ XML::FeedPP::RDF->new(),
+ XML::FeedPP::RSS->new(),
+ XML::FeedPP::Atom::Atom03->new(),
+ XML::FeedPP::Atom::Atom10->new(),
+ ];
+ foreach my $feed1 ( @$feeds ) {
+ &test_indent( 2, $feed1 );
+ &test_indent( 4, $feed1 );
+ }
+}
+# ----------------------------------------------------------------
+sub test_indent {
+ my $indent = shift;
+ my $feed = shift;
+ my $type = ref $feed;
+ $feed->link($link);
+ $feed->add_item($link);
+ my $string1 = $feed->to_string( indent => $indent );
+ is( indent($string1), ' ' x $indent, "$type indent $indent" );
+}
+# ----------------------------------------------------------------
+sub indent {
+ my $str = shift;
+ my $indent = ( $str =~ m#^(\040+)#m )[0];
+ $indent;
+}
+# ----------------------------------------------------------------
Added: branches/upstream/libxml-feedpp-perl/current/t/44_cdata.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/44_cdata.t?rev=47610&op=file
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/44_cdata.t (added)
+++ branches/upstream/libxml-feedpp-perl/current/t/44_cdata.t Sun Nov 22 03:56:26 2009
@@ -1,0 +1,58 @@
+# ----------------------------------------------------------------
+ use strict;
+ use Test::More tests => 57;
+ BEGIN { use_ok('XML::FeedPP') };
+# ----------------------------------------------------------------
+ my $flink = "http://www.kawa.net/";
+ my $ilink = "http://kawanet.blogspot.com/";
+ my $ftitle = "hoge";
+ my $ititle = "pomu";
+ my $fdesc = "foo";
+ my $idesc = "bar";
+# ----------------------------------------------------------------
+ my $feeds = [
+ XML::FeedPP::RDF->new(),
+ XML::FeedPP::RSS->new(),
+ XML::FeedPP::Atom::Atom03->new(),
+ XML::FeedPP::Atom::Atom10->new(),
+ ];
+# ----------------------------------------------------------------
+ foreach my $feed1 ( @$feeds ) {
+ my $type = ref $feed1;
+
+ $feed1->link($flink);
+ $feed1->title(\$ftitle);
+ $feed1->description(\$fdesc);
+
+ my $item1 = $feed1->add_item($ilink);
+ $item1->link($ilink);
+ $item1->title(\$ititle);
+ $item1->description(\$idesc);
+
+ my $source = $feed1->to_string();
+ my $feed2 = XML::FeedPP ->new($source);
+ my $item2 = $feed2->get_item(0);
+
+ is( $feed1->link(), $flink, "$type feed link");
+ is( $feed1->title(), $ftitle, "$type feed title");
+ is( $feed1->description(), $fdesc, "$type feed description");
+
+ like( $source, qr/<!\[CDATA\[\Q$ftitle\E\]\]>/s, "$type feed title source" );
+ like( $source, qr/<!\[CDATA\[\Q$fdesc\E\]\]>/s, "$type feed description source" );
+
+ is( $feed2->title(), $ftitle, "$type feed title back");
+ is( $feed2->description(), $fdesc, "$type feed description back");
+
+ is( $item1->link(), $ilink, "$type item link");
+ is( $item1->title(), $ititle, "$type item title");
+ is( $item1->description(), $idesc, "$type item description");
+
+ like( $source, qr/<!\[CDATA\[\Q$ititle\E\]\]>/s, "$type item title source" );
+ like( $source, qr/<!\[CDATA\[\Q$idesc\E\]\]>/s, "$type item description source" );
+
+ is( $item2->title(), $ititle, "$type item title back");
+ is( $item2->description(), $idesc, "$type item description back");
+ }
+# ----------------------------------------------------------------
+;1;
+# ----------------------------------------------------------------
Added: branches/upstream/libxml-feedpp-perl/current/t/45_cdata_multi.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feedpp-perl/current/t/45_cdata_multi.t?rev=47610&op=file
==============================================================================
--- branches/upstream/libxml-feedpp-perl/current/t/45_cdata_multi.t (added)
+++ branches/upstream/libxml-feedpp-perl/current/t/45_cdata_multi.t Sun Nov 22 03:56:26 2009
@@ -1,0 +1,53 @@
+# ----------------------------------------------------------------
+ use strict;
+ use Test::More tests => 23;
+ BEGIN { use_ok('XML::FeedPP') };
+# ----------------------------------------------------------------
+ my $url = "http://www.kawa.net/";
+ my $cate1 = "hoge";
+ my $cate2 = "pomu";
+ my $cate3 = "foobar";
+ my $catem = [ \$cate1, \$cate2, \$cate3 ];
+ my $caten = scalar @$catem;
+# ----------------------------------------------------------------
+ my $feed0 = XML::FeedPP::RSS->new();
+ $feed0->link( $url );
+ my $item0 = $feed0->add_item( $url );
+ $item0->category( $catem );
+ ok( ref $item0->category(), "init multi ref" );
+ my $source = $feed0->to_string();
+ like( $source, qr/><!\[CDATA\[\Q$cate1\E\]\]></s, "init multi 1/3" );
+ like( $source, qr/><!\[CDATA\[\Q$cate2\E\]\]></s, "init multi 2/3" );
+ like( $source, qr/><!\[CDATA\[\Q$cate3\E\]\]></s, "init multi 3/3" );
+# ----------------------------------------------------------------
+ my $feeds = [
+ XML::FeedPP::RDF->new(),
+ XML::FeedPP::RSS->new(),
+# XML::FeedPP::Atom::Atom10->new(), # Atom 1.0's <category> doesn't use CDATA
+ ];
+# ----------------------------------------------------------------
+ foreach my $feed1 ( @$feeds ) {
+ my $type = ref $feed1;
+ $feed1->merge( $source );
+ my $item1 = $feed1->get_item(0);
+ my $icate = $item1->category();
+ ok( ref $icate, "$type load ref" );
+ is( scalar @$icate, $caten, "$type load count" );
+
+ $item1->category( \$cate1 );
+ is( $item1->category(), $cate1, "$type one" );
+ like( $feed1->to_string(), qr/><!\[CDATA\[\Q$cate1\E\]\]></s, "$type one source" );
+
+ $item1->category( $catem );
+ my $jcate = $item1->category();
+ ok( ref $jcate, "$type multi ref" );
+ is( scalar @$jcate, $caten, "$type multi count" );
+
+ $source = $feed1->to_string();
+ like( $source, qr/><!\[CDATA\[\Q$cate1\E\]\]></s, "$type multi 1/3" );
+ like( $source, qr/><!\[CDATA\[\Q$cate2\E\]\]></s, "$type multi 2/3" );
+ like( $source, qr/><!\[CDATA\[\Q$cate3\E\]\]></s, "$type multi 3/3" );
+ }
+# ----------------------------------------------------------------
+;1;
+# ----------------------------------------------------------------
More information about the Pkg-perl-cvs-commits
mailing list