blib/lib/XML/Loy.pm

filter: Statementstmt 95.6% 329 / 344 Branchbran 84.0% 163 / 194 Conditioncond 69.1% 56 / 81 MC/DCmcdc 48.8% 22 / 45 Subroutinesub 96.7% 30 / 31 Podpod 100% 10 / 10 totaltotal 86.5% 610 / 705 CC 140 SCAR 23.5
CC
140
Cov
89%
_element
18.3
children
15.1
extension
14.3
CRAP 10.5
« blib/lib/XML/Loy/Atom.pm ↑ Summary blib/lib/XML/Loy/Date/RFC822.pm »
1 package XML::Loy;
2 21 ▶use Mojo::ByteStream 'b';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use Mojo::Loader qw/load_class/;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use Carp qw/croak carp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Scalar::Util qw/blessed weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use Mojo::Base 'Mojo::DOM';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 our $VERSION = '0.51';
9  
10 sub DESTROY;
11  
12 # TODO:
13 # - Support Mojolicious version > 7.77
14 # - "ns|*" namespace selector
15 #
16 # - Add ->clone
17 # (Maybe via JSON serialisation of ->tree or using Storable or Dumper)
18 #
19 # Maybe necessary: *AUTOLOAD = \&XML::Loy::AUTOLOAD;
20 #
21 # - sub try_further { };
22 # # usage:
23 # sub author {
24 # return $autor or $self->try_further;
25 # };
26 #
27 # - ALERT!
28 # Do not allow for namespace islands
29 # Search $obj->find('* *[xmlns]') and change prefixing
30 # After ->SUPER::new;
31 # Or:
32 # Do allow for namespace islands and check for the
33 # namespace to add instead of the package name before
34 # prefixing.
35 #
36 # - set() should really try to overwrite.
37 #
38 # - add() with -before => '' and -after => ''
39 # - maybe possible to save to element
40 # - Maybe with small changes a change to the object
41 # (encoding, xml etc.) can be done
42 #
43 # - closest() (jQuery)
44  
45 21 our @CARP_NOT;
46  
47 # Import routine, run when calling the class properly
48 sub import {
49 54 ▶ my $class = shift;
Subroutine import: called CC=7 SCAR=19.5
50  
51 54 ▶ return unless my $flag = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless my $flag = shift() 27 27 54
52  
53 27 ▶ return unless $flag =~ /^-?(?i:base|with)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $flag =~ /^-?(?i:base|with)$/u 1 26 27
54  
55 # Allow for manipulating the symbol table
56 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
57 21 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 # The caller is the calling (inheriting) class
60 26 my $caller = caller;
61 26 push @{"${caller}::ISA"}, __PACKAGE__;
62  
63 26 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 25 1 26
64  
65 # Get class variables
66 25 my %param = @_;
67  
68 # Set class variables
69 25 foreach (qw/namespace prefix mime/) {
70 75 ▶ if (exists $param{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $param{$_}) 63 12 75
71 63 ${ "${caller}::" . uc $_ } = delete $param{$_};
72 };
73 };
74  
75 # Set class hook
76 25 ▶ if (exists $param{on_init}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $param{"on_init"}) 2 23 25
77 2 *{"${caller}::ON_INIT"} = delete $param{on_init};
78 };
79 };
80  
81 # Make inheriting classes strict and modern
82 26 strict->import;
83 26 warnings->import;
84 26 utf8->import;
85 26 feature->import(':5.10');
86 };
87  
88  
89 # Return class variables
90 {
91 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
92 635 ▶ sub _namespace { ${"${_[0]}::NAMESPACE"} || '' };
Subroutine _namespace: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
${"$_[0]::NAMESPACE";} or "" 509 126 635
93 57 ▶ sub _prefix { ${"${_[0]}::PREFIX"} || '' };
Subroutine _prefix: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
${"$_[0]::PREFIX";} or "" 0 57 57
94 sub mime {
95 6 ▶ ${ (blessed $_[0] || $_[0]) . '::MIME'} || 'application/xml'
Subroutine mime: called CC=3 SCAR=11.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${(builtin::blessed($_[0]) || $_[0]) . '::MIME';} or "application/xml" 3 3 6
Condition66%2/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
510
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table66%2/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
96 };
97 sub _on_init {
98 1684 ▶ my $class = shift;
Subroutine _on_init: called CC=3 SCAR=11.0
99 1684 my $self = $class;
100  
101 # Run object method
102 1684 ▶ if (blessed $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($class)) { } 1672 12 1684
103 1672 $class = blessed $class;
104 }
105  
106 # Run class method
107 else {
108 12 $self = shift;
109 };
110  
111 # Run init hook
112 1684 ▶ if ($class->can('ON_INIT')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can("ON_INIT")) 525 1159 1684
113 525 *{"${class}::ON_INIT"}->($self) ;
114 };
115 };
116 21 };
117  
118  
119 # Construct new XML::Loy object
120 sub new {
121 1670 ▶ my $class = shift;
Subroutine new: called CC=11 SCAR=24.0
Pod documented
122  
123 1670 my $self;
124  
125 # Create from parent class
126 # Empty constructor
127 1670 ▶ unless ($_[0]) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_[0]) { } 584 1086 1670
if (do { ref $_[0] }) { } 1 583 584
elsif (index($_[0], '<') != -1 or index($_[0], ' ') != -1) { } 17 566 583
128 1086 $self = $class->SUPER::new->xml(1);
129 }
130  
131 # XML::Loy object
132 elsif (ref $_[0]) {
133 1 $self = $class->SUPER::new(@_)->xml(1);
134 }
135  
136 # XML string
137 ▶ elsif (index($_[0],'<') >= 0 || index($_[0],' ') >= 0) {
Condition66%2/3
index($_[0], "<") != -1 or index($_[0], " ") != -1
l!l&&r!l&&!r
170566
MC/DC50%1/2
index($_[0], "<") != -1 or index($_[0], " ") != -1
index($_[0], "<") != -1 index($_[0], " ") != -1
Truth table66%2/3
A or B
A= index($_[0], "<") != -1B= index($_[0], " ") != -1
ABresult
1X1
011
000
138 17 $self = $class->SUPER::new->xml(1)->parse(@_);
139 }
140  
141 # Create a new node
142 else {
143 566 my $name = shift;
144 566 ▶ my $att = ref( $_[0] ) eq 'HASH' ? shift : +{};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 17 549 566
145 566 my ($text, $comment) = @_;
146  
147 566 $att->{'xmlns:loy'} = 'http://sojolicious.example/ns/xml-loy';
148  
149 # Transform special attributes
150 566 ▶ _special_attributes($att) if $att;
Branch: 1 branch
BranchTrueFalseTotal
if $att 566 0 566
151  
152 # Create root
153 566 my $tree = [
154 'root',
155 [ pi => 'xml version="1.0" encoding="UTF-8" standalone="yes"']
156 ];
157  
158 # Add comment if given
159 566 ▶ push(@$tree, [ comment => $comment ]) if $comment;
Branch: 1 branch
BranchTrueFalseTotal
if $comment 2 564 566
160  
161 # Create Tag element
162 566 my $element = [ tag => $name, $att, $tree ];
163  
164 # Add element
165 566 push(@$tree, $element);
166  
167 # Add text if given
168 566 ▶ push(@$element, [ text => $text ]) if defined $text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 13 553 566
169  
170 # Create root element by parent class
171 566 $self = $class->SUPER::new->xml(1);
172  
173 # Add newly created tree
174 566 $self->tree($tree);
175  
176 # The class is derived
177 566 ▶ if ($class ne __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 536 30 566
178  
179 # Set namespace if given
180 536 ▶ if (my $ns = $class->_namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ns = $class->_namespace) 27 509 536
181 27 $att->{xmlns} = $ns;
182 };
183 };
184 };
185  
186 # Start init hook
187 1670 $self->_on_init;
188  
189 # Return root node
190 1670 return $self;
191 };
192  
193  
194 # Append a new child node to the XML Node
195 sub add {
196 152 ▶ my $self = shift;
Subroutine add: called CC=12 SCAR=25.2
Pod documented
197  
198 # Store tag
199 152 my $tag = $_[0];
200  
201 # If node is root, use first element
202 152 ▶ if (!$self->parent &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi") 90 62 152
Condition77%7/9
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi"
!ll&&!rl&&r
61190
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY"
!ll&&!rl&&r
61091
not $self->parent and ref $self->tree->[1]
!ll&&!rl&&r
61091
MC/DC50%2/4
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi"
not $self->parent ref $self->tree->[1] ref $self->tree->[1] eq "ARRAY" $self->tree->[1][0] eq "pi"
Truth table60%3/5
not(A) and B and C and D
A= not $self->parentB= ref $self->tree->[1]C= ref $self->tree->[1] eq "ARRAY"D= $self->tree->[1][0] eq "pi"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
203 ref($self->tree->[1]) &&
204 ref($self->tree->[1]) eq 'ARRAY' &&
205 $self->tree->[1]->[0] eq 'pi') {
206 90 $self = $self->at('*');
207 };
208  
209 # Add element
210 152 ▶ my $element = $self->_add_clean(@_) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element = $self->_add_clean(@_) or return 3 146 149
211  
212 146 my $tree = $element->tree;
213  
214 # Prepend with no prefix
215 146 ▶ if (index($tag, '-') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($tag, "-") == 0) 4 142 146
216 4 $tree->[1] = substr($tag, 1);
217 4 return $element;
218 };
219  
220 # Element is no tag
221 142 ▶ return $element unless $tree->[0] eq 'tag';
Branch: 1 branch
BranchTrueFalseTotal
unless $tree->[0] eq "tag" 0 142 142
222  
223 # Prepend prefix if necessary
224 142 my $caller = caller;
225 142 my $class = ref $self;
226  
227 # Caller and class are not the same
228 142 ▶ if ($caller ne $class && $caller->can('_prefix')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller ne $class and $caller->can("_prefix")) 24 118 142
Condition100%3/3
$caller ne $class and $caller->can("_prefix")
!ll&&!rl&&r
665224
MC/DC100%2/2
$caller ne $class and $caller->can("_prefix")
$caller ne $class $caller->can("_prefix")
Truth table100%3/3
A and B
A= $caller ne $classB= $caller->can("_prefix")
ABresult
0X0
100
111
229 24 ▶ if ((my $prefix = $caller->_prefix) && $caller->_namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prefix = $caller->_prefix and $caller->_namespace) 24 0 24
Condition33%1/3
my $prefix = $caller->_prefix and $caller->_namespace
!ll&&!rl&&r
0024
MC/DC0%0/2
my $prefix = $caller->_prefix and $caller->_namespace
my $prefix = $caller->_prefix $caller->_namespace
Truth table33%1/3
A and B
A= my $prefix = $caller->_prefixB= $caller->_namespace
ABresult
0X0
100
111
230 24 $element->tree->[1] = "${prefix}:$tag";
231 };
232 };
233  
234 # Return element
235 142 return $element;
236 };
237  
238  
239 # Append a child only once to the XML node.
240 sub set {
241 52 ▶ my $self = shift;
Subroutine set: called CC=12 SCAR=25.1
Pod documented
242  
243 52 my $tag;
244  
245 # If node is root, use first element
246 52 ▶ if (!$self->parent && $self->tree->[1]->[0] eq 'pi') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->parent and $self->tree->[1][0] eq "pi") 31 21 52
Condition66%2/3
not $self->parent and $self->tree->[1][0] eq "pi"
!ll&&!rl&&r
21031
MC/DC50%1/2
not $self->parent and $self->tree->[1][0] eq "pi"
not $self->parent $self->tree->[1][0] eq "pi"
Truth table66%2/3
not(A) and B
A= not $self->parentB= $self->tree->[1][0] eq "pi"
ABresult
0X0
100
111
247 31 $self = $self->at('*');
248 };
249  
250 # Get tag from document object
251 52 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 4 48 52
252 4 $tag = $_[0]->at('*')->tag;
253 }
254  
255 # Get tag
256 else {
257  
258 # Store tag
259 48 $tag = shift;
260  
261 # No prefix
262 48 ▶ if (index($tag, '-') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($tag, '-') == 0) { } 0 48 48
263 0 $tag = substr($tag, 1);
264 }
265  
266 # Maybe prefix
267 else {
268 # Prepend prefix if necessary
269 48 my $caller = caller;
270 48 my $class = ref $self;
271  
272 # Caller and class are not the same
273 48 ▶ if ($caller ne $class && $caller->can('_prefix')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller ne $class and $caller->can("_prefix")) 21 27 48
Condition100%3/3
$caller ne $class and $caller->can("_prefix")
!ll&&!rl&&r
151221
MC/DC100%2/2
$caller ne $class and $caller->can("_prefix")
$caller ne $class $caller->can("_prefix")
Truth table100%3/3
A and B
A= $caller ne $classB= $caller->can("_prefix")
ABresult
0X0
100
111
274 21 ▶ if ((my $prefix = $caller->_prefix) && $caller->_namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prefix = $caller->_prefix and $caller->_namespace) 21 0 21
Condition33%1/3
my $prefix = $caller->_prefix and $caller->_namespace
!ll&&!rl&&r
0021
MC/DC0%0/2
my $prefix = $caller->_prefix and $caller->_namespace
my $prefix = $caller->_prefix $caller->_namespace
Truth table33%1/3
A and B
A= my $prefix = $caller->_prefixB= $caller->_namespace
ABresult
0X0
100
111
275 21 $tag = "${prefix}:$tag";
276 };
277 };
278 };
279 };
280  
281 52 my $att = $self->tree->[2];
282  
283 # Introduce attribute 'once'
284 52 ▶ $att->{'loy:once'} //= '';
Condition100%2/2
$att->{"loy:once"} //= ""
l!l
2824
MC/DC100%1/1
$att->{"loy:once"} //= ""
$att->{"loy:once"}
Truth table100%2/2
A
A= $att->{"loy:once"}
Aresult
11
00
285  
286 # Check if set to once
287 52 ▶ if (index($att->{'loy:once'}, "($tag)") >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($att->{'loy:once'}, "($tag)") != -1) { } 13 39 52
288  
289 # Todo: Maybe escaping - check in extensions
290 13 $self->children("$tag")->map('remove');
291 }
292  
293 # Set if not already set
294 else {
295 39 $att->{'loy:once'} .= "($tag)";
296 };
297  
298 # Add a ref, not the tag
299 52 ▶ unshift(@_, $tag) unless blessed $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 48 4 52
300  
301 # Add element (Maybe prefixed)
302 52 return $self->_add_clean(@_);
303 };
304  
305  
306 # Children of the node
307 sub children {
308 282 ▶ my ($self, $type) = @_;
Subroutine children: called CC=15 SCAR=27.1
Pod documented
309  
310 # This method is a modified version of
311 # the children method of Mojo::DOM
312 # It works as written in the documentation,
313 # but is also aware of namespace prefixes.
314  
315 # If node is root, use first element
316 282 ▶ if (!$self->parent &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi") 21 261 282
Condition77%7/9
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi"
!ll&&!rl&&r
260121
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY"
!ll&&!rl&&r
260022
not $self->parent and ref $self->tree->[1]
!ll&&!rl&&r
260022
MC/DC50%2/4
not $self->parent and ref $self->tree->[1] and ref $self->tree->[1] eq "ARRAY" and $self->tree->[1][0] eq "pi"
not $self->parent ref $self->tree->[1] ref $self->tree->[1] eq "ARRAY" $self->tree->[1][0] eq "pi"
Truth table60%3/5
not(A) and B and C and D
A= not $self->parentB= ref $self->tree->[1]C= ref $self->tree->[1] eq "ARRAY"D= $self->tree->[1][0] eq "pi"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
317 ref($self->tree->[1]) &&
318 ref($self->tree->[1]) eq 'ARRAY' &&
319 $self->tree->[1]->[0] eq 'pi') {
320 21 $self = $self->at('*');
321 };
322  
323 282 my @children;
324 282 my $xml = $self->xml;
325 282 my $tree = $self->tree;
326 282 ▶ my $type_l = $type ? length $type : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 72 210 282
327 282 ▶ for my $e (@$tree[($tree->[0] eq 'root' ? 1 : 4) .. $#$tree]) {
Branch: 1 branch
BranchTrueFalseTotal
$tree->[0] eq 'root' ? : 1 281 282
328  
329 # Make sure child is the right type
330 1083 ▶ next unless $e->[0] eq 'tag';
Branch: 1 branch
BranchTrueFalseTotal
unless $e->[0] eq "tag" 142 941 1083
331  
332 # Type is given
333 941 ▶ if (defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 291 650 941
334  
335 # Type is already prefixed or element is not prefixed
336 291 ▶ if (index($type, ':') > 0 || index($e->[1], ':') < 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (index($type, ':') > 0 or index($e->[1], ':') == -1) { } 252 39 291
elsif (index($e->[1], ':') > 0) { } 39 0 39
Condition100%3/3
index($type, ":") > 0 or index($e->[1], ":") == -1
l!l&&r!l&&!r
1823439
MC/DC100%2/2
index($type, ":") > 0 or index($e->[1], ":") == -1
index($type, ":") > 0 index($e->[1], ":") == -1
Truth table100%3/3
A or B
A= index($type, ":") > 0B= index($e->[1], ":") == -1
ABresult
1X1
011
000
337 252 ▶ next if $e->[1] ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $e->[1] ne $type 187 65 252
338 }
339  
340 # Check, if type is valid, and ignore prefixes, cause tag is prefixed
341 elsif (index($e->[1], ':') > 0) {
342 39 ▶ next if substr($e->[1], (index($e->[1], ':') + 1)) ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if substr($e->[1], index($e->[1], ":") + 1) ne $type 21 18 39
343 };
344 };
345  
346 733 push(@children, $self->new->tree($e)->xml($xml));
347 }
348  
349 # Create new Mojo::Collection
350 282 return Mojo::Collection->new( @children );
351 };
352  
353  
354 # Append a new child node to the XML Node
355 sub _add_clean {
356 204 ▶ my $self = shift;
Subroutine _add_clean: called CC=14 SCAR=26.5
357  
358 # Node is a node object
359 204 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 10 194 204
360  
361 # Serialize node
362 10 my $node = $self->SUPER::new->xml(1)->tree( shift->tree );
363  
364 # Get root attributes
365 10 my $root_attr = $node->_root_element->[2];
366  
367 # Push namespaces to new root
368 10 foreach ( grep( index($_, 'xmlns:') == 0, keys %$root_attr ) ) {
369  
370 # Strip xmlns prefix
371 10 $_ = substr($_, 6);
372  
373 # Add namespace
374 10 $self->namespace( $_ => delete $root_attr->{ "xmlns:$_" } );
375 };
376  
377 # Delete namespace information, if already set
378 10 ▶ if (exists $root_attr->{xmlns}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $root_attr->{"xmlns"}) 5 5 10
379  
380 # Namespace information can be deleted
381 5 ▶ if (my $ns = $self->namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ns = $self->namespace) 5 0 5
382 5 ▶ delete $root_attr->{xmlns} if $root_attr->{xmlns} eq $ns;
Branch: 1 branch
BranchTrueFalseTotal
if $root_attr->{"xmlns"} eq $ns 4 1 5
383 };
384 };
385  
386 # Get root of parent node
387 10 my $base_root_attr = $self->_root_element->[2];
388  
389 # Copy extensions
390 10 ▶ if (exists $root_attr->{'loy:ext'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $root_attr->{"loy:ext"}) 0 10 10
391 0 my $ext = $base_root_attr->{'loy:ext'};
392  
393 $base_root_attr->{'loy:ext'} =
394 0 join('; ', $ext, split(/;\s/, delete $root_attr->{'loy:ext'}));
395 };
396  
397  
398 # Delete pi from node
399 10 my $sec = $node->tree->[1];
400 10 ▶ if (ref $sec eq 'ARRAY' && $sec->[0] eq 'pi') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sec eq "ARRAY" and $sec->[0] eq "pi") 9 1 10
Condition66%2/3
ref $sec eq "ARRAY" and $sec->[0] eq "pi"
!ll&&!rl&&r
019
MC/DC50%1/2
ref $sec eq "ARRAY" and $sec->[0] eq "pi"
ref $sec eq "ARRAY" $sec->[0] eq "pi"
Truth table66%2/3
A and B
A= ref $sec eq "ARRAY"B= $sec->[0] eq "pi"
ABresult
0X0
100
111
401 9 splice( @{ $node->tree }, 1,1 );
402 };
403  
404 # Append new node
405 10 $self->append_content($node);
406  
407 # Return first child
408 10 return $self->children->[-1];
409 }
410  
411 # Node is a string
412 else {
413 194 my $name = shift;
414  
415 # Pretty sloppy check for valid names
416 194 ▶ return unless $name =~ m!^-?[^\s<>]+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^-?[^\s<>]+$/u 2 192 194
417  
418 192 ▶ my $att = shift if ref( $_[0] ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "HASH" 85 107 192
419 192 my ($text, $comment) = @_;
420  
421 # Node content with text
422 192 my $string = "<$name";
423  
424 192 ▶ if (defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text) { } 113 79 192
425 113 $string .= '>' . b($text)->trim->xml_escape . "</$name>";
426 }
427  
428 # Empty element
429 else {
430 79 $string .= ' />';
431 };
432  
433 # Append new node
434 192 $self->append_content( $string );
435  
436 # Get first child
437 192 my $node = $self->children->[-1];
438  
439 # Attributes were given
440 192 ▶ if ($att) {
Branch: 1 branch
BranchTrueFalseTotal
if ($att) 85 107 192
441  
442 # Transform special attributes
443 85 _special_attributes($att);
444  
445 # Add attributes to node
446 85 $node->attr($att);
447 };
448  
449 # Add comment
450 189 ▶ $node->comment($comment) if $comment;
Branch: 1 branch
BranchTrueFalseTotal
if $comment 6 183 189
451  
452 189 return $node;
453 };
454 };
455  
456  
457 # Transform special attributes
458 sub _special_attributes {
459 651 ▶ my $att = shift;
Subroutine _special_attributes: called CC=2 SCAR=6.9
460  
461 651 foreach ( grep { index($_, '-') == 0 } keys %$att ) {
462  
463 # Set special attribute
464 15 $att->{'loy:' . substr($_, 1) } = lc delete $att->{$_};
465 };
466 };
467  
468  
469 # Prepend a comment to the XML node
470 sub comment {
471 22 ▶ my $self = shift;
Subroutine comment: called CC=6 SCAR=18.0
Pod documented
472  
473 22 my $parent;
474  
475 # If node is root, use first element
476 22 ▶ return $self unless $parent = $self->parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent = $self->parent 0 22 22
477  
478 # Find previous sibling
479 22 my $previous;
480  
481 # Find previous node
482 22 for my $e (@{$parent->tree}) {
483 146 ▶ last if $e eq $self->tree;
Branch: 1 branch
BranchTrueFalseTotal
if $e eq $self->tree 22 124 146
484 124 $previous = $e;
485 };
486  
487 # Trim and encode comment text
488 22 my $comment_text = b( shift )->trim->xml_escape;
489  
490 # Add to previous comment
491 22 ▶ if ($previous && $previous->[0] eq 'comment') {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous and $previous->[0] eq 'comment') { } 7 15 22
Condition66%2/3
$previous and $previous->[0] eq "comment"
!ll&&!rl&&r
0157
MC/DC50%1/2
$previous and $previous->[0] eq "comment"
$previous $previous->[0] eq "comment"
Truth table66%2/3
A and B
A= $previousB= $previous->[0] eq "comment"
ABresult
0X0
100
111
492 7 $previous->[1] .= '; ' . $comment_text;
493 }
494  
495 # Create new comment node
496 else {
497 15 $self->prepend("<!--$comment_text-->");
498 };
499  
500 # Return node
501 22 return $self;
502 };
503  
504  
505 # Add extension to document
506 sub extension {
507 130 ▶ my $self = shift;
Subroutine extension: called CC=11 SCAR=26.6
Pod documented
508  
509 # Get root element
510 130 my $root = $self->_root_element;
511  
512 # No root to associate extension to
513 130 ▶ unless ($root) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($root) 0 130 130
514 0 carp 'There is no document to associate the extension with';
515 0 return;
516 };
517  
518 # Get ext string
519 130 ▶ my @ext = split(/;\s/, $root->[2]->{'loy:ext'} || '');
Condition100%2/2
$root->[2]{'loy:ext'} || ''
l!l
11713
MC/DC100%1/1
$root->[2]{'loy:ext'} || ''
$root->[2]{'loy:ext'}
Truth table100%2/2
A
A= $root->[2]{'loy:ext'}
Aresult
11
00
520  
521 130 ▶ return @ext unless $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 119 11 130
522  
523 # New Loader
524 # my $loader = Mojo::Loader->new;
525  
526 # Try all given extension names
527 11 ▶ while (my $ext = shift( @_ )) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ext = shift @_) 12 11 23
528  
529 12 ▶ next if grep { $ext eq $_ } @ext;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$ext eq $_;} @ext 0 12 12
530  
531 # Default 'XML::Loy::' prefix
532 12 ▶ if (index($ext, '-') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($ext, "-") == 0) 6 6 12
533 6 $ext =~ s/^-/XML::Loy::/;
534 };
535  
536 # Unable to load extension
537 12 ▶ if (my $e = load_class $ext) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = load_class($ext)) 0 12 12
538 0 ▶ carp "Exception: $e" if ref $e;
Branch: 1 branch
BranchTrueFalseTotal
if ref $e 0 0 0
539 0 carp qq{Unable to load extension "$ext"};
540 0 next;
541 };
542  
543 # Add extension to extensions list
544 12 push(@ext, $ext);
545  
546 # Start init hook
547 12 $ext->_on_init($self);
548  
549 12 ▶ if ((my $n_ns = $ext->_namespace) &&
Branch: 1 branch
BranchTrueFalseTotal
if (my $n_ns = $ext->_namespace and my $n_pref = $ext->_prefix) 12 0 12
Condition33%1/3
my $n_ns = $ext->_namespace and my $n_pref = $ext->_prefix
!ll&&!rl&&r
0012
MC/DC0%0/2
my $n_ns = $ext->_namespace and my $n_pref = $ext->_prefix
my $n_ns = $ext->_namespace my $n_pref = $ext->_prefix
Truth table33%1/3
A and B
A= my $n_ns = $ext->_namespaceB= my $n_pref = $ext->_prefix
ABresult
0X0
100
111
550 (my $n_pref = $ext->_prefix)) {
551 12 $root->[2]->{"xmlns:$n_pref"} = $n_ns;
552 };
553 };
554  
555 # Save extension list as attribute
556 11 $root->[2]->{'loy:ext'} = join('; ', @ext);
557  
558 11 return $self;
559 };
560  
561  
562 # Get or add namespace to root
563 sub namespace {
564 589 ▶ my $self = shift;
Subroutine namespace: called CC=5 SCAR=16.1
Pod documented
565  
566 # Get namespace
567 589 ▶ unless ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_[0]) 50 539 589
568 50 ▶ return $self->SUPER::namespace || undef;
Condition100%2/2
$self->SUPER::namespace || undef
l!l
482
MC/DC100%1/1
$self->SUPER::namespace || undef
$self->SUPER::namespace
Truth table100%2/2
A
A= $self->SUPER::namespace
Aresult
11
00
569 };
570  
571 539 my $ns = pop;
572 539 my $prefix = shift;
573  
574 # Get root element
575 539 my $root = $self->_root_element;
576  
577 # No warning, but not able to set
578 539 ▶ return unless $root;
Branch: 1 branch
BranchTrueFalseTotal
unless $root 0 539 539
579  
580 # Save namespace as attribute
581 539 ▶ $root->[2]->{'xmlns' . ($prefix ? ":$prefix" : '')} = $ns;
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 537 2 539
582 539 return $prefix;
583 };
584  
585  
586 # As another object
587 sub as {
588 2 ▶ my $self = shift;
Subroutine as: called CC=6 SCAR=22.6
Pod documented
589  
590 # Base object
591 2 my $base = shift;
592  
593 # Default 'XML::Loy::' prefix
594 2 ▶ if (index($base, '-') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($base, "-") == 0) 0 2 2
595 0 for ($base) {
596  
597 # Was Loy prefix
598 0 s/^-Loy$/XML::Loy/;
599 0 s/^-/XML::Loy::/;
600 };
601 };
602  
603 # Unable to load extension
604 2 ▶ if (my $e = load_class $base) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = load_class($base)) 0 2 2
605 0 ▶ carp "Exception: $e" if ref $e;
Branch: 1 branch
BranchTrueFalseTotal
if ref $e 0 0 0
606 0 carp qq{Unable to load base class "$e"};
607 0 return;
608 };
609  
610 # Create new base document
611 2 my $xml = $base->new( $self->to_string );
612  
613 # Start init hook
614 2 $xml->_on_init;
615  
616 # Set base namespace
617 2 ▶ if ($base->_namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base->_namespace) 2 0 2
618 2 $xml->namespace( $base->_namespace );
619 };
620  
621 # Delete extension information
622 $xml->find('*[loy\:ext]')->each(
623 sub {
624 0 ▶ delete $_->{attrs}->{'loy:ext'}
Subroutine __ANON__: not called CC=1 SCAR=6.9
625 }
626 2 );
627  
628 # Add extensions
629 2 $xml->extension( @_ );
630  
631 # Return XML document
632 2 return $xml;
633 };
634  
635  
636 # Render as pretty xml
637 sub to_pretty_xml {
638 76 ▶ my $self = shift;
Subroutine to_pretty_xml: called CC=2 SCAR=6.9
Pod documented
639 76 ▶ return _render_pretty( shift // 0, $self->tree);
Condition100%2/2
shift() // 0
l!l
670
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
640 };
641  
642  
643 # Render subtrees with pretty printing
644 sub _render_pretty {
645 348 ▶ my $i = shift; # Indentation
Subroutine _render_pretty: called CC=11 SCAR=24.6
646 348 my $tree = shift;
647  
648 348 my $e = $tree->[0];
649  
650 # No element
651 348 ▶ croak('No element') and return unless $e;
Branch: 1 branch
BranchTrueFalseTotal
unless $e 0 348 348
Condition20%1/5
$e || croak('No element') && (return)
l!l
34800
croak("No element") and return
!ll
00
MC/DC0%0/2
$e || croak('No element') && (return)
$e croak("No element")
Truth table33%1/3
A || B
A= $eB= croak("No element")
ABresult
1X1
011
000
652  
653 # Element is tag
654 348 ▶ if ($e eq 'tag') {
Branch: 5 branches
BranchTrueFalseTotal
if ($e eq 'tag') { } 172 176 348
elsif ($e eq 'text') { } 5 171 176
elsif ($e eq 'comment') { } 31 140 171
elsif ($e eq 'pi') { } 69 71 140
elsif ($e eq 'root') { } 71 0 71
655 my $subtree = [
656 172 @{ $tree }[ 0 .. 2 ],
657 [
658 172 @{ $tree }[ 4 .. $#$tree ]
659 ]
660 ];
661  
662 172 return _element($i, $subtree);
663 }
664  
665 # Element is text
666 elsif ($e eq 'text') {
667  
668 5 my $escaped = $tree->[1];
669  
670 5 for ($escaped) {
671 5 ▶ next unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 5 5
672  
673 # Escape and trim whitespaces from both ends
674 5 $_ = b($_)->xml_escape->trim;
675 };
676  
677 5 return $escaped;
678 }
679  
680 # Element is comment
681 elsif ($e eq 'comment') {
682  
683 # Padding for every line
684 31 my $p = ' ' x $i;
685 31 my $comment = join "\n$p ", split(/;\s+/, $tree->[1]);
686  
687 31 return "\n" . (' ' x $i) . "<!-- $comment -->\n";
688  
689 }
690  
691 # Element is processing instruction
692 elsif ($e eq 'pi') {
693 69 return (' ' x $i) . '<?' . $tree->[1] . "?>\n";
694 }
695  
696 # Element is root
697 elsif ($e eq 'root') {
698  
699 71 my $content;
700  
701 # Pretty print the content
702 71 $content .= _render_pretty( $i, $tree->[ $_ ] ) for 1 .. $#$tree;
703  
704 71 return $content;
705 };
706 };
707  
708  
709 # Render element with pretty printing
710 sub _element {
711 172 ▶ my $i = shift;
Subroutine _element: called CC=18 SCAR=29.0
712 172 my ($type, $qname, $attr, $child) = @{ shift() };
713  
714 # Is the qname valid?
715 172 ▶ croak "$qname is no valid QName"
Branch: 1 branch
BranchTrueFalseTotal
unless $qname =~ /^(?:[a-zA-Z_]+:)?[^\s]+$/u 0 172 172
716 unless $qname =~ /^(?:[a-zA-Z_]+:)?[^\s]+$/;
717  
718 # Start start tag
719 172 my $content = (' ' x $i) . "<$qname";
720  
721 # Add attributes
722 172 $content .= _attr((' ' x $i). (' ' x ( length($qname) + 2)), $attr);
723  
724 # Has the element a child?
725 172 ▶ if ($child->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->[0]) { } 98 74 172
726  
727 # Close start tag
728 98 $content .= '>';
729  
730 # There is only a textual child - no indentation
731 98 ▶ if (!$child->[1] && ($child->[0] && $child->[0]->[0] eq 'text')) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $child->[1] and ($child->[0] and $child->[0][0] eq 'text')) { } 56 42 98
elsif (exists $attr->{'loy:type'}) { } 3 39 42
Condition83%5/6
not $child->[1] and ($child->[0] and $child->[0][0] eq "text")
!ll&&!rl&&r
36656
$child->[0] and $child->[0][0] eq "text"
!ll&&!rl&&r
0656
MC/DC66%2/3
not $child->[1] and ($child->[0] and $child->[0][0] eq "text")
not $child->[1] $child->[0] $child->[0][0] eq "text"
Truth table75%3/4
not(A) and B and C
A= not $child->[1]B= $child->[0]C= $child->[0][0] eq "text"
ABCresult
0XX0
10X0
1100
1111
732  
733 # Special content treatment
734 56 ▶ if (exists $attr->{'loy:type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{'loy:type'}) { } 5 51 56
735  
736 # With base64 indentation
737 5 ▶ if ($attr->{'loy:type'} =~ /^armour(?::(\d+))?$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr->{'loy:type'} =~ /^armour(?::(\d+))?$/iu) { } 3 2 5
738 3 ▶ my $n = $1 || 60;
Condition50%1/2
$1 || 60
l!l
30
MC/DC0%0/1
$1 || 60
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
739  
740 3 my $string = $child->[0]->[1];
741  
742 # Delete whitespace
743 3 $string =~ tr{\t-\x0d }{}d;
744  
745 # Introduce newlines after n characters
746 3 $content .= "\n" . (' ' x ($i + 1));
747 3 $content .= join "\n" . ( ' ' x ($i + 1) ), (unpack "(A$n)*", $string );
748 3 $content .= "\n" . (' ' x $i);
749 }
750  
751 # No special treatment
752 else {
753  
754 # Escape
755 2 $content .= b($child->[0]->[1])->trim->xml_escape;
756 };
757 }
758  
759 # No special content treatment indentation
760 else {
761  
762 # Escape
763 51 $content .= b($child->[0]->[1])->trim->xml_escape;
764 };
765 }
766  
767 # Treat children special
768 elsif (exists $attr->{'loy:type'}) {
769  
770 # Raw
771 3 ▶ if ($attr->{'loy:type'} eq 'raw') {
Branch: 2 branches
BranchTrueFalseTotal
if ($attr->{'loy:type'} eq 'raw') { } 1 2 3
elsif ($attr->{'loy:type'} eq 'escape') { } 2 0 2
772 1 foreach (@$child) {
773  
774 # Create new dom object
775 2 my $dom = __PACKAGE__->new;
776 2 $dom->xml(1);
777  
778 # Print without prettifying
779 2 $content .= $dom->tree($_)->to_string;
780 };
781 }
782  
783 # Todo:
784 elsif ($attr->{'loy:type'} eq 'escape') {
785 2 $content .= "\n";
786  
787 2 foreach (@$child) {
788  
789 # Create new dom object
790 5 my $dom = __PACKAGE__->new;
791 5 $dom->xml(1);
792  
793 # Pretty print
794 5 my $string = $dom->tree($_)->to_pretty_xml($i + 1);
795  
796 # Encode
797 5 $content .= b($string)->xml_escape;
798 };
799  
800 # Correct Indent
801 2 $content .= ' ' x $i;
802 };
803 }
804  
805 # There are a couple of children
806 else {
807  
808 39 my $offset = 0;
809  
810 # First element is unformatted textual
811 39 ▶ if (!exists $attr->{'loy:type'} &&
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $attr->{"loy:type"} and $child->[0] and $child->[0][0] eq "text") 4 35 39
Condition50%3/6
not exists $attr->{"loy:type"} and $child->[0] and $child->[0][0] eq "text"
!ll&&!rl&&r
0354
not exists $attr->{"loy:type"} and $child->[0]
!ll&&!rl&&r
0039
MC/DC33%1/3
not exists $attr->{"loy:type"} and $child->[0] and $child->[0][0] eq "text"
not exists $attr->{"loy:type"} $child->[0] $child->[0][0] eq "text"
Truth table50%2/4
not(A) and B and C
A= not exists $attr->{"loy:type"}B= $child->[0]C= $child->[0][0] eq "text"
ABCresult
0XX0
10X0
1100
1111
812 $child->[0] &&
813 $child->[0]->[0] eq 'text') {
814  
815 # Append directly to the last tag
816 4 $content .= b($child->[0]->[1])->trim->xml_escape;
817 4 $offset = 1;
818 };
819  
820 # Start on a new line
821 39 $content .= "\n";
822  
823 # Loop through all child elements
824 39 foreach (@{$child}[ $offset .. $#$child ]) {
825  
826 # Render next element
827 121 $content .= _render_pretty( $i + 1, $_ );
828 };
829  
830 # Correct Indent
831 39 $content .= (' ' x $i);
832 };
833  
834 # End Tag
835 98 $content .= "</$qname>\n";
836 }
837  
838 # No child - close start element as empty tag
839 else {
840 74 $content .= " />\n";
841 };
842  
843 # Return content
844 172 return $content;
845 };
846  
847  
848 # Render attributes with pretty printing
849 sub _attr {
850 172 ▶ my $indent_space = shift;
Subroutine _attr: called CC=5 SCAR=16.1
851 172 my %attr = %{$_[0]};
852  
853 # Delete special and namespace attributes
854 my @special = grep {
855 172 ▶ $_ eq 'xmlns:loy' || index($_, 'loy:') == 0
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "xmlns:loy" or index($_, "loy:") == 0 121 68 189
856 } keys %attr;
857  
858 # Delete special attributes
859 172 delete $attr{$_} foreach @special;
860  
861 # Prepare attribute values
862 172 $_ = b($_)->xml_escape->quote foreach values %attr;
863  
864 # Return indented attribute string
865 172 ▶ if (keys %attr) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %attr) 67 105 172
866 return ' ' .
867 67 join "\n$indent_space", map { "$_=" . $attr{$_} } sort keys %attr;
868 };
869  
870 # Return nothing
871 105 return '';
872 };
873  
874  
875 # Get root element (not as an object)
876 sub _root_element {
877 807 ▶ my $self = shift;
Subroutine _root_element: called CC=7 SCAR=19.6
878  
879 # Todo: Optimize! Often called!
880  
881 # Find root (Based on Mojo::DOM::root)
882 807 ▶ my $root = $self->tree or return;
Branch: 1 branch
BranchTrueFalseTotal
my $root = $self->tree or return 0 807 807
883 807 my $tag;
884  
885 # Root is root node
886 807 ▶ if ($root->[0] eq 'root') {
Branch: 1 branch
BranchTrueFalseTotal
if ($root->[0] eq 'root') { } 697 110 807
887 697 my $i = 1;
888  
889 # Search for the first tag
890 697 ▶ $i++ while $root->[$i] && $root->[$i]->[0] ne 'tag';
Branch: 1 branch
BranchTrueFalseTotal
$root->[$i] and $root->[$i][0] ne "tag" and do { ++$i } 704 697 1401
Condition66%2/3
$root->[$i] and $root->[$i][0] ne "tag"
!ll&&!rl&&r
0697704
MC/DC50%1/2
$root->[$i] and $root->[$i][0] ne "tag"
$root->[$i] $root->[$i][0] ne "tag"
Truth table66%2/3
A and B
A= $root->[$i]B= $root->[$i][0] ne "tag"
ABresult
0X0
100
111
891  
892 # Tag found
893 697 $tag = $root->[$i];
894 }
895  
896 # Root is a tag
897 else {
898  
899 # Tag found
900 110 ▶ while ($root->[0] eq 'tag') {
Branch: 1 branch
BranchTrueFalseTotal
if ($root->[0] eq "tag") 213 110 323
901 213 $tag = $root;
902  
903 213 ▶ last unless my $parent = $root->[3];
Branch: 1 branch
BranchTrueFalseTotal
unless my $parent = $root->[3] 0 213 213
904  
905 213 $root = $parent;
906 };
907 };
908  
909 # Return root element
910 807 return $tag;
911 };
912  
913  
914 # Autoload for extensions
915 sub AUTOLOAD {
916 118 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=6 SCAR=17.9
917 118 my @param = @_;
918  
919 # Split parameter
920 118 my ($package, $method) = our $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
921  
922 # Choose root element
923 118 my $root = $self->_root_element;
924  
925 # Get extension array
926 118 my @ext = $self->extension;
927  
928 {
929 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
930  
931 118 foreach (@ext) {
932  
933 # Method does not exist in extension
934 126 ▶ next unless $_->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $_->can($method) 10 116 126
935  
936 # Release method
937 116 return *{ "${_}::$method" }->($self, @param);
938 };
939 };
940  
941 2 my $errstr = qq{Can't locate "${method}" in "$package"};
942 2 ▶ if (@ext) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ext) 1 1 2
943 1 ▶ $errstr .= ' with extension' . (@ext > 1 ? 's' : '');
Branch: 1 branch
BranchTrueFalseTotal
@ext > 1 ? : 0 1 1
944 1 $errstr .= ' "' . join('", "', @ext) . '"';
945 };
946  
947 2 ▶ carp $errstr and return;
Branch: 1 branch
BranchTrueFalseTotal
carp($errstr) and return 2 0 2
948 };
949  
950  
951 21 1;
952  
953  
954 __END__
« blib/lib/XML/Loy/Atom.pm ↑ Summary blib/lib/XML/Loy/Date/RFC822.pm »