XML-Atom-Service-v0.16.2000755000765000024 011736731515 14336 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/Build.PL000444000765000024 125511736731515 15772 0ustar00inouestaff000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'XML::Atom::Service', license => 'perl', dist_author => 'Takeru INOUE ', dist_version_from => 'lib/XML/Atom/Service.pm', requires => { 'version' => 0, 'XML::Atom' => 0.27, }, build_requires => { 'Test::More' => 0, 'Test::NoWarnings' => 0, # 'Test::Perl::Critic' => 0, # 'Test::Pod' => 1.14, # 'Test::Pod::Coverage' => 1.04, }, add_to_cleanup => [ 'XML-Atom-Service-*' ], ); $builder->create_build_script(); XML-Atom-Service-v0.16.2/Changes000444000765000024 666311736731515 16001 0ustar00inouestaff0000000000002012-04-04 Takeru INOUE * release 0.16.1: * t/02.categories.t and t/05.service.t - fixed a bug on regexp 2010-03-15 Takeru INOUE * release 0.16.1: * Build.PL - fix dependency * t/perlcritic.t - check $ENV{TEST_CRITIC} whether to execute this test 2008-03-25 Takeru INOUE * release 0.16.0: * lib, t - change coding conventions 2007-09-18 Takeru INOUE * release 0.15.4: * Build.PL - change version of XML::Atom 2007-09-18 Takeru INOUE * release 0.15.3: * t/06.atompub - fix a bug 2007-09-14 Takeru INOUE * release 0.15.2: * t/03.collection.t t/04.workspace.t t/05.service.t t/06.atompub - fix namespaces 2007-09-12 Takeru INOUE * release 0.15.1: * XML/Atom/Atompub.pm - avoid redefining subroutines for XML::Atom::Thing 2007-09-10 Takeru INOUE * release 0.15.0: * XML/Atom/Service.pm - change the default namespaces to new ones, 'http://purl.org/atom/ns#' and 'http://www.w3.org/2007/app' * XML/Atom/Atompub.pm - move extension methods of XML::Atom::Entry from XML/Atom/Service.pm - add short-cut for link/@href * XML/Atom/Service.pm, XML/Atom/Categories.pm - fix document bugs 2007-08-12 Takeru INOUE * release 0.14.0: * XML/Atom/Service.pm - getService is moved in Atompub::Client * XML/Atom/Categories.pm - getCategories is moved in Atompub::Client 2007-07-24 Takeru INOUE * release 0.13.4: * XML/Atom/Service.pm - support //entry/content/@src 2007-07-23 Takeru INOUE * release 0.13.3: * MANIFEST - add t/samples/atom-1.0/06.entry 2007-07-21 Takeru INOUE * release 0.13.2: * XML/Atom/Service.pm, XML/Atom/Collection.pm: - support multiple //collection/accept 2007-07-21 Takeru INOUE * release 0.13.1: * XML/Atom/Service.pm, XML/Atom/Categories.pm: - avoid redefining subroutines for XML::Atom 2007-07-21 Takeru INOUE * release 0.13.0: * XML/Atom/Service.pm: - add some APP elements to XML::Atom::Entry, //entry/edited, //entry/control/draft * add t/06.entry.t * XML/Atom/Categories.pm: - getCategory is DEPRECATED (will be removed in the near future) * t/0*.t - change namespace to 'http://www.w3.org/2007/app' 2007-07-02 Takeru INOUE * release 0.12.1: * XML/Atom/Service.pm: - introduce global variable $DefaultNamespace 2007-07-02 Takeru INOUE * release 0.12.0: - change namespace to 'http://www.w3.org/2007/app' based on the new APP specirfication 2007-06-10 Takeru INOUE * release 0.11.1: * t/0*.t - xmlns is optional in regexp for newer LibXML 2007-03-22 Takeru INOUE * release 0.11.0: * XML/Atom/Service.pm: - implement XML::Atom::Client::getService() * XML/Atom/Categories.pm: - implement XML::Atom::Client::getCategories() * add t/05.client.t 2007-02-13 Takeru INOUE * release 0.10.1 (0.010001): updated by Module::Starter * write README * add use warnings; use Carp; * add POD tests 2007-02-12 Takeru INOUE * release 0.01: created by h2xs 1.23 with options -XAn XML::Atom::Service XML-Atom-Service-v0.16.2/Makefile.PL000444000765000024 25111736731515 16423 0ustar00inouestaff000000000000use lib qw(lib); use Module::Build::Compat; Module::Build::Compat->run_build_pl(args => \@ARGV); Module::Build::Compat->write_makefile(build_class => 'Module::Build'); XML-Atom-Service-v0.16.2/MANIFEST000444000765000024 70111736731515 15602 0ustar00inouestaff000000000000Build.PL Changes MANIFEST META.yml # Will be created by "make dist" Makefile.PL README lib/XML/Atom/Categories.pm lib/XML/Atom/Collection.pm lib/XML/Atom/Service.pm lib/XML/Atom/Workspace.pm lib/XML/Atom/Atompub.pm t/00.load.t t/01.namespace.t t/02.categories.t t/03.collection.t t/04.workspace.t t/05.service.t t/06.atompub.t t/perlcritic.t t/pod-coverage.t t/pod.t t/samples/sample.atomcat t/samples/sample.atomsvc t/samples/sample.atom META.json XML-Atom-Service-v0.16.2/META.json000444000765000024 315111736731515 16114 0ustar00inouestaff000000000000{ "abstract" : "Atom Service Document object", "author" : [ "Takeru INOUE " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.112621", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "XML-Atom-Service", "prereqs" : { "build" : { "requires" : { "Test::More" : 0, "Test::NoWarnings" : 0 } }, "configure" : { "requires" : { "Module::Build" : "0.38" } }, "runtime" : { "requires" : { "XML::Atom" : "0.27", "version" : 0 } } }, "provides" : { "XML::Atom::Atompub" : { "file" : "lib/XML/Atom/Atompub.pm", "version" : 0 }, "XML::Atom::Categories" : { "file" : "lib/XML/Atom/Categories.pm", "version" : 0 }, "XML::Atom::Collection" : { "file" : "lib/XML/Atom/Collection.pm", "version" : 0 }, "XML::Atom::Control" : { "file" : "lib/XML/Atom/Atompub.pm", "version" : 0 }, "XML::Atom::Service" : { "file" : "lib/XML/Atom/Service.pm", "version" : "v0.16.2" }, "XML::Atom::Workspace" : { "file" : "lib/XML/Atom/Workspace.pm", "version" : 0 } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "v0.16.2" } XML-Atom-Service-v0.16.2/META.yml000444000765000024 173611736731515 15753 0ustar00inouestaff000000000000--- abstract: 'Atom Service Document object' author: - 'Takeru INOUE ' build_requires: Test::More: 0 Test::NoWarnings: 0 configure_requires: Module::Build: 0.38 dynamic_config: 1 generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.112621' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: XML-Atom-Service provides: XML::Atom::Atompub: file: lib/XML/Atom/Atompub.pm version: 0 XML::Atom::Categories: file: lib/XML/Atom/Categories.pm version: 0 XML::Atom::Collection: file: lib/XML/Atom/Collection.pm version: 0 XML::Atom::Control: file: lib/XML/Atom/Atompub.pm version: 0 XML::Atom::Service: file: lib/XML/Atom/Service.pm version: v0.16.2 XML::Atom::Workspace: file: lib/XML/Atom/Workspace.pm version: 0 requires: XML::Atom: 0.27 version: 0 resources: license: http://dev.perl.org/licenses/ version: v0.16.2 XML-Atom-Service-v0.16.2/README000444000765000024 106211736731515 15352 0ustar00inouestaff000000000000 This is XML::Atom::Service, an implementation of Atom Service and Category Documents. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install Alternatively, to install with Module::Build, you can use the following commands: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES XML::Atom COPYRIGHT AND LICENCE Copyright (C) 2007, Takeru INOUE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. XML-Atom-Service-v0.16.2/lib000755000765000024 011736731515 15104 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/lib/XML000755000765000024 011736731515 15544 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/lib/XML/Atom000755000765000024 011736731515 16444 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/lib/XML/Atom/Atompub.pm000444000765000024 2042011736731515 20564 0ustar00inouestaff000000000000package XML::Atom::Atompub; use strict; use warnings; use XML::Atom::Entry; use XML::Atom::Service; use XML::Atom::Thing; unless (XML::Atom::Entry->can('edited')) { *XML::Atom::Entry::edited = sub { my($self, $edited) = @_; my $ns_uri = $XML::Atom::Service::DefaultNamespace; my $app = XML::Atom::Namespace->new(app => $ns_uri); if ($edited) { $self->set($app, 'edited', $edited); } else { $self->get($app, 'edited'); } }; } unless (XML::Atom::Entry->can('control')) { XML::Atom::Entry->mk_object_list_accessor('control' => 'XML::Atom::Control'); package XML::Atom::Control; use base qw(XML::Atom::Base); __PACKAGE__->mk_elem_accessors(qw(draft)); sub element_name { 'control' } sub element_ns { $XML::Atom::Service::DefaultNamespace } } unless (XML::Atom::Content->can('src')) { XML::Atom::Content->mk_attr_accessors(qw(src)); } unless (XML::Atom::Thing->can('alternate_link')) { *XML::Atom::Thing::alternate_link = sub { my($atom, @args) = @_; my @hrefs; if (@args) { my @links1 = grep { $_->rel && $_->rel ne 'alternate'} $atom->links; my @links2 = map { my $link = XML::Atom::Link->new; $link->rel('alternate'); $link->href($_); $link } @args; $atom->link( @links1, @links2 ); @hrefs = @_; } else { @hrefs = map { $_->href } grep { ! $_->rel || $_->rel eq 'alternate' } $atom->links; } wantarray ? @hrefs : $hrefs[0]; }; } for my $rel (qw(self edit edit-media related enclosure via first previous next last)) { no strict 'refs'; ## no critic my $method = join '_', $rel, 'link'; $method =~ s/-/_/g; next if XML::Atom::Thing->can($method); *{"XML::Atom::Thing::$method"} = sub { my($atom, @args) = @_; my @hrefs; if (@args) { my @links1 = grep { ! $_->rel || $_->rel ne $rel } $atom->links; my @links2 = map { my $link = XML::Atom::Link->new; $link->rel( $rel ); $link->href($_); $link } @args; $atom->link( @links1, @links2 ); @hrefs = @_; } else { @hrefs = map { $_->href } grep { $_->rel && $_->rel eq $rel } $atom->links; } wantarray ? @hrefs : $hrefs[0]; }; } 1; __END__ =head1 NAME XML::Atom::Atompub - Extensions of XML::Atom for the Atom Publishing Protocol =head1 SYNOPSIS use XML::Atom::Entry; use XML::Atom::Feed; use XML::Atom::Atompub; my $entry = XML::Atom::Entry->new; # 2007-01-01T00:00:00Z $entry->edited('2007-01-01T00:00:00Z'); # yes my $control = XML::Atom::Control->new; $control->draft('yes'); $entry->control($control); # my $content = XML::Atom::Content->new; $content->type('image/png'); $content->src('http://example.com/foo.png'); $entry->content($content); # $entry->alternate_link('http://example.com/foo.html'); my $feed = XML::Atom::Feed->new; # $feed->self_link('http://example.com'); =head1 METHODS of XML::Atom Some elements are introduced by the Atom Publishing Protocol, which are imported into L by this module. =head2 $entry->control([ $control ]) Returns an L object representing the control of the Entry, or C if there is no control. If $control is supplied, it should be an L object representing the control. For example: my $control = XML::Atom::Control->new; $control->draft('yes'); $entry->control($control); =head2 $entry->edited([ $edited ]) Returns an I element. If $edited is given, sets the I element. =head2 $content->src([ $src ]) Returns a value of I attribute in I element. If $src is given, the I attribute is added. =head2 $atom->alternate_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->self_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->edit_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->edit_media_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->related_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->enclosure_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->via_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->first_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->previous_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->next_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head2 $atom->last_link([ $href ]) Returns a value of I attribute in I element with a link relation of I. If $href is given, an I element with a link relation of I is added. =head1 SEE ALSO L L =head1 AUTHOR Takeru INOUE, Etakeru.inoue _ gmail.comE =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Takeru INOUE C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut XML-Atom-Service-v0.16.2/lib/XML/Atom/Categories.pm000444000765000024 1041511736731515 21245 0ustar00inouestaff000000000000package XML::Atom::Categories; use warnings; use strict; use Carp; use XML::Atom; use XML::Atom::Category; use XML::Atom::Service; use base qw(XML::Atom::Thing); __PACKAGE__->mk_attr_accessors(qw(fixed scheme href)); sub element_name { 'categories' } sub element_ns { $XML::Atom::Service::DefaultNamespace } sub XML::Atom::Category::element_ns { $XML::Atom::Util::NS_MAP{$XML::Atom::DefaultVersion} } 1; __END__ =head1 NAME XML::Atom::Categories - Atom Category Document object =head1 SYNOPSIS use XML::Atom::Service; my $category = XML::Atom::Category->new; $category->term('joke'); $category->scheme('http://example.org/extra-cats/'); my $categories = XML::Atom::Categories->new; $categories->add_category($category); my $xml = $categories->as_xml; # Get a list of the category elements. my @category = $categories->category; =head1 DESCRIPTION Category Documents contain lists of categories described using the "atom:category" element from the Atom Syndication Format [RFC4287]. The Category Document is defined in "The Atom Publishing Protocol," IETF Internet-Draft. =head1 METHODS =head2 XML::Atom::Categories->new([ $stream ]) Creates a new Category Document object, and if $stream is supplied, fills it with the data specified by $stream. Automatically handles autodiscovery if $stream is a URI (see below). Returns the new L object. On failure, returns C. $stream can be any one of the following: =over 4 =item * Reference to a scalar This is treated as the XML body of the Category Document. =item * Scalar This is treated as the name of a file containing the Category Document XML. =item * Filehandle This is treated as an open filehandle from which the Category Document XML can be read. =item * URI object This is treated as a URI, and the Category Document XML will be retrieved from the URI. =back =head2 $categories->categoryk([ $category ]) If called in scalar context, returns an L object corresponding to the first "app:category" element found in the Category Document. If called in list context, returns a list of L objects corresponding to all of the "app:category" elements found in the Service Document. =head2 $service->add_category($category) Adds the category $category, which must be an L object, to the Service Document as a new "app:category" element. For example: my $category = XML::Atom::Category->new; $category->term('joke'); $categories->add_category($category); =head2 $categories->fixed =head2 $categories->scheme =head2 $categories->href =head2 $categories->element_name =head2 $categories->element_ns =head1 SEE ALSO L L L =head1 AUTHOR Takeru INOUE, Etakeru.inoue _ gmail.comE =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Takeru INOUE C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut XML-Atom-Service-v0.16.2/lib/XML/Atom/Collection.pm000444000765000024 1147211736731515 21257 0ustar00inouestaff000000000000package XML::Atom::Collection; use warnings; use strict; use Carp; use XML::Atom; use XML::Atom::Service; use base qw(XML::Atom::Base); __PACKAGE__->mk_attr_accessors(qw(href)); sub element_name { 'collection' } sub element_ns { $XML::Atom::Service::DefaultNamespace } sub title { my($self, $title) = @_; my $ns_uri = $XML::Atom::Util::NS_MAP{$XML::Atom::DefaultVersion}; my $atom = XML::Atom::Namespace->new(atom => $ns_uri); if (defined $title) { $self->set($atom, 'title', $title); } else { $self->get($atom, 'title'); } } __PACKAGE__->mk_object_list_accessor('categories' => 'XML::Atom::Categories'); # accessors to text elements, multiple which there can be unless (XML::Atom::Base->can('mk_elem_list_accessor')) { use XML::Atom::Util qw(childlist create_element); *XML::Atom::Base::mk_elem_list_accessor = sub { my($class, $name, $moniker) = @_; no strict 'refs'; ## no critic *{"$class\::$name"} = sub { my($obj, @args) = @_; my $ns_uri = $class->element_ns || $obj->ns; if (@args) { # setter: clear existent elements first my @elem = childlist($obj->elem, $ns_uri, $name); for my $el (@elem) { $obj->elem->removeChild($el); } # add the new elements for each my $adder = "add_$name"; for my $add_elem (@args) { $obj->$adder($add_elem); } } else { # getter: my @children = map { $_->textContent } childlist( $obj->elem, $ns_uri, $name ); wantarray ? @children : $children[0]; } }; if ($moniker) { *{"$class\::$moniker"} = sub { my($obj, @args) = @_; if (@args) { return $obj->$name(@args); } else { my @obj = $obj->$name; return wantarray ? @obj : \@obj; } }; } *{"$class\::add_$name"} = sub { my($obj, $stuff) = @_; my $ns_uri = $class->element_ns || $obj->ns; my $elem = create_element($ns_uri, 'accept'); $elem->appendText($stuff); $obj->elem->appendChild($elem); }; }; } __PACKAGE__->mk_elem_list_accessor('accept', 'accepts'); 1; __END__ =head1 NAME XML::Atom::Collection - Collection object =head1 SYNOPSIS my $categories = XML::Atom::Categories->new; $categories->href('http://example.com/cats/forMain.cats'); $categories->add_category($category); my $collection = XML::Atom::Collection->new; $collection->href('http://example.org/reilly/main'); $collection->title('My Blog Entries'); $collection->categories($categories); # Get a list of the categories elements my @categories = $collection->categories; =head1 METHODS =head2 XML::Atom::Collection->new =head2 $collection->href =head2 $collection->title =head2 $collection->accept =head2 $collection->accepts =head2 $collection->add_accept =head2 $collection->categories =head2 $collection->element_name =head2 $collection->element_ns =head1 SEE ALSO L L =head1 AUTHOR Takeru INOUE, Etakeru.inoue _ gmail.comE =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Takeru INOUE C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut XML-Atom-Service-v0.16.2/lib/XML/Atom/Service.pm000444000765000024 1416111736731515 20562 0ustar00inouestaff000000000000package XML::Atom::Service; use warnings; use strict; use Carp; use XML::Atom 0.27; use XML::Atom::Workspace; use XML::Atom::Collection; use XML::Atom::Categories; use XML::Atom::Atompub; use base qw(XML::Atom::Thing); use version; our $VERSION = qv('0.16.2'); #our $DefaultNamespace = 'http://purl.org/atom/app#'; our $DefaultNamespace = 'http://www.w3.org/2007/app'; $XML::Atom::DefaultVersion = '1.0'; sub element_name { 'service' } sub element_ns { $DefaultNamespace } __PACKAGE__->mk_object_list_accessor('workspace' => 'XML::Atom::Workspace', 'workspaces'); 1; __END__ =head1 NAME XML::Atom::Service - Atom Service Document object =head1 COMPATIBILITY ISSUES L has B since v0.15.0. The new namespaces are 'http://www.w3.org/2005/Atom' and 'http://www.w3.org/2007/app'. See L in details. =head1 SYNOPSIS use XML::Atom::Service; my $category = XML::Atom::Category->new; $category->term('joke'); $category->scheme('http://example.org/extra-cats/'); my $categories = XML::Atom::Categories->new; $categories->add_category($category); my $collection = XML::Atom::Collection->new; $collection->href('http://example.org/reilly/main'); $collection->title('My Blog Entries'); $collection->add_accept('application/atom+xml;type=entry'); $collection->add_categories($categories); my $workspace = XML::Atom::Workspace->new; $workspace->title('Main Site'); $workspace->add_collection($collection); my $service = XML::Atom::Service->new; $service->add_workspace($workspace); my $xml = $service->as_xml; # Get lists of the workspace, collection, and categories elements my @workspace = $service->workspaces; my @collection = $workspace[0]->collections; my @categories = $collection[0]->categories; =head1 DESCRIPTION The Atom Publishing Protocol (Atompub) is a protocol for publishing and editing Web resources described at L. L is an Service Document implementation. In the Atom Publishing Protocol, a client needs to first discover the capabilities and locations of Collections. The Service Document is designed to support this discovery process. The document describes the location and capabilities of Collections. The Atom Publishing Protocol introduces some new XML elements, such as I and I, which are imported into L. See L in detail. This module was tested in InteropTokyo2007 L, and interoperated with other implementations. =head1 METHODS =head2 XML::Atom::Service->new([ $stream ]) Creates a new Service Document object, and if $stream is supplied, fills it with the data specified by $stream. Automatically handles autodiscovery if $stream is a URI (see below). Returns the new L object. On failure, returns C. $stream can be any one of the following: =over 4 =item * Reference to a scalar This is treated as the XML body of the Service Document. =item * Scalar This is treated as the name of a file containing the Service Document XML. =item * Filehandle This is treated as an open filehandle from which the Service Document XML can be read. =item * URI object This is treated as a URI, and the Service Document XML will be retrieved from the URI. =back =head2 $service->workspace If called in scalar context, returns an L object corresponding to the first "app:workspace" element found in the Service Document. If called in list context, returns a list of L objects corresponding to all of the app:workspace elements found in the Service Document. =head2 $service->add_workspace($workspace) Adds the workspace $workspace, which must be an L object, to the Service Document as a new app:workspace element. For example: my $workspace = XML::Atom::Workspace->new; $workspace->title('Foo Bar'); $service->add_workspace($workspace); =head2 $service->element_name =head2 $service->element_ns =head1 NAMESPACES By default, L will create entities using the new Atom namespaces, 'http://www.w3.org/2005/Atom' and 'http://www.w3.org/2007/app'. In order to use old ones, you can set them by setting global variables like: use XML::Atom; use XML::Atom::Service; $XML::Atom::DefaultVersion = '0.3'; # 'http://purl.org/atom/ns#' $XML::Atom::Service::DefaultNamespace = 'http://purl.org/atom/app#'; =head1 SEE ALSO L L L =head1 AUTHOR Takeru INOUE, Etakeru.inoue _ gmail.comE =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Takeru INOUE C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut XML-Atom-Service-v0.16.2/lib/XML/Atom/Workspace.pm000444000765000024 611611736731515 21101 0ustar00inouestaff000000000000package XML::Atom::Workspace; use warnings; use strict; use Carp; use XML::Atom; use XML::Atom::Service; use base qw(XML::Atom::Base); sub element_name { 'workspace' } sub element_ns { $XML::Atom::Service::DefaultNamespace } sub title { my($self, $title) = @_; my $ns_uri = $XML::Atom::Util::NS_MAP{$XML::Atom::DefaultVersion}; my $atom = XML::Atom::Namespace->new(atom => $ns_uri); if (defined $title) { $self->set( $atom, 'title', $title ); } else { $self->get( $atom, 'title' ); } } __PACKAGE__->mk_object_list_accessor('collection' => 'XML::Atom::Collection', 'collections'); 1; __END__ =head1 NAME XML::Atom::Workspace - Workspace object =head1 SYNOPSIS my $categories = XML::Atom::Categories->new; $categories->href('http://example.com/cats/forMain.cats'); $categories->add_category($category); my $collection = XML::Atom::Collection->new; $collection->href('http://example.org/reilly/main'); $collection->title('My Blog Entries'); $collection->categories($categories); my $workspace = XML::Atom::Workspace->new; $workspace->title('Main Site'); $workspace->add_collection($collection); # Get lists of the collection and categories elements my @collection = $workspace->collections; my @categories = $collection[0]->categories; =head1 METHODS =head2 XML::Atom::Workspace->new =head2 $workspace->title =head2 $workspace->collection =head2 $workspace->add_collection =head2 $workspace->element_name =head2 $workspace->element_ns =head1 SEE ALSO L L =head1 AUTHOR Takeru INOUE, Etakeru.inoue _ gmail.comE =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Takeru INOUE C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut XML-Atom-Service-v0.16.2/t000755000765000024 011736731515 14601 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/t/00.load.t000444000765000024 21611736731515 16237 0ustar00inouestaff000000000000use Test::More tests => 1; BEGIN { use_ok( 'XML::Atom::Service' ); } diag( "Testing XML::Atom::Service $XML::Atom::Service::VERSION" ); XML-Atom-Service-v0.16.2/t/01.namespace.t000444000765000024 35311736731515 17257 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 2; use XML::Atom::Service; is $XML::Atom::DefaultVersion, '1.0'; is $XML::Atom::Service::DefaultNamespace, 'http://www.w3.org/2007/app'; XML-Atom-Service-v0.16.2/t/02.categories.t000444000765000024 505211736731515 17472 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 40; use XML::Atom::Categories; use XML::Atom::Category; my $categories = XML::Atom::Categories->new; isa_ok $categories, 'XML::Atom::Categories'; $categories->fixed('yes'); is $categories->fixed, 'yes'; $categories->scheme('http://example.org/extra-cats/'); is $categories->scheme, 'http://example.org/extra-cats/'; my $category = XML::Atom::Category->new; isa_ok $category, 'XML::Atom::Category'; ok $category->elem; $category->scheme('http://example.org/extra-cats/'); is $category->scheme, 'http://example.org/extra-cats/'; $category->term('joke'); is $category->term, 'joke'; $categories->add_category($category); $category = $categories->category; isa_ok $category, 'XML::Atom::Category'; is $category->scheme, 'http://example.org/extra-cats/'; is $category->term, 'joke'; my $category2 = XML::Atom::Category->new; $category2->scheme('http://example.org/extra-cats/'); $category2->term('serious'); $categories->add_category($category2); my @category = $categories->category; is scalar(@category), 2; isa_ok $category[0], 'XML::Atom::Category'; is $category[0]->scheme, 'http://example.org/extra-cats/'; is $category[0]->term, 'joke'; isa_ok $category[1], 'XML::Atom::Category'; is $category[1]->scheme, 'http://example.org/extra-cats/'; is $category[1]->term, 'serious'; @category = $categories->categories; is scalar(@category), 2; isa_ok $category[0], 'XML::Atom::Category'; is $category[0]->scheme, 'http://example.org/extra-cats/'; is $category[0]->term, 'joke'; isa_ok $category[1], 'XML::Atom::Category'; is $category[1]->scheme, 'http://example.org/extra-cats/'; is $category[1]->term, 'serious'; my $xml = $categories->as_xml; like $xml, qr!^<\?xml version="1.0" encoding="utf-8"\?>!i; like $xml, qr!$!; my $sample = "t/samples/sample.atomcat"; $categories = XML::Atom::Categories->new($sample); isa_ok $categories, 'XML::Atom::Categories'; is $categories->fixed, 'yes'; is $categories->scheme, 'http://example.com/cats/big3'; @category = $categories->category; is scalar(@category), 3; is $category[0]->term, 'animal'; is $category[1]->term, 'vegetable'; is $category[2]->term, 'mineral'; XML-Atom-Service-v0.16.2/t/03.collection.t000444000765000024 302111736731515 17473 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 16; use XML::Atom::Categories; use XML::Atom::Category; use XML::Atom::Collection; my $collection = XML::Atom::Collection->new; isa_ok $collection, 'XML::Atom::Collection'; $collection->href('http://example.org/reilly/main'); is $collection->href, 'http://example.org/reilly/main'; $collection->title('Foo Bar'); is $collection->title, 'Foo Bar'; $collection->add_accept('image/png'); $collection->add_accept('image/jpeg'); my @accepts = $collection->accepts; is @accepts, 2; is $accepts[0], 'image/png'; is $accepts[1], 'image/jpeg'; my $categories = XML::Atom::Categories->new; my $category = XML::Atom::Category->new; $category->term('joke'); $categories->add_category($category); $collection->categories($categories); $categories = $collection->categories; isa_ok $categories, 'XML::Atom::Categories'; $category = $categories->category; isa_ok $category, 'XML::Atom::Category'; is $category->term, 'joke'; my $xml = $collection->as_xml; my $ns_uri = $XML::Atom::Util::NS_MAP{ $XML::Atom::DefaultVersion }; like $xml, qr!Foo Bar!; like $xml, qr!image/png!; like $xml, qr!image/jpeg!; like $xml, qr!$!; XML-Atom-Service-v0.16.2/t/04.workspace.t000444000765000024 303011736731515 17337 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 16; use XML::Atom::Collection; use XML::Atom::Workspace; my $workspace = XML::Atom::Workspace->new; isa_ok $workspace, 'XML::Atom::Workspace'; $workspace->title('Foo Bar'); is $workspace->title, 'Foo Bar'; my $collection = XML::Atom::Collection->new; $collection->href('http://example.org/reilly/main'); $workspace->add_collection($collection); $collection = $workspace->collection; isa_ok $collection, 'XML::Atom::Collection'; is $collection->href, 'http://example.org/reilly/main'; my $collection2 = XML::Atom::Collection->new; $collection2->href('http://example.org/reilly/sub'); $workspace->add_collection($collection2); my @collection = $workspace->collection; is scalar(@collection), 2; is $collection[0]->href, 'http://example.org/reilly/main'; is $collection[1]->href, 'http://example.org/reilly/sub'; @collection = $workspace->collections; is scalar(@collection), 2; is $collection[0]->href, 'http://example.org/reilly/main'; is $collection[1]->href, 'http://example.org/reilly/sub'; my $xml = $workspace->as_xml; my $ns_uri = $XML::Atom::Util::NS_MAP{ $XML::Atom::DefaultVersion }; like $xml, qr!Foo Bar!; like $xml, qr!$!; XML-Atom-Service-v0.16.2/t/05.service.t000444000765000024 277711736731515 17023 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 17; use XML::Atom; use XML::Atom::Service; my $service = XML::Atom::Service->new; isa_ok $service, 'XML::Atom::Service'; my $workspace = XML::Atom::Workspace->new; $workspace->title('Foo Bar'); $service->add_workspace($workspace); $workspace = $service->workspace; is $workspace->title, 'Foo Bar'; my $workspace2 = XML::Atom::Workspace->new; $workspace2->title('Baz Quux'); $service->add_workspace($workspace2); my @workspace = $service->workspace; is scalar(@workspace), 2; is $workspace[0]->title, 'Foo Bar'; is $workspace[1]->title, 'Baz Quux'; @workspace = $service->workspaces; is scalar(@workspace), 2; is $workspace[0]->title, 'Foo Bar'; is $workspace[1]->title, 'Baz Quux'; my $xml = $service->as_xml; like $xml, qr!^<\?xml version="1.0" encoding="utf-8"\?>!i; my $ns_uri = $XML::Atom::Util::NS_MAP{ $XML::Atom::DefaultVersion }; like $xml, qr!)?!; like $xml, qr!)?!; like $xml, qr!Foo Bar!; like $xml, qr!Baz Quux!; like $xml, qr!$!; my $sample = "t/samples/sample.atomsvc"; $service = XML::Atom::Service->new($sample); isa_ok $service, 'XML::Atom::Service'; @workspace = $service->workspace; is $workspace[0]->title, 'Main Site'; is $workspace[1]->title, 'Side Bar Blog'; XML-Atom-Service-v0.16.2/t/06.atompub.t000444000765000024 343511736731515 17023 0ustar00inouestaff000000000000use strict; use warnings; #use Data::Dumper; $Data::Dumper::Indent = 1; use Test::More tests => 18; use XML::Atom::Entry; use XML::Atom::Atompub; my $entry = XML::Atom::Entry->new; $entry->alternate_link('http://example.com/foo.html'); $entry->edit_media_link('http://example.com/foo.png'); is $entry->alternate_link, 'http://example.com/foo.html'; is $entry->edit_media_link, 'http://example.com/foo.png'; like $entry->as_xml, qr{}; like $entry->as_xml, qr{}; $entry->edited('2007-01-01T00:00:00Z'); is $entry->edited, '2007-01-01T00:00:00Z'; my $control = XML::Atom::Control->new; isa_ok $control, 'XML::Atom::Control'; $control->draft('yes'); is $control->draft, 'yes'; $entry->control($control); my $content = XML::Atom::Content->new( Version => 1.0 ); $content->src('http://example.com/foo.png'); $content->type('image/png'); is $content->src, 'http://example.com/foo.png'; is $content->type, 'image/png'; $entry->content($content); my $ns_uri = quotemeta $XML::Atom::Service::DefaultNamespace; like $entry->as_xml, qr{2007-01-01T00:00:00Z}; like $entry->as_xml, qr{<(?:app:)?control xmlns="$ns_uri">\s*<(?:app:)?draft>yes\s*}ms; my $sample = "t/samples/sample.atom"; $entry = XML::Atom::Entry->new($sample); isa_ok $entry, 'XML::Atom::Entry'; is $entry->alternate_link, 'http://example.com/foo.html'; is $entry->edit_media_link, 'http://example.com/foo.png'; is $entry->title, 'Title'; is $entry->edited, '2007-01-01T00:00:00Z'; is $entry->control->draft, 'yes'; is $entry->content->src, 'http://example.com/foo.png'; XML-Atom-Service-v0.16.2/t/perlcritic.t000444000765000024 43611736731515 17246 0ustar00inouestaff000000000000#!perl use strict; use Test::More; plan skip_all => '$ENV{TEST_CRITIC} must be set to enable this test' unless $ENV{TEST_CRITIC}; eval { require Test::Perl::Critic }; plan skip_all => 'Test::Perl::Critic required to enable this test' if $@; Test::Perl::Critic::all_critic_ok(); XML-Atom-Service-v0.16.2/t/pod-coverage.t000444000765000024 25411736731515 17457 0ustar00inouestaff000000000000#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); XML-Atom-Service-v0.16.2/t/pod.t000444000765000024 21411736731515 15662 0ustar00inouestaff000000000000#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); XML-Atom-Service-v0.16.2/t/samples000755000765000024 011736731515 16245 5ustar00inouestaff000000000000XML-Atom-Service-v0.16.2/t/samples/sample.atom000444000765000024 67211736731515 20532 0ustar00inouestaff000000000000 Title 2007-01-01T00:00:00Z yes XML-Atom-Service-v0.16.2/t/samples/sample.atomcat000444000765000024 46111736731515 21216 0ustar00inouestaff000000000000 XML-Atom-Service-v0.16.2/t/samples/sample.atomsvc000444000765000024 177011736731515 21266 0ustar00inouestaff000000000000 Main Site My Blog Entries Pictures image/png image/jpeg Side Bar Blog Remaindered Links entry