Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Dec 17, 2023
1 parent f731049 commit d1180b9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/GDPR/IAB/TCFv2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ In case a vendor has declared flexibility for a purpose and there is no legal ba
=head2 publisher_restrictions
Similar to L</check_publisher_restriction> but return an hashref of purpose => restriction type for a given vendor (if any).
Similar to L</check_publisher_restriction> but return an hashref of purpose => restriction type => bool } for a given vendor (if any).
=head2 publisher_tc
Expand Down
8 changes: 4 additions & 4 deletions lib/GDPR/IAB/TCFv2/Publisher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ Return true for a given combination of purpose id, restriction type and vendor_i
my $purpose_id = 1;
my $restriction_type = 0;
my $vendor_id = 284;
$ok = $range->check_restriction($purpose_id, $restriction_type, $vendor_id);
$ok = $publisher->check_restriction($purpose_id, $restriction_type, $vendor_id);
=head2 restrictions
Return a map of purpose id => restriction type for a given vendor id
Return a hashref of purpose => restriction type => bool } for a given vendor id.
Example, by parsing the consent C<COwAdDhOwAdDhN4ABAENAPCgAAQAAv___wAAAFP_AAp_4AI6ACACAA> we can generate this.
my $restrictions = $range->restrictions(32);
# returns { 7 => 1 }
my $restrictions = $publisher->restrictions(32);
# returns { 7 => { 1 => 1 } }
=head2 publisher_tc
Expand Down
11 changes: 6 additions & 5 deletions lib/GDPR/IAB/TCFv2/PublisherRestrictions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ sub restrictions {
if ( $self->{restrictions}->{$purpose_id}->{$restriction_type}
->contains($vendor_id) )
{
$restrictions{$purpose_id} = $restriction_type;
$restrictions{$purpose_id} ||= {};
$restrictions{$purpose_id}->{$restriction_type} = 1;
}
}
}
Expand Down Expand Up @@ -176,16 +177,16 @@ Return true for a given combination of purpose id, restriction type and vendor
my $purpose_id = 1;
my $restriction_type = 0;
my $vendor_id = 284;
my $ok = $range->check_restriction($purpose_id, $restriction_type, $vendor_id);
my $ok = $object->check_restriction($purpose_id, $restriction_type, $vendor_id);
=head2 restrictions
Return a map of purpose id => restriction type for a given vendor id
Return a hashref of purpose => restriction type => bool } for a given vendor id.
Example, by parsing the consent C<COwAdDhOwAdDhN4ABAENAPCgAAQAAv___wAAAFP_AAp_4AI6ACACAA> we can generate this.
my $restrictions = $range->restrictions(32);
# returns { 7 => 1 }
my $restrictions = $object->restrictions(32);
# returns { 7 => { 1 => 1 } }
=head2 TO_JSON
Expand Down
22 changes: 12 additions & 10 deletions t/01-parse.t
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ subtest "bitfield" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

my $publisher_tc = $consent->publisher_tc;

Expand Down Expand Up @@ -450,7 +450,7 @@ subtest "range" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

my $publisher_tc = $consent->publisher_tc;

Expand Down Expand Up @@ -515,7 +515,7 @@ subtest "range" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

done_testing;
};
Expand Down Expand Up @@ -549,11 +549,11 @@ subtest "check publisher restriction" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

$restrictions = $consent->publisher_restrictions(32);
is_deeply $restrictions, { 7 => 1 },
"should return the restriction purpose id => restriction type map";
is_deeply $restrictions, { 7 => { 1 => 1 } },
"should return the restriction purpose id => restriction map type map";

done_testing;
};
Expand Down Expand Up @@ -597,11 +597,13 @@ subtest "check publisher restriction" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

$restrictions = $consent->publisher_restrictions(32);
is_deeply $restrictions, { 1 => 0, 2 => 0, 7 => 0, 10 => 0 },
"should return the restriction purpose id => restriction type map";
is_deeply $restrictions,
{ 1 => { 0 => 1 }, 2 => { 0 => 1, 1 => 1 }, 7 => { 0 => 1, 1 => 1 },
10 => { 0 => 1, 1 => 1 } },
"should return the restriction purpose id => restriction map type map";


done_testing;
Expand All @@ -625,7 +627,7 @@ subtest "check publisher restriction" => sub {

my $restrictions = $consent->publisher_restrictions(284);
is_deeply $restrictions, {},
"should return the restriction purpose id => restriction type map";
"should return the restriction purpose id => restriction map type map";

done_testing;
};
Expand Down

0 comments on commit d1180b9

Please sign in to comment.