census_for 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2feb599ade71e9e27063be5ed53d8c8b3a41279e
4
- data.tar.gz: 205434019596a929adeeb96e863e0e311f9ecc49
3
+ metadata.gz: 4ea084ebaf7d177e9926827b5f64080943176a56
4
+ data.tar.gz: fcb08da50af3e836e4413c3f24b06131272c8359
5
5
  SHA512:
6
- metadata.gz: 3a899229e4dafbc0ae340e1f88ff6bd6cce13f8a02a1dc893cea8dc0346d7f62307bcc2eda5094c0646ab3c8bf56caf89bf6504fd73c1d34b33992a378660d13
7
- data.tar.gz: 0ec9d49d82ee53a3d27e55d88bb0400db65934e1fbcfbb95cfa6ea10e78eb78b3459d7d194cdf601d87f79a7d4513aa45ea1610ea590c91d5bf4c92534e49a0d
6
+ metadata.gz: b27cd6479f2ed7311f78a4e1d2f775f63855852e5577172967d7e751282b3cd6d4d27f1c3fbfe18bbb009d0960b333652da6ec4035144d229bbd35dcd586c403
7
+ data.tar.gz: e6ebb1b081450ad25649923e35208d2f7dd1da2737c403e6d17106f1d82467ae74af825d47fe872b3006eab99484173b5e4f52ba8316309d652f48746b1c8191
@@ -185,6 +185,7 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
185
185
  0500000US05145,5145,"White County, Arkansas",77076,77076,77339,78132,78652,78661,78592
186
186
  0500000US05147,5147,"Woodruff County, Arkansas",7260,7264,7243,7192,7071,7052,6910
187
187
  0500000US05149,5149,"Yell County, Arkansas",22185,22185,22159,21942,21811,21807,21951
188
+ ,,"Any, American Samoa",,,,,,,55165
188
189
  0500000US06001,6001,"Alameda County, California",1510271,1510261,1513625,1532518,1556249,1583226,1610921
189
190
  0500000US06003,6003,"Alpine County, California",1175,1175,1158,1111,1127,1150,1116
190
191
  0500000US06005,6005,"Amador County, California",38091,38091,37860,37520,37072,36602,36742
@@ -318,7 +319,7 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
318
319
  0500000US10001,10001,"Kent County, Delaware",162310,162344,162954,165214,167666,169562,171987
319
320
  0500000US10003,10003,"New Castle County, Delaware",538479,538477,538873,542324,546021,549233,552778
320
321
  0500000US10005,10005,"Sussex County, Delaware",197145,197115,197904,200291,203194,206445,210849
321
- 0500000US11001,11001,"District of Columbia, District of Columbia",601723,601767,605210,620427,635040,649111,658893
322
+ 0500000US11001,11001,"District Of Columbia County, District Of Columbia",601723,601767,605210,620427,635040,649111,658893
322
323
  0500000US12001,12001,"Alachua County, Florida",247336,247335,247680,249712,251713,253309,256380
323
324
  0500000US12003,12003,"Baker County, Florida",27115,27115,27072,27064,27041,27017,27093
324
325
  0500000US12005,12005,"Bay County, Florida",168852,168852,169294,169700,171994,174966,178985
@@ -545,6 +546,7 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
545
546
  0500000US13317,13317,"Wilkes County, Georgia",10593,10593,10491,10194,10046,9944,9940
546
547
  0500000US13319,13319,"Wilkinson County, Georgia",9563,9563,9516,9457,9542,9436,9326
547
548
  0500000US13321,13321,"Worth County, Georgia",21679,21679,21734,21617,21470,21064,20940
549
+ ,,"Any, Guam",,,,,,,165124
548
550
  0500000US15001,15001,"Hawaii County, Hawaii",185079,185079,185325,187039,188946,191409,194190
549
551
  0500000US15003,15003,"Honolulu County, Hawaii",953207,953207,956336,966559,976746,987019,991788
550
552
  0500000US15005,15005,"Kalawao County, Hawaii",90,90,90,90,89,89,89
@@ -1192,6 +1194,8 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
1192
1194
  0500000US23027,23027,"Waldo County, Maine",38786,38786,38797,38806,38889,38975,39051
1193
1195
  0500000US23029,23029,"Washington County, Maine",32856,32856,32810,32694,32485,32186,31808
