| 1 | package WWW::KrispyKreme::HotLight; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Mojo::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | has 'where'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | has locations => \&_build_locations; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub _build_locations { | ||||||||||||||||||||||||||||
| 13 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_build_locations: called CC=5 SCAR=22.7
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | my $geo = $self->where or return []; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | my $ua = Mojo::UserAgent->new; | |||||||||||||||||||||||||||
| 17 | 1 | my $base_url = 'http://locations.krispykreme.com/Store-Locator/'; | |||||||||||||||||||||||||||
| 18 | 1 | my $hotlight_url = 'http://locations.krispykreme.com/Hotlight/HotLightStatus.ashx'; | |||||||||||||||||||||||||||
| 19 | 1 | my $header = {'X-Requested-With' => 'XMLHttpRequest'}; | |||||||||||||||||||||||||||
| 20 | 1 | my $form = {lat => $geo->[0], lng => $geo->[1]}; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | my $locations = join ',', | |||||||||||||||||||||||||||
| 23 | $ua->get($base_url => $header => form => $form) | ||||||||||||||||||||||||||||
| 24 | ->res->dom->find('.content-results')->attr('id')->each; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $json = $locations && $ua->post( | ||||||||||||||||||||||||||
|
Condition0%0/3
$locations && $ua->post($hotlight_url, {%$header, 'Referer', $base_url}, 'form', {'locations', $locations})->res->json
MC/DC0%0/2
$locations && $ua->post($hotlight_url, {%$header, 'Referer', $base_url}, 'form', {'locations', $locations})->res->json
$locations
$ua->post($hotlight_url, {%$header, 'Referer', $base_url}, 'form', {'locations', $locations})->res->json
Truth table0%0/3
A && B
A= $locationsB= $ua->post($hotlight_url, {%$header, 'Referer', $base_url}, 'form', {'locations', $locations})->res->json
| |||||||||||||||||||||||||||||
| 27 | $hotlight_url => {%$header, Referer => $base_url} | ||||||||||||||||||||||||||||
| 28 | => form => {locations => $locations} | ||||||||||||||||||||||||||||
| 29 | )->res->json; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | return $json && $json->{status} eq 'success' | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | ? [@{$json->{data}{locations}}] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$json and $json->{"status"} eq "success"
MC/DC0%0/2
$json and $json->{"status"} eq "success"
$json
$json->{"status"} eq "success"
Truth table0%0/3
A and B
A= $jsonB= $json->{"status"} eq "success"
| |||||||||||||||||||||||||||||
| 33 | : []; | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | 1; | |||||||||||||||||||||||||||
| 37 | __END__ | ||||||||||||||||||||||||||||