Schema/Populate/CountryLocale.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 29 / 29 CC 3 SCAR 6.9
CC
3
Cov
100%
populate_countries
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Schema/Populate/Zone.pm ↑ Summary Schema/Result/PriceModifier.pm »
1 package Interchange6::Schema::Populate::CountryLocale;
2  
3 =head1 NAME
4  
5 Interchange6::Schema::Populate::CountryLocale
6  
7 =head1 DESCRIPTION
8  
9 This module provides population capabilities for the Country schema
10  
11 =cut
12  
13 4 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Locale::SubCountry;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 =head1 METHODS
18  
19 =head2 populate_countries
20  
21 =cut
22  
23 sub populate_countries {
24 3 ▶ my $self = shift;
Subroutine populate_countries: called CC=3 SCAR=11.0
Pod documented
25 3 my $has_state;
26 3 my @countries_with_states = qw(US CA); # United States, Canada
27 3 my $world = Locale::SubCountry::World->new;;
28 3 my %all_country_keyed_by_code = $world->code_full_name_hash;
29  
30 3 my $rset = $self->schema->resultset('Country');
31  
32 3 foreach my $country_code ( sort keys %all_country_keyed_by_code ){
33 #need regex to clean up records containing 'See (*)'
34 750 my $country_name = $all_country_keyed_by_code{$country_code};
35 750 ▶ if ( grep( /^$country_code$/, @countries_with_states ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep /^$country_code$/, @countries_with_states) { } 6 744 750
36 6 $has_state = '1';
37 } else {
38 744 $has_state = '0';
39 }
40 750 $rset->create(
41 {
42 'country_iso_code' => $country_code,
43 'name' => $country_name,
44 'show_states' => $has_state
45 }
46 );
47 }
48 }
49  
50 4 1;
« Schema/Populate/Zone.pm ↑ Summary Schema/Result/PriceModifier.pm »