File Coverage

blib/lib/WebService/Geocodio/Fields.pm
Criterion Covered Total %
statement 111 135 82.2
branch 0 26 0.0
condition n/a
subroutine 37 40 92.5
pod 0 3 0.0
total 148 204 72.5


line stmt bran cond sub pod time code
1 7     7   38 use strict;
  7         11  
  7         155  
2 7     7   27 use warnings;
  7         11  
  7         324  
3              
4             {
5             package WebService::Geocodio::Fields::CongressionalDistrict;
6             $WebService::Geocodio::Fields::CongressionalDistrict::VERSION = '0.05';
7 7     7   471 use Moo;
  7         8861  
  7         39  
8 7     7   3312 use strictures 2;;
  7         1226  
  7         240  
9              
10             has [qw(name district_number congress_number proportion congress_years current_legislators)] => (
11             is => 'ro',
12             );
13              
14             }
15              
16             ################## State Legislative Districts
17              
18             {
19             package WebService::Geocodio::Fields::StateLegislativeDistrict::House;
20             $WebService::Geocodio::Fields::StateLegislativeDistrict::House::VERSION = '0.05';
21 7     7   1454 use Moo;
  7         13  
  7         22  
22 7     7   1767 use strictures 2;;
  7         48  
  7         190  
23              
24             has [qw(name district_number)] => (
25             is => 'ro',
26             );
27             }
28              
29             {
30             package WebService::Geocodio::Fields::StateLegislativeDistrict::Senate;
31             $WebService::Geocodio::Fields::StateLegislativeDistrict::Senate::VERSION = '0.05';
32 7     7   1200 use Moo;
  7         12  
  7         21  
33 7     7   1809 use strictures 2;;
  7         34  
  7         195  
34              
35             has [qw(name district_number)] => (
36             is => 'ro',
37             );
38             }
39              
40             {
41              
42             package WebService::Geocodio::Fields::StateLegislativeDistrict;
43             $WebService::Geocodio::Fields::StateLegislativeDistrict::VERSION = '0.05';
44 7     7   1144 use WebService::Geocodio::Fields::StateLegislativeDistrict::House;
  7         12  
  7         173  
45 7     7   38 use WebService::Geocodio::Fields::StateLegislativeDistrict::Senate;
  7         11  
  7         126  
46              
47 7     7   25 use Moo;
  7         11  
  7         34  
48 7     7   1845 use strictures 2;;
  7         28  
  7         184  
49 7     7   1012 use Carp qw(confess);
  7         17  
  7         1366  
50              
51             has [qw(house senate)] => (
52             is => 'ro',
53             predicate => 1,
54             );
55              
56             sub BUILDARGS {
57 0     0 0   my ($class, $hr) = @_;
58              
59 0 0         confess "$class only accepts hashrefs in its constructor" unless ( ref($hr) eq 'HASH' );
60              
61 0           my $out;
62              
63             $out->{house} = WebService::Geocodio::Fields::StateLegislativeDistrict::House->new(
64 0 0         $hr->{house}) if exists $hr->{house};
65             $out->{senate} = WebService::Geocodio::Fields::StateLegislativeDistrict::Senate->new(
66 0 0         $hr->{senate}) if exists $hr->{senate};
67              
68 0           return $out;
69             }
70              
71             }
72              
73             ############### School districts
74              
75             {
76             package WebService::Geocodio::Fields::SchoolDistrict::Unified;
77             $WebService::Geocodio::Fields::SchoolDistrict::Unified::VERSION = '0.05';
78 7     7   45 use Moo;
  7         28  
  7         31  
79 7     7   1797 use strictures 2;;
  7         24  
  7         188  
80              
81             has [qw(name lea_code grade_low grade_high)] => (
82             is => 'ro',
83             );
84             }
85              
86             {
87             package WebService::Geocodio::Fields::SchoolDistrict::Elementary;
88             $WebService::Geocodio::Fields::SchoolDistrict::Elementary::VERSION = '0.05';
89 7     7   1182 use Moo;
  7         10  
  7         22  
90 7     7   1751 use strictures 2;;
  7         27  
  7         190  
91              
92             has [qw(name lea_code grade_low grade_high)] => (
93             is => 'ro',
94             );
95             }
96              
97             {
98             package WebService::Geocodio::Fields::SchoolDistrict::Secondary;
99             $WebService::Geocodio::Fields::SchoolDistrict::Secondary::VERSION = '0.05';
100 7     7   1067 use Moo;
  7         19  
  7         21  
101 7     7   1751 use strictures 2;;
  7         26  
  7         209  
102              
103             has [qw(name lea_code grade_low grade_high)] => (
104             is => 'ro',
105             );
106             }
107              
108             {
109              
110             package WebService::Geocodio::Fields::SchoolDistrict;
111             $WebService::Geocodio::Fields::SchoolDistrict::VERSION = '0.05';
112 7     7   1099 use WebService::Geocodio::Fields::SchoolDistrict::Unified;
  7         22  
  7         156  
113 7     7   35 use WebService::Geocodio::Fields::SchoolDistrict::Elementary;
  7         11  
  7         143  
114 7     7   38 use WebService::Geocodio::Fields::SchoolDistrict::Secondary;
  7         12  
  7         112  
115              
116 7     7   24 use Moo;
  7         22  
  7         51  
117 7     7   1902 use strictures 2;;
  7         27  
  7         185  
118 7     7   907 use Carp qw(confess);
  7         16  
  7         1367  
119              
120             has [qw(unified elementary secondary)] => (
121             is => 'ro',
122             predicate => 1,
123             );
124              
125             sub BUILDARGS {
126 0     0 0   my ($class, $hr) = @_;
127              
128 0 0         confess "$class only accepts hashrefs in its constructor" unless ( ref($hr) eq 'HASH' );
129              
130 0           my $out;
131              
132             $out->{unified} = WebService::Geocodio::Fields::SchoolDistrict::Unified->new(
133 0 0         $hr->{unified}) if exists $hr->{unified};
134             $out->{elementary} = WebService::Geocodio::Fields::SchoolDistrict::Elementary->new(
135 0 0         $hr->{elementary}) if exists $hr->{elementary};
136             $out->{secondary} = WebService::Geocodio::Fields::SchoolDistrict::Secondary->new(
137 0 0         $hr->{secondary}) if exists $hr->{secondary};
138              
139 0           return $out;
140             }
141             }
142              
143             ############################ Timezone
144              
145             {
146             package WebService::Geocodio::Fields::Timezone;
147             $WebService::Geocodio::Fields::Timezone::VERSION = '0.05';
148 7     7   46 use Moo;
  7         9  
  7         24  
149 7     7   1743 use strictures 2;
  7         27  
  7         178  
150              
151             has [qw(name utc_offset observes_dst)] => (
152             is => 'ro',
153             );
154             }
155              
156             ############################ Census
157              
158             {
159             package WebService::Geocodio::Fields::Census;
160             $WebService::Geocodio::Fields::Census::VERSION = '0.05';
161 7     7   1067 use Moo;
  7         9  
  7         25  
162 7     7   1749 use strictures 2;
  7         28  
  7         200  
163              
164             has [qw(state_fips county_fips place_fips tract_code
165             block_group block_code census_year)] => (
166             is => 'ro',
167             );
168              
169             }
170              
171             package WebService::Geocodio::Fields;
172             $WebService::Geocodio::Fields::VERSION = '0.05';
173             # ABSTRACT: Modules to represent various fields Geocod.io supports
174              
175 7     7   1099 use WebService::Geocodio::Fields::CongressionalDistrict;
  7         13  
  7         162  
