postal_code 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.rdoc +15 -1
- data/db/US.tsv +66 -37
- data/lib/postal_code.rb +11 -7
- data/test/test_postal_code.rb +17 -10
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3669d039774fdfe02d784606417d34a0934e9ed9f6f75bcb93b1cdb484838f56
|
|
4
|
+
data.tar.gz: 626a654598f0458f751fa526c758303c0e93a51f7bb2712a9567096d9f4f7b4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea844f0dd9fd458cd214a0bef221e96193ece2406b6218469cdd9a3d0ae59e4dd5603ca4058434ef47fc149792771d2bcfff21172e637b2ae61d301f07852602
|
|
7
|
+
data.tar.gz: ffe0b33ff04b423fce648bb0d16cb9045f77bdfeebb7ef617936f6bfcde54359dec6ae49bae49944bacb135b5b090f2d1b9d2144b55aa29d3fc2f326772fc104
|
data/README.rdoc
CHANGED
|
@@ -82,6 +82,14 @@ details.
|
|
|
82
82
|
PostalCode.city '00000' #=> nil
|
|
83
83
|
PostalCode.state '00000' #=> nil
|
|
84
84
|
|
|
85
|
+
=== Validate postal code
|
|
86
|
+
|
|
87
|
+
PostalCode.valid_format? 1 #=> TypeError (postal code must be a string)
|
|
88
|
+
|
|
89
|
+
PostalCode.valid_format? '1' #=> false
|
|
90
|
+
PostalCode.valid_format? '00000' #=> true
|
|
91
|
+
PostalCode.valid_format? '00000-0000' #=> true
|
|
92
|
+
|
|
85
93
|
=== Load entire postal code database into memory
|
|
86
94
|
|
|
87
95
|
PostalCode.load_cache
|
|
@@ -148,12 +156,18 @@ Bug Tracker :: https://bitbucket.org/pachl/postal_code/issues
|
|
|
148
156
|
8. 2017-12-04, v0.3.5
|
|
149
157
|
* Update US database. (515 additions and 7 deletions)
|
|
150
158
|
|
|
159
|
+
9. 2020-02-19, v0.3.6
|
|
160
|
+
* Add API method PostalCode.valid\_format?
|
|
161
|
+
* Raise TypeError when a postal code parameter is not a string.
|
|
162
|
+
* Clean up validation tests.
|
|
163
|
+
* Update US database. (66 additions and 37 deletions)
|
|
164
|
+
|
|
151
165
|
|
|
152
166
|
== License
|
|
153
167
|
|
|
154
168
|
({ISC License}[https://opensource.org/licenses/ISC])
|
|
155
169
|
|
|
156
|
-
Copyright (c)
|
|
170
|
+
Copyright (c) 2020, Clint Pachl <pachl@ecentryx.com>
|
|
157
171
|
|
|
158
172
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
159
173
|
with or without fee is hereby granted, provided that the above copyright notice
|
data/db/US.tsv
CHANGED
|
@@ -3169,7 +3169,6 @@
|
|
|
3169
3169
|
09461 APO AE
|
|
3170
3170
|
09462 APO AE
|
|
3171
3171
|
09463 APO AE
|
|
3172
|
-
09464 APO AA
|
|
3173
3172
|
09464 APO AE
|
|
3174
3173
|
09467 APO AE
|
|
3175
3174
|
09468 APO AE
|
|
@@ -6696,6 +6695,7 @@
|
|
|
6696
6695
|
17332 Hanover PA
|
|
6697
6696
|
17333 Hanover PA
|
|
6698
6697
|
17334 Hanover PA
|
|
6698
|
+
17335 Hanover PA
|
|
6699
6699
|
17337 Idaville PA
|
|
6700
6700
|
17339 Lewisberry PA
|
|
6701
6701
|
17340 Littlestown PA
|
|
@@ -7960,6 +7960,7 @@
|
|
|
7960
7960
|
20245 Washington DC
|
|
7961
7961
|
20250 Washington DC
|
|
7962
7962
|
20251 Washington DC
|
|
7963
|
+
20252 Washington DC
|
|
7963
7964
|
20254 Washington DC
|
|
7964
7965
|
20260 Washington DC
|
|
7965
7966
|
20261 Washington DC
|
|
@@ -8015,6 +8016,7 @@
|
|
|
8015
8016
|
20414 Washington DC
|
|
8016
8017
|
20415 Washington DC
|
|
8017
8018
|
20416 Washington DC
|
|
8019
|
+
20417 Washington DC
|
|
8018
8020
|
20418 Washington DC
|
|
8019
8021
|
20419 Washington DC
|
|
8020
8022
|
20420 Washington DC
|
|
@@ -8112,11 +8114,13 @@
|
|
|
8112
8114
|
20581 Washington DC
|
|
8113
8115
|
20585 Washington DC
|
|
8114
8116
|
20586 Washington DC
|
|
8117
|
+
20588 Dhs MD
|
|
8115
8118
|
20590 Washington DC
|
|
8116
8119
|
20591 Washington DC
|
|
8117
8120
|
20593 Washington DC
|
|
8118
8121
|
20594 Washington DC
|
|
8119
8122
|
20597 Washington DC
|
|
8123
|
+
20598 Dhs VA
|
|
8120
8124
|
20599 Washington DC
|
|
8121
8125
|
20601 Waldorf MD
|
|
8122
8126
|
20602 Waldorf MD
|
|
@@ -9624,6 +9628,7 @@
|
|
|
9624
9628
|
24201 Bristol VA
|
|
9625
9629
|
24202 Bristol VA
|
|
9626
9630
|
24203 Bristol VA
|
|
9631
|
+
24205 Bristol VA
|
|
9627
9632
|
24209 Bristol VA
|
|
9628
9633
|
24210 Abingdon VA
|
|
9629
9634
|
24211 Abingdon VA
|
|
@@ -10363,6 +10368,7 @@
|
|
|
10363
10368
|
25879 Minden WV
|
|
10364
10369
|
25880 Mount Hope WV
|
|
10365
10370
|
25882 Mullens WV
|
|
10371
|
+
25888 Mount Hope WV
|
|
10366
10372
|
25901 Oak Hill WV
|
|
10367
10373
|
25902 Odd WV
|
|
10368
10374
|
25904 Pax WV
|
|
@@ -10744,31 +10750,31 @@
|
|
|
10744
10750
|
27094 Rural Hall NC
|
|
10745
10751
|
27098 Rural Hall NC
|
|
10746
10752
|
27099 Rural Hall NC
|
|
10747
|
-
27101 Winston
|
|
10748
|
-
27102 Winston
|
|
10749
|
-
27103 Winston
|
|
10750
|
-
27104 Winston
|
|
10751
|
-
27105 Winston
|
|
10752
|
-
27106 Winston
|
|
10753
|
-
27107 Winston
|
|
10754
|
-
27108 Winston
|
|
10755
|
-
27109 Winston
|
|
10756
|
-
27110 Winston
|
|
10757
|
-
27111 Winston
|
|
10758
|
-
27113 Winston
|
|
10759
|
-
27114 Winston
|
|
10760
|
-
27115 Winston
|
|
10761
|
-
27116 Winston
|
|
10762
|
-
27117 Winston
|
|
10763
|
-
27120 Winston
|
|
10764
|
-
27127 Winston
|
|
10765
|
-
27130 Winston
|
|
10766
|
-
27150 Winston
|
|
10767
|
-
27152 Winston
|
|
10768
|
-
27155 Winston
|
|
10769
|
-
27157 Winston
|
|
10770
|
-
27198 Winston
|
|
10771
|
-
27199 Winston
|
|
10753
|
+
27101 Winston-Salem NC
|
|
10754
|
+
27102 Winston-Salem NC
|
|
10755
|
+
27103 Winston-Salem NC
|
|
10756
|
+
27104 Winston-Salem NC
|
|
10757
|
+
27105 Winston-Salem NC
|
|
10758
|
+
27106 Winston-Salem NC
|
|
10759
|
+
27107 Winston-Salem NC
|
|
10760
|
+
27108 Winston-Salem NC
|
|
10761
|
+
27109 Winston-Salem NC
|
|
10762
|
+
27110 Winston-Salem NC
|
|
10763
|
+
27111 Winston-Salem NC
|
|
10764
|
+
27113 Winston-Salem NC
|
|
10765
|
+
27114 Winston-Salem NC
|
|
10766
|
+
27115 Winston-Salem NC
|
|
10767
|
+
27116 Winston-Salem NC
|
|
10768
|
+
27117 Winston-Salem NC
|
|
10769
|
+
27120 Winston-Salem NC
|
|
10770
|
+
27127 Winston-Salem NC
|
|
10771
|
+
27130 Winston-Salem NC
|
|
10772
|
+
27150 Winston-Salem NC
|
|
10773
|
+
27152 Winston-Salem NC
|
|
10774
|
+
27155 Winston-Salem NC
|
|
10775
|
+
27157 Winston-Salem NC
|
|
10776
|
+
27198 Winston-Salem NC
|
|
10777
|
+
27199 Winston-Salem NC
|
|
10772
10778
|
27201 Alamance NC
|
|
10773
10779
|
27202 Altamahaw NC
|
|
10774
10780
|
27203 Asheboro NC
|
|
@@ -10808,6 +10814,7 @@
|
|
|
10808
10814
|
27263 High Point NC
|
|
10809
10815
|
27264 High Point NC
|
|
10810
10816
|
27265 High Point NC
|
|
10817
|
+
27268 High Point NC
|
|
10811
10818
|
27278 Hillsborough NC
|
|
10812
10819
|
27281 Jackson Springs NC
|
|
10813
10820
|
27282 Jamestown NC
|
|
@@ -12968,10 +12975,12 @@
|
|
|
12968
12975
|
31136 Atlanta GA
|
|
12969
12976
|
31139 Atlanta GA
|
|
12970
12977
|
31141 Atlanta GA
|
|
12978
|
+
31144 Kennesaw GA
|
|
12971
12979
|
31145 Atlanta GA
|
|
12972
12980
|
31146 Atlanta GA
|
|
12973
12981
|
31150 Atlanta GA
|
|
12974
12982
|
31156 Atlanta GA
|
|
12983
|
+
31169 Peachtree City GA
|
|
12975
12984
|
31192 Atlanta GA
|
|
12976
12985
|
31193 Atlanta GA
|
|
12977
12986
|
31195 Atlanta GA
|
|
@@ -13895,6 +13904,7 @@
|
|
|
13895
13904
|
33097 Coconut Creek FL
|
|
13896
13905
|
33101 Miami FL
|
|
13897
13906
|
33102 Miami FL
|
|
13907
|
+
33106 Miami FL
|
|
13898
13908
|
33109 Miami Beach FL
|
|
13899
13909
|
33111 Miami FL
|
|
13900
13910
|
33112 Miami FL
|
|
@@ -14586,6 +14596,7 @@
|
|
|
14586
14596
|
34433 Dunnellon FL
|
|
14587
14597
|
34434 Dunnellon FL
|
|
14588
14598
|
34436 Floral City FL
|
|
14599
|
+
34441 Hernando FL
|
|
14589
14600
|
34442 Hernando FL
|
|
14590
14601
|
34445 Holder FL
|
|
14591
14602
|
34446 Homosassa FL
|
|
@@ -14901,6 +14912,7 @@
|
|
|
14901
14912
|
35260 Birmingham AL
|
|
14902
14913
|
35261 Birmingham AL
|
|
14903
14914
|
35266 Birmingham AL
|
|
14915
|
+
35270 Birmingham AL
|
|
14904
14916
|
35282 Birmingham AL
|
|
14905
14917
|
35283 Birmingham AL
|
|
14906
14918
|
35285 Birmingham AL
|
|
@@ -16985,6 +16997,7 @@
|
|
|
16985
16997
|
40161 Rhodelia KY
|
|
16986
16998
|
40162 Rineyville KY
|
|
16987
16999
|
40165 Shepherdsville KY
|
|
17000
|
+
40166 Shepherdsville KY
|
|
16988
17001
|
40170 Stephensport KY
|
|
16989
17002
|
40171 Union Star KY
|
|
16990
17003
|
40175 Vine Grove KY
|
|
@@ -17198,6 +17211,7 @@
|
|
|
17198
17211
|
40743 London KY
|
|
17199
17212
|
40744 London KY
|
|
17200
17213
|
40745 London KY
|
|
17214
|
+
40750 London KY
|
|
17201
17215
|
40755 Pittsburg KY
|
|
17202
17216
|
40759 Rockholds KY
|
|
17203
17217
|
40763 Siler KY
|
|
@@ -17292,7 +17306,9 @@
|
|
|
17292
17306
|
41017 Ft Mitchell KY
|
|
17293
17307
|
41018 Erlanger KY
|
|
17294
17308
|
41019 Covington KY
|
|
17309
|
+
41021 Hebron KY
|
|
17295
17310
|
41022 Florence KY
|
|
17311
|
+
41025 Erlanger KY
|
|
17296
17312
|
41030 Crittenden KY
|
|
17297
17313
|
41031 Cynthiana KY
|
|
17298
17314
|
41033 De Mossville KY
|
|
@@ -17960,6 +17976,7 @@
|
|
|
17960
17976
|
43160 Washington Court House OH
|
|
17961
17977
|
43162 West Jefferson OH
|
|
17962
17978
|
43164 Williamsport OH
|
|
17979
|
+
43194 Lockbourne OH
|
|
17963
17980
|
43195 Groveport OH
|
|
17964
17981
|
43199 Groveport OH
|
|
17965
17982
|
43201 Columbus OH
|
|
@@ -19382,6 +19399,7 @@
|
|
|
19382
19399
|
46208 Indianapolis IN
|
|
19383
19400
|
46209 Indianapolis IN
|
|
19384
19401
|
46211 Indianapolis IN
|
|
19402
|
+
46213 Indianapolis IN
|
|
19385
19403
|
46214 Indianapolis IN
|
|
19386
19404
|
46216 Indianapolis IN
|
|
19387
19405
|
46217 Indianapolis IN
|
|
@@ -21881,6 +21899,8 @@
|
|
|
21881
21899
|
50950 Des Moines IA
|
|
21882
21900
|
50980 Des Moines IA
|
|
21883
21901
|
50981 Des Moines IA
|
|
21902
|
+
50982 Des Moines IA
|
|
21903
|
+
50983 Des Moines IA
|
|
21884
21904
|
51001 Akron IA
|
|
21885
21905
|
51002 Alta IA
|
|
21886
21906
|
51003 Alton IA
|
|
@@ -25106,6 +25126,7 @@
|
|
|
25106
25126
|
58795 Wildrose ND
|
|
25107
25127
|
58801 Williston ND
|
|
25108
25128
|
58802 Williston ND
|
|
25129
|
+
58803 Williston ND
|
|
25109
25130
|
58830 Alamo ND
|
|
25110
25131
|
58831 Alexander ND
|
|
25111
25132
|
58833 Ambrose ND
|
|
@@ -25721,6 +25742,7 @@
|
|
|
25721
25742
|
60415 Chicago Ridge IL
|
|
25722
25743
|
60416 Coal City IL
|
|
25723
25744
|
60417 Crete IL
|
|
25745
|
+
60418 Crestwood IL
|
|
25724
25746
|
60419 Dolton IL
|
|
25725
25747
|
60420 Dwight IL
|
|
25726
25748
|
60421 Elwood IL
|
|
@@ -25848,6 +25870,7 @@
|
|
|
25848
25870
|
60566 Naperville IL
|
|
25849
25871
|
60567 Naperville IL
|
|
25850
25872
|
60568 Aurora IL
|
|
25873
|
+
60569 Aurora IL
|
|
25851
25874
|
60572 Aurora IL
|
|
25852
25875
|
60585 Plainfield IL
|
|
25853
25876
|
60586 Plainfield IL
|
|
@@ -30665,6 +30688,7 @@
|
|
|
30665
30688
|
72225 Little Rock AR
|
|
30666
30689
|
72227 Little Rock AR
|
|
30667
30690
|
72231 Little Rock AR
|
|
30691
|
+
72255 Little Rock AR
|
|
30668
30692
|
72260 Little Rock AR
|
|
30669
30693
|
72295 Little Rock AR
|
|
30670
30694
|
72301 West Memphis AR
|
|
@@ -30916,6 +30940,7 @@
|
|
|
30916
30940
|
72704 Fayetteville AR
|
|
30917
30941
|
72711 Avoca AR
|
|
30918
30942
|
72712 Bentonville AR
|
|
30943
|
+
72713 Bentonville AR
|
|
30919
30944
|
72714 Bella Vista AR
|
|
30920
30945
|
72715 Bella Vista AR
|
|
30921
30946
|
72716 Bentonville AR
|
|
@@ -31837,6 +31862,7 @@
|
|
|
31837
31862
|
75033 Frisco TX
|
|
31838
31863
|
75034 Frisco TX
|
|
31839
31864
|
75035 Frisco TX
|
|
31865
|
+
75036 Frisco TX
|
|
31840
31866
|
75038 Irving TX
|
|
31841
31867
|
75039 Irving TX
|
|
31842
31868
|
75040 Garland TX
|
|
@@ -31867,6 +31893,7 @@
|
|
|
31867
31893
|
75069 Mckinney TX
|
|
31868
31894
|
75070 Mckinney TX
|
|
31869
31895
|
75071 Mckinney TX
|
|
31896
|
+
75072 Mckinney TX
|
|
31870
31897
|
75074 Plano TX
|
|
31871
31898
|
75075 Plano TX
|
|
31872
31899
|
75076 Pottsboro TX
|
|
@@ -32477,6 +32504,7 @@
|
|
|
32477
32504
|
76181 Fort Worth TX
|
|
32478
32505
|
76182 North Richland Hills TX
|
|
32479
32506
|
76185 Fort Worth TX
|
|
32507
|
+
76190 Fort Worth TX
|
|
32480
32508
|
76191 Fort Worth TX
|
|
32481
32509
|
76192 Fort Worth TX
|
|
32482
32510
|
76193 Fort Worth TX
|
|
@@ -35433,9 +35461,9 @@
|
|
|
35433
35461
|
83811 Clark Fork ID
|
|
35434
35462
|
83812 Clarkia ID
|
|
35435
35463
|
83813 Cocolalla ID
|
|
35436
|
-
83814 Coeur
|
|
35437
|
-
83815 Coeur
|
|
35438
|
-
83816 Coeur
|
|
35464
|
+
83814 Coeur d'Alene ID
|
|
35465
|
+
83815 Coeur d'Alene ID
|
|
35466
|
+
83816 Coeur d'Alene ID
|
|
35439
35467
|
83821 Coolin ID
|
|
35440
35468
|
83822 Oldtown ID
|
|
35441
35469
|
83823 Deary ID
|
|
@@ -35909,12 +35937,14 @@
|
|
|
35909
35937
|
85087 New River AZ
|
|
35910
35938
|
85097 Phoenix AZ
|
|
35911
35939
|
85098 Phoenix AZ
|
|
35940
|
+
85117 Apache Junction AZ
|
|
35912
35941
|
85118 Gold Canyon AZ
|
|
35913
35942
|
85119 Apache Junction AZ
|
|
35914
35943
|
85120 Apache Junction AZ
|
|
35915
35944
|
85121 Bapchule AZ
|
|
35916
35945
|
85122 Casa Grande AZ
|
|
35917
35946
|
85123 Arizona City AZ
|
|
35947
|
+
85127 Chandler Heights AZ
|
|
35918
35948
|
85128 Coolidge AZ
|
|
35919
35949
|
85130 Casa Grande AZ
|
|
35920
35950
|
85131 Eloy AZ
|
|
@@ -35931,6 +35961,9 @@
|
|
|
35931
35961
|
85147 Sacaton AZ
|
|
35932
35962
|
85172 Stanfield AZ
|
|
35933
35963
|
85173 Superior AZ
|
|
35964
|
+
85178 Apache Junction AZ
|
|
35965
|
+
85190 Tortilla Flat AZ
|
|
35966
|
+
85191 Valley Farms AZ
|
|
35934
35967
|
85192 Winkelman AZ
|
|
35935
35968
|
85193 Casa Grande AZ
|
|
35936
35969
|
85194 Casa Grande AZ
|
|
@@ -36438,6 +36471,7 @@
|
|
|
36438
36471
|
87125 Albuquerque NM
|
|
36439
36472
|
87131 Albuquerque NM
|
|
36440
36473
|
87144 Rio Rancho NM
|
|
36474
|
+
87151 Albuquerque NM
|
|
36441
36475
|
87153 Albuquerque NM
|
|
36442
36476
|
87154 Albuquerque NM
|
|
36443
36477
|
87158 Albuquerque NM
|
|
@@ -36567,6 +36601,7 @@
|
|
|
36567
36601
|
87583 Villanueva NM
|
|
36568
36602
|
87592 Santa Fe NM
|
|
36569
36603
|
87594 Santa Fe NM
|
|
36604
|
+
87654 Spaceport City NM
|
|
36570
36605
|
87701 Las Vegas NM
|
|
36571
36606
|
87710 Angel Fire NM
|
|
36572
36607
|
87711 Anton Chico NM
|
|
@@ -36632,6 +36667,7 @@
|
|
|
36632
36667
|
88009 Playas NM
|
|
36633
36668
|
88011 Las Cruces NM
|
|
36634
36669
|
88012 Las Cruces NM
|
|
36670
|
+
88013 Las Cruces NM
|
|
36635
36671
|
88020 Animas NM
|
|
36636
36672
|
88021 Anthony NM
|
|
36637
36673
|
88022 Arenas Valley NM
|
|
@@ -39077,6 +39113,7 @@
|
|
|
39077
39113
|
95211 Stockton CA
|
|
39078
39114
|
95212 Stockton CA
|
|
39079
39115
|
95213 Stockton CA
|
|
39116
|
+
95214 Stockton CA
|
|
39080
39117
|
95215 Stockton CA
|
|
39081
39118
|
95219 Stockton CA
|
|
39082
39119
|
95220 Acampo CA
|
|
@@ -39961,14 +39998,6 @@
|
|
|
39961
39998
|
96863 FPO AA
|
|
39962
39999
|
96863 Mcbh Kaneohe Bay HI
|
|
39963
40000
|
96898 Wake Island HI
|
|
39964
|
-
96940 Palau PW
|
|
39965
|
-
96941 Pohnpei FM
|
|
39966
|
-
96942 Chuuk FM
|
|
39967
|
-
96943 Yap FM
|
|
39968
|
-
96944 Kosrae FM
|
|
39969
|
-
96950 Saipan MP
|
|
39970
|
-
96951 Rota MP
|
|
39971
|
-
96952 Tinian MP
|
|
39972
40001
|
96960 Marshall Islands MH
|
|
39973
40002
|
96970 Ebeye MH
|
|
39974
40003
|
97001 Antelope OR
|
data/lib/postal_code.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module PostalCode
|
|
2
2
|
|
|
3
|
-
VERSION = '0.3.
|
|
3
|
+
VERSION = '0.3.6'
|
|
4
4
|
|
|
5
5
|
CityOffset = 0
|
|
6
6
|
StateOffset = 1
|
|
@@ -45,13 +45,17 @@ module PostalCode
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
48
|
+
# Postal codes must be strings because:
|
|
49
|
+
# 1. Postal codes are not calculable, therefore should not be numeric.
|
|
50
|
+
# 2. A postal code with a leading zero would be an octal. However, *08880* is
|
|
51
|
+
# an invalid octal numeric, yet a valid postal code.
|
|
52
52
|
#
|
|
53
53
|
def self.valid_format? postal_code
|
|
54
|
-
postal_code
|
|
54
|
+
unless postal_code.is_a? String
|
|
55
|
+
raise(TypeError, "postal code must be a string")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
(postal_code =~ /^\d{5}(-\d{4})?$/) ? true : false
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
#
|
|
@@ -74,6 +78,6 @@ module PostalCode
|
|
|
74
78
|
end
|
|
75
79
|
end
|
|
76
80
|
|
|
77
|
-
private_class_method :fetch
|
|
81
|
+
private_class_method :fetch
|
|
78
82
|
|
|
79
83
|
end
|
data/test/test_postal_code.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
2
|
require 'postal_code'
|
|
3
3
|
|
|
4
|
-
class PostalCodeTest < Minitest::
|
|
4
|
+
class PostalCodeTest < Minitest::Test
|
|
5
5
|
|
|
6
6
|
ProductionDB = PostalCode::DB.dup
|
|
7
7
|
TestDB = File.dirname(__FILE__) + '/data/US.tsv'
|
|
@@ -72,15 +72,22 @@ class PostalCodeTest < Minitest::Unit::TestCase
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def test_postal_code_validations
|
|
75
|
-
|
|
76
|
-
refute PostalCode.
|
|
77
|
-
refute PostalCode.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
assert PostalCode.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
assert PostalCode.valid_format?('01234-1234')
|
|
76
|
+
refute PostalCode.valid_format?('01234-123')
|
|
77
|
+
refute PostalCode.valid_format?('01234-12')
|
|
78
|
+
refute PostalCode.valid_format?('01234-1')
|
|
79
|
+
refute PostalCode.valid_format?('01234-')
|
|
80
|
+
assert PostalCode.valid_format?('01234')
|
|
81
|
+
refute PostalCode.valid_format?('0123')
|
|
82
|
+
refute PostalCode.valid_format?('012')
|
|
83
|
+
refute PostalCode.valid_format?('01')
|
|
84
|
+
refute PostalCode.valid_format?('0')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_postal_code_validation_exceptions
|
|
88
|
+
assert_raises(TypeError) { PostalCode.valid_format? 99999 }
|
|
89
|
+
assert_raises(TypeError) { PostalCode.valid_format? 00001 }
|
|
90
|
+
assert_raises(TypeError) { PostalCode.valid_format? 1 }
|
|
84
91
|
end
|
|
85
92
|
|
|
86
93
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: postal_code
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Clint Pachl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-02-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Resolve a postal (ZIP) code to a corresponding city or state.
|
|
14
14
|
email: pachl@ecentryx.com
|
|
@@ -48,8 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
49
|
version: '0'
|
|
50
50
|
requirements: []
|
|
51
|
-
|
|
52
|
-
rubygems_version: 2.6.12
|
|
51
|
+
rubygems_version: 3.0.3
|
|
53
52
|
signing_key:
|
|
54
53
|
specification_version: 4
|
|
55
54
|
summary: Postal (ZIP) Code Resolver
|