| 1 | package XML::Atom::Ext::Inline; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw(XML::Atom::Base); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use XML::Atom::Link; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use XML::Atom::Feed; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use XML::Atom::Entry; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use XML::Atom::Util qw(childlist); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | XML::Atom::Ext::Inline - In-lining Extensions for Atom | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Version 0.02 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | XML::Atom::Link->mk_object_accessor(inline => 'XML::Atom::Ext::Inline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | *XML::Atom::Link::set = sub {XML::Atom::Base::set(@_)}; # hack to eliminate backwards compatibility hack in XML::Atom::Link | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | This module implements In-lining extesions for Atom. You can see the RFC draft | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | here: L<http://tools.ietf.org/html/draft-mehta-atom-inline-01> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | The following code: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | use XML::Atom; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | use XML::Atom::Ext::Inline; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | my $feed = XML::Atom::Feed->new(Version => '1.0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | my $parent_feed = XML::Atom::Feed->new(Version => '1.0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $parent_feed->title('foo bar'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | my $inline = XML::Atom::Ext::Inline->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $inline->atom($parent_feed); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | my $link = XML::Atom::Link->new(Version => '1.0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $link->rel('up'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $link->inline($inline); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $feed->add_link($link); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | print $feed->as_xml(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | will produce: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | <?xml version="1.0" encoding="utf-8"?> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | <feed xmlns="http://www.w3.org/2005/Atom"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | <link rel="up"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | <ae:inline xmlns:ae="http://purl.org/atom/ext/"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | <feed> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | <title>foo bar</title> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | </feed> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | </ae:inline> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | </link> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | </feed> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =head1 USAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =head2 atom($feed | $entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Returns an I<XML::Atom::Feed> or I<XML::Atom::Entry> object representing the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | inline element contents or C<undef> if there is no contents. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | If given an argument, adds the feed I<$feed> which must be an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | I<XML::Atom::Feed> object or I<$entry> which must be I<XML::Atom::Entry> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | object, into inline element. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub atom { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atom: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $inline = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($_[0]->isa('XML::Atom::Feed')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my ($feed) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $ns_uri = $feed->{ns}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my @elem = childlist($inline->elem, $ns_uri, 'entry'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $inline->elem->removeChild($_) for @elem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $inline->set($ns_uri, 'feed', $feed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ($_[0]->isa('XML::Atom::Feed')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my ($entry) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $ns_uri = $entry->{ns}->{uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my @elem = childlist($inline->elem, $ns_uri, 'feed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $inline->elem->removeChild($_) for @elem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $inline->set($ns_uri, 'entry', $entry); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $r = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | carp "can't embed $r - should be XML::Atom::Feed or XML::Atom::Entry"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # looking for feed or entry or the same stuff again with old NS URI | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $inline->get_object('http://www.w3.org/2005/Atom', 'feed', 'XML::Atom::Feed') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$inline->get_object('http://www.w3.org/2005/Atom', 'feed', 'XML::Atom::Feed') || $inline->get_object('http://www.w3.org/2005/Atom', 'entry', 'XML::Atom::Entry') || $inline->get_object('http://purl.org/atom/ns#', 'feed', 'XML::Atom::Feed') || $inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry')
$inline->get_object("http://www.w3.org/2005/Atom", "feed", "XML::Atom::Feed") or $inline->get_object("http://www.w3.org/2005/Atom", "entry", "XML::Atom::Entry") or $inline->get_object("http://purl.org/atom/ns#", "feed", "XML::Atom::Feed")
$inline->get_object("http://www.w3.org/2005/Atom", "feed", "XML::Atom::Feed") or $inline->get_object("http://www.w3.org/2005/Atom", "entry", "XML::Atom::Entry")
MC/DC0%0/4
$inline->get_object('http://www.w3.org/2005/Atom', 'feed', 'XML::Atom::Feed') || $inline->get_object('http://www.w3.org/2005/Atom', 'entry', 'XML::Atom::Entry') || $inline->get_object('http://purl.org/atom/ns#', 'feed', 'XML::Atom::Feed') || $inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry')
$inline->get_object("http://www.w3.org/2005/Atom", "feed", "XML::Atom::Feed")
$inline->get_object("http://www.w3.org/2005/Atom", "entry", "XML::Atom::Entry")
$inline->get_object("http://purl.org/atom/ns#", "feed", "XML::Atom::Feed")
$inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry')
Truth table0%0/5
A or B or C || D
A= $inline->get_object("http://www.w3.org/2005/Atom", "feed", "XML::Atom::Feed")B= $inline->get_object("http://www.w3.org/2005/Atom", "entry", "XML::Atom::Entry")C= $inline->get_object("http://purl.org/atom/ns#", "feed", "XML::Atom::Feed")D= $inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | || $inline->get_object('http://www.w3.org/2005/Atom', 'entry', 'XML::Atom::Entry') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | || $inline->get_object('http://purl.org/atom/ns#', 'feed', 'XML::Atom::Feed') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | || $inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =head2 element_ns | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | Returns the L<XML::Atom::Namespace> object representing our xmlns:ae="http://purl.org/atom/ext/">. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub element_ns { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return XML::Atom::Namespace->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'ae' => q{http://purl.org/atom/ext/} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub element_name {'inline'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | Dmitri Popov, C<< <operator at cv.dp-net.com> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | Please report more bugs here: L<http://github.com/pin/xml-atom-ext-inline/issues> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | You can find more information and usefull links on project wiki: L<http://wiki.github.com/pin/xml-atom-ext-inline> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Copyright 2009-2010 Dmitri Popov, all rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | 1; # End of XML::Atom::Ext::Inline | |||||||||||||||||||||||||||||||||||||||||||||||||