blib/lib/Geo/Fips55.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 40 / 40 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package Geo::Fips55;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 Geo::TigerLine::Record::Parser
8 Geo::TigerLine::Record::Accessor
9 Geo::TigerLine::Record
10 Class::Data::Inheritable
11 1 );
12  
13 1 our $VERSION = '0.01';
14  
15 # Auto-generated data dictionary.
16 1 my @Proto_Dict = (
17 state_fips => {
18 beg => 1, end => 2, len => 2, type => "N",
19 description => "FIPS State Code" },
20 place_fips => {
21 beg => 3, end => 7, len => 5, type => "N",
22 description => "FIPS Place Code" },
23 state => {
24 beg => 8, end => 9, len => 2, type => "A",
25 description => "State Alpha Code" },
26 num_counties => {
27 beg => 10, end => 11, len => 2, type => "N",
28 description => "Total Number of Counties" },
29 crsn => {
30 beg => 12, end => 13, len => 2, type => "N",
31 description => "County Record Sequence Number" },
32 class => {
33 beg => 14, end => 15, len => 2, type => "A",
34 description => "Class Code" },
35 name => {
36 beg => 16, end => 67, len => 52, type => "A",
37 description => "Place Name" },
38 county_fips => {
39 beg => 68, end => 70, len => 3, type => "N",
40 description => "FIPS County Code" },
41 county => {
42 beg => 71, end => 92, len => 22, type => "A",
43 description => "Name of County" },
44 part_of => {
45 beg => 93, end => 97, len => 5, type => "N",
46 description => "Part of Code" },
47 other_name => {
48 beg => 98, end => 102, len => 5, type => "N",
49 description => "Other Name Code" },
50 zip => {
51 beg => 103, end => 107, len => 5, type => "N",
52 description => "Zip Code" },
53 postal_match => {
54 beg => 108, end => 109, len => 2, type => "A",
55 description => "Postal Name Match" },
56 zip_range => {
57 beg => 110, end => 111, len => 2, type => "N",
58 description => "Zip Code Range" },
59 gsa => {
60 beg => 112, end => 115, len => 4, type => "N",
61 description => "GSA Code" },
62 mrf => {
63 beg => 116, end => 119, len => 4, type => "N",
64 description => "MRF Code" },
65 msa => {
66 beg => 120, end => 123, len => 4, type => "N",
67 description => "MSA Code" },
68 cd1 => {
69 beg => 124, end => 125, len => 2, type => "N",
70 description => "Congressional District 1" },
71 cd2 => {
72 beg => 126, end => 127, len => 2, type => "N",
73 description => "Congressional District 2" },
74 cd3 => {
75 beg => 128, end => 129, len => 2, type => "N",
76 description => "Congressional District 3" },
77 cd4 => {
78 beg => 130, end => 131, len => 2, type => "N",
79 description => "Congressional District 4" },
80 cd5 => {
81 beg => 132, end => 133, len => 2, type => "N",
82 description => "Congressional District 5" },
83 cd6 => {
84 beg => 134, end => 135, len => 2, type => "N",
85 description => "Congressional District 6" },
86 cd7 => {
87 beg => 136, end => 137, len => 2, type => "N",
88 description => "Congressional District 7" },
89 cd8 => {
90 beg => 138, end => 139, len => 2, type => "N",
91 description => "Congressional District 8" },
92 cd9 => {
93 beg => 140, end => 141, len => 2, type => "N",
94 description => "Congressional District 9" },
95 cd10 => {
96 beg => 142, end => 143, len => 2, type => "N",
97 description => "Congressional District 10" },
98 cd11 => {
99 beg => 144, end => 145, len => 2, type => "N",
100 description => "Congressional District 11" },
101 cd12 => {
102 beg => 146, end => 147, len => 2, type => "N",
103 description => "Congressional District 12" },
104 cd13 => {
105 beg => 148, end => 149, len => 2, type => "N",
106 description => "Congressional District 13" },
107 cd14 => {
108 beg => 142, end => 143, len => 2, type => "N",
109 description => "Congressional District 14" },
110 );
111  
112 1 my %Data_Dict = ();
113 1 my @Data_Fields = ();
114 1 my $fieldnum = 1;
115  
116 1 ▶while (my ($field, $args) = splice(@Proto_Dict, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@Proto_Dict, 0, 2)) 31 1 32
117 $Data_Dict{$field} = {
118 fieldnum => $fieldnum++, bv => "Yes", field => $field,
119 31 ▶ fmt => ($args->{type} eq "N" ? "R" : "L"),
Branch: 1 branch
BranchTrueFalseTotal
$args->{'type'} eq 'N' ? : 26 5 31
120 %$args
121 };
122 31 push @Data_Fields, $field;
123 }
124  
125 1 assert(keys %Data_Dict == @Data_Fields);
126  
127 # Turn the data dictionary into class data
128 1 __PACKAGE__->mk_classdata('Fields');
129 1 __PACKAGE__->mk_classdata('Dict');
130 1 __PACKAGE__->mk_classdata('Pack_Tmpl');
131  
132 1 __PACKAGE__->Dict(\%Data_Dict);
133 1 __PACKAGE__->Fields(\@Data_Fields);
134  
135 # Generate a pack template for parsing and turn it into class data.
136 31 my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} }
137 1 @Data_Dict{@Data_Fields};
138 1 __PACKAGE__->Pack_Tmpl($pack_tmpl);
139  
140 # Generate accessors for each data field
141 1 foreach my $def (@Data_Dict{@Data_Fields}) {
142 31 __PACKAGE__->mk_accessor($def);
143 }
144  
145 1 1;
146 __END__
↑ Summary