blib/lib/WWW/KrispyKreme/HotLight.pm

filter: Statementstmt 85.7% 18 / 21 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 57.8% 22 / 38 SCAR 18.6
CC
5
Cov
61%
_build_locations
9.7
BEGIN
1.0
BEGIN
1.0
CRAP 6.5
↑ Summary Build »
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
BranchTrueFalseTotal
my $geo = $self->where or return [] 0 1 1
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
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
$json && $json->{'status'} eq 'success' ? : 0 0 0
Condition0%0/3
$json and $json->{"status"} eq "success"
!ll&&!rl&&r
000
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"
ABresult
0X0
100
111
33 : [];
34 }
35  
36 1 1;
37 __END__
↑ Summary Build »