176 7     7   31 use WebService::Geocodio::Fields::StateLegislativeDistrict;
  7         8  
  7         165  
177 7     7   31 use WebService::Geocodio::Fields::SchoolDistrict;
  7         9  
  7         106  
178 7     7   33 use WebService::Geocodio::Fields::Timezone;
  7         23  
  7         169  
179 7     7   32 use WebService::Geocodio::Fields::Census;
  7         14  
  7         141  
180              
181 7     7   29 use Moo;
  7         9  
  7         27  
182 7     7   1735 use strictures 2;
  7         25  
  7         187  
183 7     7   935 use Carp qw(confess);
  7         14  
  7         1765  
184              
185             has [qw(cd stateleg school timezone census)] => (
186             is => 'rw',
187             predicate => 1,
188             );
189              
190             sub BUILDARGS {
191 0     0 0   my ( $class, $hr ) = @_;
192              
193 0 0         confess "$class only accepts hashrefs in its constructor" unless ( ref($hr) eq 'HASH' );
194              
195 0           my $out;
196              
197 0           $out->{cd} = [ map { WebService::Geocodio::Fields::CongressionalDistrict->new($_) }
198 0 0         @{ $hr->{congressional_districts} } ] if exists $hr->{congressional_districts};
  0            
199             $out->{stateleg} = WebService::Geocodio::Fields::StateLegislativeDistrict->new(
200 0 0         $hr->{state_legislative_districts}) if exists $hr->{state_legislative_districts};
201             $out->{school} = WebService::Geocodio::Fields::SchoolDistrict->new(
202 0 0         $hr->{school_districts}) if exists $hr->{school_districts};
203             $out->{timezone} = WebService::Geocodio::Fields::Timezone->new($hr->{timezone})
204 0 0         if exists $hr->{timezone};
205             $out->{census} = WebService::Geocodio::Fields::Census->new($hr->{census})
206 0 0         if exists $hr->{census};
207              
208 0           return $out;
209             }
210              
211             1;
212              
213             __END__