r7693 - in /branches/upstream/libxml-atom-perl/current: Build.PL Changes MANIFEST META.yml Makefile.PL inc/Module/Install/Build.pm lib/XML/Atom.pm lib/XML/Atom/Base.pm t/04-person.t t/19-ext.t t/23-category.t t/25-utf8-create.t t/28-ext.t

hanska-guest at users.alioth.debian.org hanska-guest at users.alioth.debian.org
Tue Sep 18 07:55:52 UTC 2007


Author: hanska-guest
Date: Tue Sep 18 07:55:52 2007
New Revision: 7693

URL: http://svn.debian.org/wsvn/?sc=1&rev=7693
Log:
[svn-upgrade] Integrating new upstream version, libxml-atom-perl (0.27)

Added:
    branches/upstream/libxml-atom-perl/current/t/28-ext.t
Removed:
    branches/upstream/libxml-atom-perl/current/Build.PL
    branches/upstream/libxml-atom-perl/current/inc/Module/Install/Build.pm
Modified:
    branches/upstream/libxml-atom-perl/current/Changes
    branches/upstream/libxml-atom-perl/current/MANIFEST
    branches/upstream/libxml-atom-perl/current/META.yml
    branches/upstream/libxml-atom-perl/current/Makefile.PL
    branches/upstream/libxml-atom-perl/current/lib/XML/Atom.pm
    branches/upstream/libxml-atom-perl/current/lib/XML/Atom/Base.pm
    branches/upstream/libxml-atom-perl/current/t/04-person.t
    branches/upstream/libxml-atom-perl/current/t/19-ext.t
    branches/upstream/libxml-atom-perl/current/t/23-category.t
    branches/upstream/libxml-atom-perl/current/t/25-utf8-create.t

Modified: branches/upstream/libxml-atom-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/Changes?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/Changes (original)
+++ branches/upstream/libxml-atom-perl/current/Changes Tue Sep 18 07:55:52 2007
@@ -1,6 +1,22 @@
 $Id$
 
 Revision history for XML::Atom
+
+0.27 2007.09.15
+    * Fixed $feed->as_xml_utf8 to work with latest XML::LibXML
+
+0.26 2007.09.15
+    * This be 0.26
+
+0.25_02  2007.06.20
+    * Fixed tests that fail with newer libxml (Thanks to knagano)
+
+0.25_01 2007.04.27
+
+    * Fixed XML::Atom::Base element accessor to work with attributes
+      (Patch from LTjake and Jshirley for OpenSearch extension)
+    * Make XML::Atom::Link easily subclassable
+      (Patch from Simon Wistow for Google Calendar support)
 
 0.25  2006.11.30
     * Fixed memory leaks in XML::Atom::Client

Modified: branches/upstream/libxml-atom-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/MANIFEST?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-atom-perl/current/MANIFEST Tue Sep 18 07:55:52 2007
@@ -1,11 +1,9 @@
-Build.PL
 Changes
 inc/ExtUtils/AutoInstall.pm
 inc/Module/AutoInstall.pm
 inc/Module/Install.pm
 inc/Module/Install/AutoInstall.pm
 inc/Module/Install/Base.pm
-inc/Module/Install/Build.pm
 inc/Module/Install/Can.pm
 inc/Module/Install/Fetch.pm
 inc/Module/Install/Include.pm
@@ -59,3 +57,4 @@
 t/samples/me.jpg
 t/samples/vox.xml
 t/TestLib.pm
+t/28-ext.t

Modified: branches/upstream/libxml-atom-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/META.yml?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/META.yml (original)
+++ branches/upstream/libxml-atom-perl/current/META.yml Tue Sep 18 07:55:52 2007
@@ -15,10 +15,10 @@
   HTML::Parser: 0
   LWP: 0
   LWP::Authen::Wsse: 0
-  XML::LibXML: 1.54
+  XML::LibXML: 1.64
   XML::XPath: 0
 requires: 
   Class::Data::Inheritable: 0
   MIME::Base64: 0
   URI: 0
-version: 0.25
+version: 0.27

