| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package WWW::Shopify::Liquid::Tag::Capture; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 38 | ▶ | use base 'WWW::Shopify::Liquid::Tag::Enclosing'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub min_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub max_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 38 | ▶ | use Scalar::Util qw(blessed looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | my ($self, $hash, $action, $pipeline) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | my @vars = map { $self->is_processed($_) ? $_ : $_->$action($pipeline, $hash) } @{$self->{arguments}->[0]->{core}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | return $self if $action eq "optimize" && int(grep { !$self->is_processed($_) } @vars) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action eq "optimize" and int grep({not $self->is_processed($_);} @vars) > 0
MC/DC0%0/2
$action eq "optimize" and int grep({not $self->is_processed($_);} @vars) > 0
$action eq "optimize"
int grep({not $self->is_processed($_);} @vars) > 0
Truth table0%0/3
A and B
A= $action eq "optimize"B= int grep({not $self->is_processed($_);} @vars) > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $inner_hash = $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | for (0..$#vars-1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | return $self if ref($inner_hash) && ref($inner_hash) eq "HASH" && !exists $inner_hash->{$vars[$_]} && $action eq 'optimize'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $inner_hash and ref $inner_hash eq "HASH" and not exists $$inner_hash{$vars[$_]} and $action eq "optimize"
ref $inner_hash and ref $inner_hash eq "HASH" and not exists $$inner_hash{$vars[$_]}
ref $inner_hash and ref $inner_hash eq "HASH"
MC/DC0%0/4
ref $inner_hash and ref $inner_hash eq "HASH" and not exists $$inner_hash{$vars[$_]} and $action eq "optimize"
ref $inner_hash
ref $inner_hash eq "HASH"
not exists $$inner_hash{$vars[$_]}
$action eq "optimize"
Truth table0%0/5
A and B and not(C) and D
A= ref $inner_hashB= ref $inner_hash eq "HASH"C= not exists $$inner_hash{$vars[$_]}D= $action eq "optimize"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if (looks_like_number($vars[$_]) && ref($inner_hash) && ref($inner_hash) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
&looks_like_number($vars[$_]) and ref $inner_hash and ref $inner_hash eq "ARRAY"
&looks_like_number($vars[$_]) and ref $inner_hash
MC/DC0%0/3
&looks_like_number($vars[$_]) and ref $inner_hash and ref $inner_hash eq "ARRAY"
&looks_like_number($vars[$_])
ref $inner_hash
ref $inner_hash eq "ARRAY"
Truth table0%0/4
A and B and C
A= &looks_like_number($vars[$_])B= ref $inner_hashC= ref $inner_hash eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | $inner_hash->[$vars[$_]] = {} if !defined $inner_hash->[$vars[$_]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $inner_hash = $inner_hash->[$vars[$_]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $inner_hash->{$vars[$_]} = {} if !exists $inner_hash->{$vars[$_]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $inner_hash = $inner_hash->{$vars[$_]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $result = $self->{contents}->$action($pipeline, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return $self unless $self->is_processed($result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # For now, only do renders. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($action eq "optimize") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $pipeline->flag_conditional_uncertainty(\@vars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $inner_hash->{$vars[-1]} = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return undef if $pipeline->remove_assignment && !defined $pipeline->conditional_state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pipeline->remove_assignment and not defined $pipeline->conditional_state
MC/DC0%0/2
$pipeline->remove_assignment and not defined $pipeline->conditional_state
$pipeline->remove_assignment
not defined $pipeline->conditional_state
Truth table0%0/3
A and not(B)
A= $pipeline->remove_assignmentB= not defined $pipeline->conditional_state
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (looks_like_number($vars[-1]) && ref($inner_hash) && ref($inner_hash) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
&looks_like_number($vars[-1]) and ref $inner_hash and ref $inner_hash eq "ARRAY"
&looks_like_number($vars[-1]) and ref $inner_hash
MC/DC0%0/3
&looks_like_number($vars[-1]) and ref $inner_hash and ref $inner_hash eq "ARRAY"
&looks_like_number($vars[-1])
ref $inner_hash
ref $inner_hash eq "ARRAY"
Truth table0%0/4
A and B and C
A= &looks_like_number($vars[-1])B= ref $inner_hashC= ref $inner_hash eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $inner_hash->[$vars[-1]] = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $inner_hash->{$vars[-1]} = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires a variable to be the capture target.") unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Token::Variable'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||