| 1 | package DBIx::Class::Schema::Diff::Filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Further filters diff data produced by DBIx::Class::Schema::Diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | with 'DBIx::Class::Schema::Diff::Role::Common'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Types::Standard qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 108 | ▶ | has 'mode', is => 'ro', isa => Enum[qw(limit ignore)], default => sub{'limit'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | has 'match', is => 'ro', isa => Maybe[InstanceOf['Hash::Layout']], default => sub{undef}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | has 'events', is => 'ro', coerce => \&_coerce_list_hash, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | isa => Maybe[Map[Enum[qw(added changed deleted)],Bool]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | has 'source_events', is => 'ro', coerce => \&_coerce_list_hash, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | isa => Maybe[Map[Enum[qw(added changed deleted)],Bool]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | has 'empty_match', is => 'ro', lazy => 1, default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 108 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 108 | ▶ | return (scalar(keys %{$self->match->Data}) > 0) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | }, init_arg => undef, isa => Bool; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 127 | ▶ | has 'matched_paths', is => 'ro', init_arg => undef, default => sub {[]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | sub filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 127 | ▶ | my ($self, $diff) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: called CC=11 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 127 | ▶ | return undef unless ($diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 127 | my $newd = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 127 | for my $s_name (keys %$diff) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 719 | my $h = $diff->{$s_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | next if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $self->skip_source($s_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | || $self->_is_skip( source_events => $h->{_event}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 719 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->skip_source($s_name) or $self->_is_skip("source_events", $h->{"_event"})
MC/DC100%2/2
$self->skip_source($s_name) or $self->_is_skip("source_events", $h->{"_event"})
$self->skip_source($s_name)
$self->_is_skip("source_events", $h->{"_event"})
Truth table100%3/3
A or B
A= $self->skip_source($s_name)B= $self->_is_skip("source_events", $h->{"_event"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 520 | $newd->{$s_name} = $self->source_filter( $s_name => $h ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 520 | ▶ | delete $newd->{$s_name} unless (defined $newd->{$s_name}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Strip if the event is 'changed' but the diff data has been stripped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | delete $newd->{$s_name} if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $newd->{$s_name} && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $newd->{$s_name}{_event} && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $newd->{$s_name}{_event} eq 'changed' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 520 | ▶ | scalar(keys %{$newd->{$s_name}}) == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$newd->{$s_name} and $newd->{$s_name}{"_event"} and $newd->{$s_name}{"_event"} eq "changed" and scalar keys %{$$newd{$s_name};} == 1
$newd->{$s_name} and $newd->{$s_name}{"_event"} and $newd->{$s_name}{"_event"} eq "changed"
$newd->{$s_name} and $newd->{$s_name}{"_event"}
MC/DC50%2/4
$newd->{$s_name} and $newd->{$s_name}{"_event"} and $newd->{$s_name}{"_event"} eq "changed" and scalar keys %{$$newd{$s_name};} == 1
$newd->{$s_name}
$newd->{$s_name}{"_event"}
$newd->{$s_name}{"_event"} eq "changed"
scalar keys %{$$newd{$s_name};} == 1
Truth table60%3/5
A and B and C and D
A= $newd->{$s_name}B= $newd->{$s_name}{"_event"}C= $newd->{$s_name}{"_event"} eq "changed"D= scalar keys %{$$newd{$s_name};} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 127 | ▶ | return scalar(keys %$newd) > 0 ? $newd : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub source_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 520 | ▶ | my ($self, $s_name, $diff) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source_filter: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 520 | ▶ | return undef unless ($diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 520 | my $newd = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 520 | for my $type (keys %$diff) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1221 | ▶ | next if ($type ne '_event' && $self->skip_type($s_name => $type)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type ne "_event" and $self->skip_type($s_name, $type)
MC/DC100%2/2
$type ne "_event" and $self->skip_type($s_name, $type)
$type ne "_event"
$self->skip_type($s_name, $type)
Truth table100%3/3
A and B
A= $type ne "_event"B= $self->skip_type($s_name, $type)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1020 | my $val = $diff->{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1020 | ▶ | if($type eq 'columns' || $type eq 'relationships' || $type eq 'constraints') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$type eq "columns" or $type eq "relationships" or $type eq "constraints"
$type eq "columns" or $type eq "relationships"
MC/DC100%3/3
$type eq "columns" or $type eq "relationships" or $type eq "constraints"
$type eq "columns"
$type eq "relationships"
$type eq "constraints"
Truth table100%4/4
A or B or C
A= $type eq "columns"B= $type eq "relationships"C= $type eq "constraints"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 338 | $newd->{$type} = $self->_info_filter( $type, $s_name => $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 338 | ▶ | delete $newd->{$type} unless (defined $newd->{$type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 682 | $newd->{$type} = $val | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 520 | ▶ | return (scalar(keys %$newd) > 0) ? $newd : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | sub _should_skip_info_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 707 | ▶ | my ($self, $type, $s_name, $name, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_should_skip_info_item: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 707 | ▶ | return 1 if ($self->_is_skip( 'events' => $data->{_event} )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 701 | ▶ | return 1 if ($self->skip_type_id($s_name, $type => $name )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 551 | return 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | sub _info_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 338 | ▶ | my ($self, $type, $s_name, $items) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_info_filter: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 338 | ▶ | return undef unless ($items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 338 | my $new_items = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 338 | for my $name (keys %$items) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #next if ($self->_should_skip_info_item($type, $s_name, $name, $items->{$name})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 567 | ▶ | if($items->{$name}{_event} eq 'changed') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 280 | my $check = $self->test_path($s_name, $type, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 280 | my $globmatch = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 280 | ▶ | my $filter_deep = ($check && ref($check) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$check && ref $check eq 'HASH'
MC/DC100%2/2
$check && ref $check eq 'HASH'
$check
ref $check eq 'HASH'
Truth table100%3/3
A && B
A= $checkB= ref $check eq 'HASH'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 280 | ▶ | unless($filter_deep) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 233 | my $diff = $items->{$name}{diff}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 233 | for my $k (keys %$diff) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 233 | ▶ | if($self->match->lookup_path_globmatch($s_name, $type, $name, $k)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 14 | $globmatch = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 14 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 280 | ▶ | $filter_deep = ($check && ref($check) eq 'HASH') || $globmatch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$check && ref $check eq 'HASH' || $globmatch
$check and ref $check eq "HASH"
MC/DC100%3/3
$check && ref $check eq 'HASH' || $globmatch
$check
ref $check eq "HASH"
$globmatch
Truth table80%4/5
A and B || C
A= $checkB= ref $check eq "HASH"C= $globmatch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 280 | ▶ | next if (!$globmatch && $self->_should_skip_info_item($type, $s_name, $name, $items->{$name})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $globmatch and $self->_should_skip_info_item($type, $s_name, $name, $items->{$name})
MC/DC100%2/2
not $globmatch and $self->_should_skip_info_item($type, $s_name, $name, $items->{$name})
not $globmatch
$self->_should_skip_info_item($type, $s_name, $name, $items->{$name})
Truth table100%3/3
not(A) and B
A= not $globmatchB= $self->_should_skip_info_item($type, $s_name, $name, $items->{$name})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 215 | ▶ | if($filter_deep) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | my $new_diff = $self->_deep_value_filter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 61 | ▶ | $items->{$name}{diff}, $s_name, $type, $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 38 | $new_items->{$name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | _event => 'changed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | diff => $new_diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # Allow through as-is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 154 | ▶ | $new_items->{$name} = $items->{$name} unless ($self->_should_skip_info_item($type, $s_name, $name, $items->{$name})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # Allow through as-is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 287 | ▶ | $new_items->{$name} = $items->{$name} unless ($self->_should_skip_info_item($type, $s_name, $name, $items->{$name})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | #if($self->match->lookup_leaf_path($s_name, $type, $name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 338 | ▶ | return scalar(keys %$new_items) > 0 ? $new_items : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | sub _deep_value_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 73 | ▶ | my ($self, $hash, @path) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deep_value_filter: called CC=11 SCAR=24.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 73 | my $new_hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 73 | for my $k (keys %$hash) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 73 | my $val = $hash->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 73 | my $set = $self->test_path(@path,$k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 73 | ▶ | if($set) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 51 | ▶ | if($val && ref($val) eq 'HASH' && ref($set) eq 'HASH' && scalar(keys %$val) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$val and ref $val eq "HASH" and ref $set eq "HASH" and scalar keys %$val > 0
$val and ref $val eq "HASH" and ref $set eq "HASH"
$val and ref $val eq "HASH"
MC/DC50%2/4
$val and ref $val eq "HASH" and ref $set eq "HASH" and scalar keys %$val > 0
$val
ref $val eq "HASH"
ref $set eq "HASH"
scalar keys %$val > 0
Truth table60%3/5
A and B and C and D
A= $valB= ref $val eq "HASH"C= ref $set eq "HASH"D= scalar keys %$val > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 12 | $new_hash->{$k} = $self->_deep_value_filter($val,@path,$k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 12 | ▶ | delete $new_hash->{$k} unless (defined $new_hash->{$k}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 39 | ▶ | next if ($self->mode eq 'ignore'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 38 | $new_hash->{$k} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 22 | ▶ | next if ($self->mode eq 'limit'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $new_hash->{$k} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 73 | ▶ | return scalar(keys %$new_hash) > 0 ? $new_hash : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | sub _is_skip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1248 | ▶ | my ($self, $meth, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_skip: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1248 | my $h = $self->$meth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1248 | ▶ | $self->mode eq 'limit' ? $h && ! $h->{$key} : $h && $h->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$h and not $h->{$key}
$h and $h->{$key}
MC/DC100%2/2
$h and not $h->{$key}
$h
not $h->{$key}
MC/DC100%2/2
$h and $h->{$key}
$h
$h->{$key}
Truth table100%3/3
A and not(B)
A= $hB= not $h->{$key}
Truth table100%3/3
A and B
A= $hB= $h->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | sub skip_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 719 | ▶ | my ($self, $s_name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_source: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 719 | ▶ | my $HL = $self->match or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 719 | ▶ | my $set = $self->test_path($s_name) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->test_path($s_name) || 0
MC/DC100%1/1
$self->test_path($s_name) || 0
$self->test_path($s_name)
Truth table100%2/2
A
A= $self->test_path($s_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 719 | ▶ | if($self->mode eq 'limit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 602 | ▶ | return 0 if ($self->empty_match); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 562 | ▶ | return $set ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 117 | ▶ | return $set && ! ref($set) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set and not ref $set
MC/DC100%2/2
$set and not ref $set
$set
not ref $set
Truth table100%3/3
A and not(B)
A= $setB= not ref $set
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub skip_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 701 | ▶ | my ($self, $s_name, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_type: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 701 | ▶ | my $HL = $self->match or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 701 | my $set = $self->test_path($s_name,$type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 701 | ▶ | if($self->mode eq 'limit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 586 | ▶ | return 0 if ($self->empty_match); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # If this source/type is set, OR if the entire source is included: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 542 | ▶ | return $set || $self->test_leaf_path($s_name) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set or $self->test_leaf_path($s_name)
MC/DC100%2/2
$set or $self->test_leaf_path($s_name)
$set
$self->test_leaf_path($s_name)
Truth table100%3/3
A or B
A= $setB= $self->test_leaf_path($s_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 115 | ▶ | return $set && ! ref($set) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set and not ref $set
MC/DC100%2/2
$set and not ref $set
$set
not ref $set
Truth table100%3/3
A and not(B)
A= $setB= not ref $set
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub skip_type_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 701 | ▶ | my ($self, $s_name, $type, $id) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_type_id: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 701 | ▶ | my $HL = $self->match or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 701 | my $set = $self->test_path($s_name,$type,$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 701 | ▶ | if($self->mode eq 'limit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 561 | ▶ | return 0 if ($self->empty_match); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # If this source/type is set, OR if the entire source or source/type is included: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 485 | ▶ | return $set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$set or $self->test_leaf_path($s_name) or $self->test_leaf_path($s_name, $type)
$set or $self->test_leaf_path($s_name)
MC/DC100%3/3
$set or $self->test_leaf_path($s_name) or $self->test_leaf_path($s_name, $type)
$set
$self->test_leaf_path($s_name)
$self->test_leaf_path($s_name, $type)
Truth table100%4/4
A or B or C
A= $setB= $self->test_leaf_path($s_name)C= $self->test_leaf_path($s_name, $type)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | || $self->test_leaf_path($s_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | || $self->test_leaf_path($s_name,$type) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 140 | ▶ | return $set && ! ref($set) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set and not ref $set
MC/DC100%2/2
$set and not ref $set
$set
not ref $set
Truth table100%3/3
A and not(B)
A= $setB= not ref $set
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sub test_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2474 | ▶ | my ($self, @path) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_path: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2474 | ▶ | return $self->test_leaf_path(@path) || $self->match->lookup_path(@path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->test_leaf_path(@path) || $self->match->lookup_path(@path)
MC/DC100%2/2
$self->test_leaf_path(@path) || $self->match->lookup_path(@path)
$self->test_leaf_path(@path)
$self->match->lookup_path(@path)
Truth table100%3/3
A || B
A= $self->test_leaf_path(@path)B= $self->match->lookup_path(@path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | sub test_leaf_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3380 | ▶ | my ($self, @path) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_leaf_path: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3380 | ▶ | my $ret = $self->match->lookup_leaf_path(@path) || $self->match->lookup_path_globmatch(@path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->match->lookup_leaf_path(@path) || $self->match->lookup_path_globmatch(@path)
MC/DC100%2/2
$self->match->lookup_leaf_path(@path) || $self->match->lookup_path_globmatch(@path)
$self->match->lookup_leaf_path(@path)
$self->match->lookup_path_globmatch(@path)
Truth table100%3/3
A || B
A= $self->match->lookup_leaf_path(@path)B= $self->match->lookup_path_globmatch(@path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3380 | ▶ | push @{$self->matched_paths}, \@path if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ret and not ref $ret
MC/DC50%1/2
$ret and not ref $ret
$ret
not ref $ret
Truth table66%2/3
A and not(B)
A= $retB= not ref $ret
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $ret | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # We don't want to record the path as "matched" for empty HashRef {} leafs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | && ! ref $ret | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 3380 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | DBIx::Class::Schema::Diff::Filter - internal filtering object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | This class is used internally by L<DBIx::Class::Schema::Diff> and is not meant to be called directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | Please refer to the main L<DBIx::Class::Schema::Diff> documentation for more info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | Henry Van Styn <vanstyn@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | This software is copyright (c) 2014 by IntelliTree Solutions llc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||