1194
1196
  0500000US23031,23031,"York County, Maine",197131,197134,197196,198247,199055,199463,200710
1197
+ ,,"Any, Mariana Islands",,,,,,,53855
1198
+ ,,"Any, Marshall Islands",,,,,,,52634
1195
1199
  0500000US24001,24001,"Allegany County, Maryland",75087,75087,74988,74527,73883,73531,72952
1196
1200
  0500000US24003,24003,"Anne Arundel County, Maryland",537656,537656,539174,544976,550715,556348,560133
1197
1201
  0500000US24005,24005,"Baltimore County, Maryland",805029,804973,806233,813136,818425,823883,826925
@@ -2243,6 +2247,8 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
2243
2247
  0500000US41067,41067,"Washington County, Oregon",529710,529712,531345,539627,547737,555547,562998
2244
2248
  0500000US41069,41069,"Wheeler County, Oregon",1441,1441,1449,1420,1426,1397,1375
2245
2249
  0500000US41071,41071,"Yamhill County, Oregon",99193,99193,99312,99751,100771,100837,101758
2250
+ ,,"Any, Palau",,,,,,,20918
2251
+ ,,"Any, U.s. Minor Outlying Islands",,,,,,,300
2246
2252
  0500000US42001,42001,"Adams County, Pennsylvania",101407,101413,101470,101649,101538,101457,101714
2247
2253
  0500000US42003,42003,"Allegheny County, Pennsylvania",1223348,1223348,1223797,1227472,1230383,1232953,1231255
2248
2254
  0500000US42005,42005,"Armstrong County, Pennsylvania",68941,68940,68822,68636,68362,68110,67785
@@ -2952,6 +2958,7 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
2952
2958
  0500000US51820,51820,"Waynesboro city, Virginia",21006,21020,21068,21094,21105,21250,21366
2953
2959
  0500000US51830,51830,"Williamsburg city, Virginia",14068,13673,13689,14262,14617,14745,14691
2954
2960
  0500000US51840,51840,"Winchester city, Virginia",26203,26203,26183,26756,27178,27497,27543
2961
+ ,,"Any, Virgin Islands",,,,,,,104737
2955
2962
  0500000US53001,53001,"Adams County, Washington",18728,18728,18760,18830,18914,19073,19179
2956
2963
  0500000US53003,53003,"Asotin County, Washington",21623,21623,21697,21911,21873,22104,22189
2957
2964
  0500000US53005,53005,"Benton County, Washington",175177,175177,176456,180475,182396,184453,186486
@@ -3141,6 +3148,7 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
3141
3148
  0500000US56041,56041,"Uinta County, Wyoming",21118,21118,21103,20917,20989,21031,20904
3142
3149
  0500000US56043,56043,"Washakie County, Wyoming",8533,8533,8541,8466,8441,8450,8322
3143
3150
  0500000US56045,56045,"Weston County, Wyoming",7208,7208,7169,7102,7051,7154,7201
3151
+ ,,"Any, Ae",,,,,,,1318428
3144
3152
  ,,"Adjuntas Municipio, Puerto Rico",19483,19483,19473,19345,19170,19052,18900
3145
3153
  ,,"Aguada Municipio, Puerto Rico",41959,41959,41917,41656,41221,40759,40329
3146
3154
  ,,"Aguadilla Municipio, Puerto Rico",60949,60949,60788,60088,59067,58106,57290
@@ -3218,4 +3226,4 @@ GEO.id,GEO.id2,GEO.display-label,rescen42010,resbase42010,respop72010,respop7201
3218
3226
  ,,"Vieques Municipio, Puerto Rico",9301,9301,9306,9255,9237,9172,9113
3219
3227
  ,,"Villalba Municipio, Puerto Rico",26073,26073,26007,25604,25201,24777,24389
3220
3228
  ,,"Yabucoa Municipio, Puerto Rico",37941,37941,37880,37442,36919,36397,35879
3221
- ,,"Yauco Municipio, Puerto Rico",42043,42043,41926,41216,40425,39604,38782
3229
+ ,,"Yauco Municipio, Puerto Rico",42043,42043,41926,41216,40425,39604,38782
data/lib/census_for.rb CHANGED
@@ -2,7 +2,7 @@ require 'smarter_csv'
2
2
 
