| 1 | package Google::RestApi::SheetsApi4::Request; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '2.2.5'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Google::RestApi::Setup; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Hash::Merge (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use List::MoreUtils qw( first_index ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Storable (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use parent "Google::RestApi::Request"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 252 | ▶ | sub merge_request { | ||||||||||||||||||||||||||
|
Subroutine
merge_request: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 252 | my $self = shift; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 252 | state $check = signature(positional => [HashRef]); | |||||||||||||||||||||||||||
| 17 | 252 | my ($request) = $check->(@_); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 252 | ▶ | my $requests = $self->{requests} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 192 | ▶ | my ($index) = first_index { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 192 | $self->_can_merge($request, $_); | |||||||||||||||||||||||||||
| 22 | 252 | } @$requests; | |||||||||||||||||||||||||||
| 23 | 252 | ▶ | return if $index < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 133 | my $other_request = $requests->[$index]; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 133 | my $key = (keys %$request)[0]; | |||||||||||||||||||||||||||
| 28 | 133 | my $fields = $request->{$key}->{fields}; | |||||||||||||||||||||||||||
| 29 | 133 | my $other_fields = $other_request->{$key}->{fields}; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 133 | my %fields; | |||||||||||||||||||||||||||
| 32 | 133 | ▶ | %fields = map { $_ => 1 } split(',', $fields), split(',', $other_fields) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$fields and $other_fields
MC/DC50%1/2
$fields and $other_fields
$fields
$other_fields
Truth table66%2/3
A and B
A= $fieldsB= $other_fields
| |||||||||||||||||||||||||||||
| 33 | if $fields && $other_fields; | ||||||||||||||||||||||||||||
| 34 | 133 | $other_request = Hash::Merge::merge($request, $other_request); | |||||||||||||||||||||||||||
| 35 | 133 | ▶ | $other_request->{$key}->{fields} = join(',', sort keys %fields) if %fields; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 133 | $requests->[$index] = $other_request; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 133 | return $other_request; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 192 | ▶ | sub _can_merge { | ||||||||||||||||||||||||||
|
Subroutine
_can_merge: called CC=12 SCAR=38.0
| |||||||||||||||||||||||||||||
| 43 | 192 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 192 | my ($request, $other_request) = @_; | |||||||||||||||||||||||||||
| 46 | 192 | my $key = (keys %$request)[0]; | |||||||||||||||||||||||||||
| 47 | 192 | my $other_key = (keys %$other_request)[0]; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 192 | ▶ | return if $key ne $other_key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 133 | ▶ | return if $key =~ /^(deleteProtected|deleteNamed|deleteEmbeded)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 133 | ▶ | if ($key =~ /^updateProtected/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $id = $request->{$key}->{protectedRangeId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $other_id = $other_request->{$key}->{protectedRangeId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | return $id == $other_id; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 133 | ▶ | if ($key =~ /^updateNamedRange/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $id = $request->{$key}->{namedRange}->{namedRangeId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $other_id = $other_request->{$key}->{namedRange}->{namedRangeId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | return $id == $other_id; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 133 | ▶ | if ($key =~ /^updateEmbededObject/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $id = $request->{$key}->{objectId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $other_id = $other_request->{$key}->{objectId} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | return $id == $other_id; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 133 | return 1; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||