| 1 | package Net::Async::HTTP::DAV::XML; | ||||||||||||||||||||||||||||
| 2 | 4 | $Net::Async::HTTP::DAV::XML::VERSION = '0.001'; | |||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use parent qw(XML::SAX::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Date::Parse qw(str2time); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | my %handler = ( | ||||||||||||||||||||||||||||
| 11 | 'D:response' => { | ||||||||||||||||||||||||||||
| 12 | 3 | ▶ | start => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 3 | my ($self, $tag, $data) = @_; | |||||||||||||||||||||||||||
| 14 | 3 | $self->{item} = {}; | |||||||||||||||||||||||||||
| 15 | }, | ||||||||||||||||||||||||||||
| 16 | 3 | ▶ | end => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=31.6
| |||||||||||||||||||||||||||||
| 17 | 3 | my ($self, $tag, $data) = @_; | |||||||||||||||||||||||||||
| 18 | 3 | my $item = $self->{item}; | |||||||||||||||||||||||||||
| 19 | 3 | ▶ | $item->{modified} ||= str2time(delete $item->{lastmodifieddate}) if exists $item->{lastmodifieddate}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$item->{"modified"} ||= str2time(delete $item->{"lastmodifieddate"})
MC/DC0%0/2
$item->{"modified"} ||= str2time(delete $item->{"lastmodifieddate"})
$item->{"modified"}
str2time(delete $item->{"lastmodifieddate"})
Truth table33%1/3
A ||= B
A= $item->{"modified"}B= str2time(delete $item->{"lastmodifieddate"})
| |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | $item->{modified} ||= str2time(delete $item->{getlastmodifieddate}) if exists $item->{getlastmodifieddate}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$item->{"modified"} ||= str2time(delete $item->{"getlastmodifieddate"})
MC/DC0%0/2
$item->{"modified"} ||= str2time(delete $item->{"getlastmodifieddate"})
$item->{"modified"}
str2time(delete $item->{"getlastmodifieddate"})
Truth table0%0/3
A ||= B
A= $item->{"modified"}B= str2time(delete $item->{"getlastmodifieddate"})
| |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | $item->{modified} ||= str2time(delete $item->{getlastmodified}) if exists $item->{getlastmodified}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$item->{"modified"} ||= str2time(delete $item->{"getlastmodified"})
MC/DC0%0/2
$item->{"modified"} ||= str2time(delete $item->{"getlastmodified"})
$item->{"modified"}
str2time(delete $item->{"getlastmodified"})
Truth table33%1/3
A ||= B
A= $item->{"modified"}B= str2time(delete $item->{"getlastmodified"})
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | $item->{size} = delete $item->{getcontentlength} if exists $item->{getcontentlength}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | $item->{type} = ((delete $item->{resourcetype}) // '' eq 'collection') ? 'directory' : 'file'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
delete $item->{"resourcetype"} //
MC/DC0%0/1
delete $item->{"resourcetype"} //
delete $item->{"resourcetype"}
Truth table50%1/2
A
A= delete $item->{"resourcetype"}
| |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | $item->{path} = delete $item->{href} if exists $item->{href}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 3 | ▶ | $item->{displayname} = '.' if $item->{path} eq ($self->{path} // ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"path"} // ""
MC/DC0%0/1
$self->{"path"} // ""
$self->{"path"}
Truth table50%1/2
A
A= $self->{"path"}
| |||||||||||||||||||||||||||||
| 26 | 3 | ▶ | ($item->{displayname}) = $item->{path} =~ m{([^/]+)$} unless defined $item->{displayname}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 3 | $self->maybe_invoke('on_item', $item); | |||||||||||||||||||||||||||
| 28 | 3 | delete $self->{item}; | |||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||
| 31 | 'D:multistatus' => { | ||||||||||||||||||||||||||||
| 32 | 1 | ▶ | end => sub { my ($self, $tag, $data) = @_; $self->maybe_invoke('on_complete'); } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||
| 34 | 'D:collection' => { | ||||||||||||||||||||||||||||
| 35 | 2 | ▶ | start => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 36 | 2 | my ($self, $tag, $data) = @_; | |||||||||||||||||||||||||||
| 37 | 2 | (my $name = $tag->{Name}) =~ s/^D://; | |||||||||||||||||||||||||||
| 38 | 2 | ▶ | $self->{item}->{resourcetype} = $name if $self->{stack}[1]{Name} eq 'D:resourcetype'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | 4 | ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | foreach my $type (qw( | |||||||||||||||||||||||||||
| 44 | creationdate | ||||||||||||||||||||||||||||
| 45 | getlastmodified | ||||||||||||||||||||||||||||
| 46 | getetag | ||||||||||||||||||||||||||||
| 47 | displayname | ||||||||||||||||||||||||||||
| 48 | getcontentlanguage | ||||||||||||||||||||||||||||
| 49 | getcontentlength | ||||||||||||||||||||||||||||
| 50 | getcontenttype | ||||||||||||||||||||||||||||
| 51 | immutable | ||||||||||||||||||||||||||||
| 52 | lastmodifieddate | ||||||||||||||||||||||||||||
| 53 | resourceid | ||||||||||||||||||||||||||||
| 54 | resourcetype | ||||||||||||||||||||||||||||
| 55 | src | ||||||||||||||||||||||||||||
| 56 | dst | ||||||||||||||||||||||||||||
| 57 | read-only | ||||||||||||||||||||||||||||
| 58 | href | ||||||||||||||||||||||||||||
| 59 | )) { | ||||||||||||||||||||||||||||
| 60 | $handler{"lp1:$type"} = $handler{"D:$type"} = { | ||||||||||||||||||||||||||||
| 61 | 34 | ▶ | start => sub { my $self = shift; $self->{item}->{$type} = ''; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 34 | ▶ | end => sub { my $self = shift; $self->maybe_invoke('on_item_property', $self->{item}, $type, $self->{item}->{$type}); }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 29 | ▶ | content => sub { my $self = shift; $self->{item}->{$type} .= $_[0]; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 60 | }; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 70 | 1 | my %args = @_; | |||||||||||||||||||||||||||
| 71 | 1 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 72 | 1 | $self->{$_} = delete $args{$_} for grep { /^on_/ } keys %args; | |||||||||||||||||||||||||||
| 73 | 1 | $self->{dav} = delete $args{dav}; | |||||||||||||||||||||||||||
| 74 | 1 | $self->{href} = delete $args{href}; | |||||||||||||||||||||||||||
| 75 | 1 | $self->{stack} = []; | |||||||||||||||||||||||||||
| 76 | 1 | return $self; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub dav { shift->{dav} } | ||||||||||||||||||||||||||
|
Subroutine
dav: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | 0 | $self->dav->debug(@_); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 start_element | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 49 | ▶ | sub start_element { | ||||||||||||||||||||||||||
|
Subroutine
start_element: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 49 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 49 | my $element = shift; | |||||||||||||||||||||||||||
| 93 | 49 | unshift @{$self->{stack}}, $element; | |||||||||||||||||||||||||||
| 94 | 49 | ▶ | if(my $handler = $handler{$element->{Name}}->{start}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 39 | $handler->($self, $element); | |||||||||||||||||||||||||||
| 96 | 39 | return $self->SUPER::start_element($element); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # Find an appropriate class for this element | ||||||||||||||||||||||||||||
| 100 | 10 | my $v = $element->{Name}; | |||||||||||||||||||||||||||
| 101 | # warn "Had unhandled $v\n"; | ||||||||||||||||||||||||||||
| 102 | 10 | return $self->SUPER::start_element($element); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head2 end_element | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =cut | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 49 | ▶ | sub end_element { | ||||||||||||||||||||||||||
|
Subroutine
end_element: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 49 | my $self = shift; | |||||||||||||||||||||||||||
| 111 | 49 | my $element = shift; | |||||||||||||||||||||||||||
| 112 | 49 | shift @{$self->{stack}}; | |||||||||||||||||||||||||||
| 113 | 49 | ▶ | if(my $handler = $handler{$element->{Name}}->{end}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 38 | $handler->($self); | |||||||||||||||||||||||||||
| 115 | 38 | return $self->SUPER::end_element($element); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 11 | return $self->SUPER::end_element($element); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head2 characters | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 88 | ▶ | sub characters { | ||||||||||||||||||||||||||
|
Subroutine
characters: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 88 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 88 | my $element = $self->{stack}->[0]; | |||||||||||||||||||||||||||
| 127 | 88 | ▶ | if(my $handler = $handler{$element->{Name}}->{content}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 29 | $handler->($self, $_[0]->{Data}); | |||||||||||||||||||||||||||
| 129 | 29 | return $self->SUPER::characters(@_); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 59 | return $self->SUPER::characters(@_); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 34 | ▶ | sub on_item_property { | ||||||||||||||||||||||||||
|
Subroutine
on_item_property: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | 34 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | 34 | my ($item, $k, $v) = @_; | |||||||||||||||||||||||||||
| 137 | 34 | ▶ | $v //= ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$v //= ""
MC/DC0%0/1
$v //= ""
$v
Truth table50%1/2
A
A= $v
| |||||||||||||||||||||||||||||
| 138 | # warn " $k => $v\n"; | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 38 | ▶ | sub maybe_invoke { | ||||||||||||||||||||||||||
|
Subroutine
maybe_invoke: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 38 | my $self = shift; | |||||||||||||||||||||||||||
| 143 | 38 | my $type = shift; | |||||||||||||||||||||||||||
| 144 | 38 | ▶ | my $code = $self->{$type} || $self->can($type); | ||||||||||||||||||||||||||
|
Condition100%3/3
$self->{$type} || $self->can($type)
MC/DC100%2/2
$self->{$type} || $self->can($type)
$self->{$type}
$self->can($type)
Truth table100%3/3
A || B
A= $self->{$type}B= $self->can($type)
| |||||||||||||||||||||||||||||
| 145 | 38 | ▶ | return unless $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 37 | return $code->(@_); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 4 | 1; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | __END__ | ||||||||||||||||||||||||||||