3
3
  class CensusFor
4
4
 
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
 
7
7
  STATES =
8
8
  {
@@ -19,16 +19,23 @@ class CensusFor
19
19
  ks: "kansas", ky: "kentucky",
20
20
  la: "louisiana",
21
21
  ma: "massachusetts", md: "maryland", me: "maine", mi: "michigan", mn: "minnesota", mo: "missouri", ms: "mississippi", mt: "montana",
22
+ mh: "marshall islands",
23
+ mp: "mariana islands",
22
24
  nc: "north carolina", nd: "north dakota", ne: "nebraska", nh: "new hampshire", nj: "new jersey", nm: "new mexico", nv: "nevada", ny: "new york",
23
25
  oh: "ohio", ok: "oklahoma", or: "oregon",
24
26
  pa: "pennsylvania",
25
27
  pr: "puerto rico",
28
+ pw: "palau",
26
29
  ri: "rhode island",
27
30
  sc: "south carolina", sd: "south dakota", tn: "tennessee", tx: "texas",
31
+ um: "u.s. minor outlying islands",
28
32
  ut: "utah",
29
33
  va: "virginia", vt: "vermont",
30
34
  vi: "virgin islands",
31
- wa: "washingington", wi: "wisconsin", wv: "west virginia", wy: "wyoming"
35
+ wa: "washington", wi: "wisconsin", wv: "west virginia", wy: "wyoming",
36
+ ae: "ae",
37
+ aa: "ae",
38
+ ap: "ae"
32
39
  }
33
40
 
34
41
  class CensusData
@@ -50,31 +57,35 @@ class CensusFor
50
57
  def self.parse_county_state(county_state)
51
58
  transit = county_state.downcase.split(/[\s,]+/) - ["county"] - ["parish"] - ["borough"] - ["municipio"] - ["municipality"]
52
59
  if transit.size >= 3
53
- result = []
60
+ city_state_key_array = []
54
61
  1.upto((transit.size - 1)) do |x|
55
62
  y = transit.size
56
63
  first = transit.take(x).join(' ')
57
64
  second = transit.last(y-x).join(' ')
58
- result << [first, second].flatten
65
+ city_state_key_array << [first, second].flatten
59
66
  end
60
- return result
61
67
  else
62
- return [transit]
68
+ city_state_key_array = [transit]
63
69
  end
64
- end
65
-
66
- def self.population_lookup(county_state)
67
- county_state.each do |cs|
70
+ city_state_key_array.each do |cs|
68
71
  county_name = cs.first
69
72
  state_name = cs.last
70
73
  state = Abbrev.converter(state_name)
71
74
  result = CensusData.data.find { |x| x[:"geo.display_label"] ==
72
75
  "#{county_name.split.map(&:capitalize).join(' ')} County, #{state}" || x[:"geo.display_label"] == "#{county_name.split.map(&:capitalize).join(' ')} Parish, Louisiana" || x[:"geo.display_label"] == "#{county_name.split.map(&:capitalize).join(' ')} Municipio, Puerto Rico" }
73
76
  if result
74
- return result[:respop72014]
77
+ return result[:"geo.display_label"]
75
78
  end
76
79
  end
77
- return "not found" #preceding each loop matched nothing from query
80
+ return "not found"
81
+ end
82
+
83
+ def self.population_lookup(parsed_county_state)
84
+ if parsed_county_state == "not found"
85
+ return "not found"
86
+ else
87
+ return CensusData.data.find { |x| x[:"geo.display_label"] == parsed_county_state }[:respop72014]
88
+ end
78
89
  end
79
90
 
80
91
  def self.coeff(county_state)
@@ -108,7 +119,8 @@ class CensusFor
108
119
  counties_pop_total += c[:respop72014]
109
120
  end
110
121
  return counties_pop_total
111
- else 'not found'
122
+ else
123
+ return 'not found'
112
124
  end
113
125
  end
114
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: census_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-07 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smarter_csv
@@ -98,7 +98,6 @@ post_install_message:
98
98
  rdoc_options: []
99
99
  require_paths:
100
100
  - lib
101
- - data
102
101
  required_ruby_version: !ruby/object:Gem::Requirement
103
102
  requirements:
104
103
  - - ">="