Modified: branches/upstream/libxml-atom-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/Makefile.PL?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/Makefile.PL (original)
+++ branches/upstream/libxml-atom-perl/current/Makefile.PL Tue Sep 18 07:55:52 2007
@@ -19,7 +19,7 @@
 features(
     'Faster XML parsing with libxml' => [
         -default => 1,
-        recommends('XML::LibXML' => 1.54),
+        recommends('XML::LibXML' => 1.64),
     ],
     'Pure perl XML parsing with XML::XPath' => [
         -default => 0,

Modified: branches/upstream/libxml-atom-perl/current/lib/XML/Atom.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/lib/XML/Atom.pm?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/lib/XML/Atom.pm (original)
+++ branches/upstream/libxml-atom-perl/current/lib/XML/Atom.pm Tue Sep 18 07:55:52 2007
@@ -3,7 +3,7 @@
 package XML::Atom;
 use strict;
 
-our $VERSION = '0.25';
+our $VERSION = '0.27';
 
 BEGIN {
     @XML::Atom::EXPORT = qw( LIBXML );

Modified: branches/upstream/libxml-atom-perl/current/lib/XML/Atom/Base.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/lib/XML/Atom/Base.pm?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/lib/XML/Atom/Base.pm (original)
+++ branches/upstream/libxml-atom-perl/current/lib/XML/Atom/Base.pm Tue Sep 18 07:55:52 2007
@@ -1,4 +1,4 @@
-# $Id: /mirror/code/XML-Atom/trunk/lib/XML/Atom/Base.pm 5342 2006-09-16T06:39:51.745764Z miyagawa  $
+# $Id: /mirror/code/XML-Atom/trunk/lib/XML/Atom/Base.pm 6911 2007-09-16T04:41:21.502409Z miyagawa  $
 
 package XML::Atom::Base;
 use strict;
@@ -28,7 +28,20 @@
     unless ($elem = $param{Elem}) {
         if (LIBXML) {
             my $doc = XML::LibXML::Document->createDocument('1.0', 'utf-8');
-            $elem = $doc->createElementNS($obj->ns, $obj->element_name);
+            my $ns = $obj->ns;
+            my ($ns_uri, $ns_prefix);
+            if ( ref $ns and $ns->isa('XML::Atom::Namespace') ) {
+                $ns_uri     = $ns->{uri};
+                $ns_prefix  = $ns->{prefix};
+            } else {
+                $ns_uri = $ns;
+            }
+            if ( $ns_uri and $ns_prefix ) {
+                $elem = $doc->createElement($obj->element_name);
+                $elem->setNamespace( $ns_uri, $ns_prefix, 1 );
+            } else {
+                $elem = $doc->createElementNS($obj->ns, $obj->element_name);
+            }
             $doc->setDocumentElement($elem);
         } else {
             $elem = XML::XPath::Node::Element->new($obj->element_name);
@@ -162,16 +175,35 @@
 
 sub mk_elem_accessors {
     my $class = shift;
-    my(@list) = @_;
-    no strict 'refs';
-    for my $elem (@list) {
+    my (@list) = @_;
+    my $override_ns;
+
+    if ( ref $list[-1] ) {
+        my $ns_list = pop @list;
+        if ( ref $ns_list eq 'ARRAY' ) {
+            $ns_list = $ns_list->[0];
+        }
+        if ( ref($ns_list) =~ /Namespace/ ) {
+            $override_ns = $ns_list;
+        } else {
+            if ( ref $ns_list eq 'HASH' ) {
+                $override_ns = XML::Atom::Namespace->new(%$ns_list);
+            }
+            elsif ( not ref $ns_list and $ns_list ) {
+                $override_ns = $ns_list;
+            }
+        } 
+    }
+
+    no strict 'refs';
+    for my $elem ( @list ) {
         (my $meth = $elem) =~ tr/\-/_/;
         *{"${class}::$meth"} = sub {
             my $obj = shift;
             if (@_) {
-                return $obj->set($obj->ns, $elem, $_[0]);
-            } else {
-                return $obj->get($obj->ns, $elem);
+                return $obj->set( $override_ns || $obj->ns, $elem, $_[0]);
+            } else {
+                return $obj->get( $override_ns || $obj->ns, $elem);
             }
         };
     }
@@ -293,7 +325,7 @@
         my($stuff) = @_;
 
         my $ns_uri = $ext_class->element_ns || $obj->ns;
-        my $elem = ref $stuff eq $ext_class ?
+        my $elem = (ref $stuff && UNIVERSAL::isa($stuff, $ext_class)) ?
             $stuff->elem : create_element($ns_uri, $name);
         $obj->elem->appendChild($elem);
 
@@ -321,7 +353,11 @@
 
 sub as_xml_utf8 {
     my $obj = shift;
-    Encode::encode_utf8($obj->as_xml);
+    my $xml = $obj->as_xml;
+    if (utf8::is_utf8($xml)) {
+        return Encode::encode_utf8($xml);
+    }
+    return $xml;
 }
 
 1;

Modified: branches/upstream/libxml-atom-perl/current/t/04-person.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/t/04-person.t?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/t/04-person.t (original)
+++ branches/upstream/libxml-atom-perl/current/t/04-person.t Tue Sep 18 07:55:52 2007
@@ -22,5 +22,5 @@
 my $xml = $person->as_xml;
 like $xml, qr/^<\?xml version="1.0" encoding="utf-8"\?>/;
 like $xml, qr/<author xmlns="http:\/\/purl.org\/atom\/ns#">/;
-like $xml, qr/<name xmlns="http:\/\/purl.org\/atom\/ns#">Baz Quux<\/name>/;
-like $xml, qr/<email xmlns="http:\/\/purl.org\/atom\/ns#">foo\@bar.com<\/email>/;
+like $xml, qr/<name(?: xmlns="http:\/\/purl.org\/atom\/ns#")?>Baz Quux<\/name>/;
+like $xml, qr/<email(?: xmlns="http:\/\/purl.org\/atom\/ns#")?>foo\@bar.com<\/email>/;

Modified: branches/upstream/libxml-atom-perl/current/t/19-ext.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/t/19-ext.t?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/t/19-ext.t (original)
+++ branches/upstream/libxml-atom-perl/current/t/19-ext.t Tue Sep 18 07:55:52 2007
@@ -1,4 +1,4 @@
-# $Id: /mirror/code/XML-Atom/trunk/t/19-ext.t 5803 2006-09-19T22:35:49.408282Z btrott  $
+# $Id: /mirror/code/XML-Atom/trunk/t/19-ext.t 6810 2007-06-20T19:20:38.705942Z miyagawa  $
 
 use strict;
 use FindBin;
@@ -11,7 +11,7 @@
 $foo->bar(1);
 is $foo->bar, 1;
 like $foo->as_xml, qr/<foo xmlns="http:\/\/www.example.com\/ns\/">/;
-like $foo->as_xml, qr/<bar xmlns="http:\/\/www.example.com\/ns\/">1<\/bar>/;
+like $foo->as_xml, qr/<bar(?: xmlns="http:\/\/www.example.com\/ns\/")?>1<\/bar>/;
 
 my $feed = XML::Atom::Feed->new;
 $feed->foo($foo);

Modified: branches/upstream/libxml-atom-perl/current/t/23-category.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/t/23-category.t?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/t/23-category.t (original)
+++ branches/upstream/libxml-atom-perl/current/t/23-category.t Tue Sep 18 07:55:52 2007
@@ -47,7 +47,7 @@
     is $cat[1]->term, "bar";
 
     my $xml = $entry->as_xml;
-    like $xml, qr!<category xmlns="http://www.w3.org/2005/Atom" term="foo" scheme="http://example.org/foo#" label="foo bar"/>!;
-    like $xml, qr!<category xmlns="http://www.w3.org/2005/Atom" term="bar" scheme="http://example.org/bar#"/>!;
+    like $xml, qr!<category(?: xmlns="http://www.w3.org/2005/Atom")? term="foo" scheme="http://example.org/foo#" label="foo bar"/>!;
+    like $xml, qr!<category(?: xmlns="http://www.w3.org/2005/Atom")? term="bar" scheme="http://example.org/bar#"/>!;
 }
 

Modified: branches/upstream/libxml-atom-perl/current/t/25-utf8-create.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/t/25-utf8-create.t?rev=7693&op=diff
==============================================================================
--- branches/upstream/libxml-atom-perl/current/t/25-utf8-create.t (original)
+++ branches/upstream/libxml-atom-perl/current/t/25-utf8-create.t Tue Sep 18 07:55:52 2007
@@ -6,6 +6,7 @@
 my $feed = XML::Atom::Feed->new(Version => 1.0);
 $feed->version; # 1.0
 $feed->title("Dicion\xc3\xa1rios");
+is $feed->title, "Dicion\xc3\xa1rios";
 
 my $out = "$FindBin::Bin/utf8-create.xml";
 open my $fh, ">", $out;

Added: branches/upstream/libxml-atom-perl/current/t/28-ext.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-atom-perl/current/t/28-ext.t?rev=7693&op=file
==============================================================================
--- branches/upstream/libxml-atom-perl/current/t/28-ext.t (added)
+++ branches/upstream/libxml-atom-perl/current/t/28-ext.t Tue Sep 18 07:55:52 2007
@@ -1,0 +1,85 @@
+package XML::Atom::Ext::Test;
+
+use base qw( XML::Atom::Base );
+
+XML::Atom::Feed->mk_elem_accessors(qw(totalResults startIndex itemsPerPage),
+    [ element_ns() ]
+);
+
+XML::Atom::Feed->mk_object_list_accessor( ext_link => 'XML::Atom::Ext::Test::Link' );
+#XML::Atom::Feed->mk_object_accessor( Query => 'XML::Atom::Ext::::Query' );
+
+sub element_ns {
+    return XML::Atom::Namespace->new("testext" => q{http://test.com/-/spec/test/0.1/} );
+}
+
+1;
+
+package XML::Atom::Ext::Test::Link;
+
+use base qw( XML::Atom::Base );
+
+__PACKAGE__->mk_attr_accessors( qw( href hreflang rel type ) );
+
+sub element_name {
+    return 'link'
+}
+
+sub element_ns {
+    return XML::Atom::Ext::Test->element_ns;
+}
+
+1;
+
+package main;
+
+use strict;
+use warnings;
+
+use XML::Atom::Feed;
+use Test::More tests => 8;
+
+my $feed = XML::Atom::Feed->new;
+
+my $link = XML::Atom::Link->new;
+    $link->href(q{http://www.legacy_link.com});
+    $feed->add_link($link);
+
+my $ext_link = XML::Atom::Ext::Test::Link->new;
+    $ext_link->href(q{http://www.extended_link.org});
+    $feed->add_ext_link($ext_link);
+
+ok($ext_link, "creating extension link");
+
+# Test simple accessors
+my @accessors = qw( totalResults startIndex itemsPerPage );
+
+for ( @accessors ) {
+    $feed->$_( 2 );
+}
+for ( @accessors ) {
+    is($feed->$_, 2, "extension accessors");
+}
+
+my $xml = $feed->as_xml;
+like( $xml, qr{xmlns:testext="http://test.com/-/spec/test/0.1/"}, "ext namespace");
+like( $xml, qr{<testext:link xmlns:testext="http://test.com/-/spec/test/0.1/" href="http://www.extended_link.org"/>}, "ext link match");
+
+like( $xml, qr{<testext:startIndex xmlns:testext="http://test.com/-/spec/test/0.1/">2</testext:startIndex>}, "ext method match");
+
+like( $xml, qr{<link(?: xmlns="http://purl.org/atom/ns#")? href="http://www.legacy_link.com"/>}, "standard link match");
+
+
+__END__
+
+=head2 Expected Output
+
+ <?xml version="1.0" encoding="utf-8"?>
+ <feed xmlns="http://purl.org/atom/ns#" xmlns:testext="http://test.com/-/spec/test/0.1/">
+  <link xmlns="http://purl.org/atom/ns#" href="http://www.legacy_link.com"/>
+  <testext:link xmlns:testext="http://test.com/-/spec/test/0.1/" href="http://www.extended_link.org"/>
+  <testext:totalResults xmlns:testext="http://test.com/-/spec/test/0.1/">2</testext:totalResults>
+  <testext:startIndex xmlns:testext="http://test.com/-/spec/test/0.1/">2</testext:startIndex>
+  <testext:itemsPerPage xmlns:testext="http://test.com/-/spec/test/0.1/">2</testext:itemsPerPage>
+ </feed>
+




More information about the Pkg-perl-cvs-commits mailing list