| 1 | package Net::Google::DocumentsList::Role::EnsureListed; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 14 | ▶ | use Any::Moose '::Role'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | our $SLEEP = 1; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 14 | our $RETRY = 10; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub ensure_listed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_listed: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | my ($self, $item, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | my @items = $self->item( | |||||||||||||||||||||||||||||||||||||||||
| 11 | { | ||||||||||||||||||||||||||||||||||||||||||
| 12 | resource_id => $item->resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | title => $item->title, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 'title-exact' => 'true', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | category => $item->kind, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | grep {$_ && $_->id eq $item->id} @items and last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ && $_->id eq $item->id
MC/DC0%0/2
$_ && $_->id eq $item->id
$_
$_->id eq $item->id
Truth table0%0/3
A && B
A= $_B= $_->id eq $item->id
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $found_item = $self->_find_entry($item); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ($found_item->title ne $item->title) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | undef $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($args->{etag_should_change}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $found_item->etag eq $item->etag and next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | # retry, but keep $found_item (it would the the true item) | ||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $found_item or confess "updated entry couldn't be retrieved"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $item->container->sync if $item->container; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub ensure_not_listed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_not_listed: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($self, $folder) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | undef $found; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my @list = $folder->item( | |||||||||||||||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | resource_id => $self->resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | title => $self->title, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'title-exact' => 'true', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | category => $self->kind, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | ($found) = grep {$_ && $_->id eq $self->id} @list or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ && $_->id eq $self->id
MC/DC0%0/2
$_ && $_->id eq $self->id
$_
$_->id eq $self->id
Truth table0%0/3
A && B
A= $_B= $_->id eq $self->id
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $found and confess "item couldn't be moved"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub ensure_trashed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_trashed: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $item) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my @items = $self->item( | |||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | resource_id => $item->resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | title => $item->title, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 'title-exact' => 'true', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | category => [$item->kind, 'trashed'], | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my ($found) = grep {$_ && $_->id eq $item->id && $_->deleted} @items and last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$_ && $_->id eq $item->id && $_->deleted
$_ and $_->id eq $item->id
MC/DC0%0/3
$_ && $_->id eq $item->id && $_->deleted
$_
$_->id eq $item->id
$_->deleted
Truth table0%0/4
A and B && C
A= $_B= $_->id eq $item->idC= $_->deleted
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $found_item = $self->_find_entry($item); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $found_item->title eq $item->title && $found_item->deleted and last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$found_item->title eq $item->title and $found_item->deleted
MC/DC0%0/2
$found_item->title eq $item->title and $found_item->deleted
$found_item->title eq $item->title
$found_item->deleted
Truth table0%0/3
A and B
A= $found_item->title eq $item->titleB= $found_item->deleted
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | undef $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $found_item or confess "couldn't trash the item"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub ensure_deleted { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_deleted: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my ($self, $item) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $found_item; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my @items = $self->service->item( | |||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | resource_id => $item->resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | title => $item->title, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 'title-exact' => 'true', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | category => $item->kind, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | push @items, $self->service->item( | |||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | resource_id => $item->resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | title => $item->title, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 'title-exact' => 'true', | ||||||||||||||||||||||||||||||||||||||||||
| 101 | category => [$item->kind, 'trashed'], | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | grep {$_ && $_->id eq $item->id} @items or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ && $_->id eq $item->id
MC/DC0%0/2
$_ && $_->id eq $item->id
$_
$_->id eq $item->id
Truth table0%0/3
A && B
A= $_B= $_->id eq $item->id
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | for (1 .. $RETRY) { | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | undef $found; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $found = eval {$self->_find_entry($item)} or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | sleep $SLEEP; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $found and confess "couldn't delete the item"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub _find_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_entry: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my ($self, $item) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | my $found = $self->service->get_entry($item->selfurl) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return (ref $item)->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | $item->container ? (container => $item->container) | ||||||||||||||||||||||||||||||||||||||||||
| 121 | : ( service => $self->service), | ||||||||||||||||||||||||||||||||||||||||||
| 122 | atom => $found, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||