area 0.1.0

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.
Files changed (6) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/Rakefile +8 -0
  3. data/data/areacodes.csv +333 -0
  4. data/lib/area.rb +14 -0
  5. data/readme.md +13 -0
  6. metadata +50 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Jonathan Vingiano
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push "lib"
6
+ t.test_files = FileList['test/unit/*_test.rb']
7
+ t.verbose = true
8
+ end
@@ -0,0 +1,333 @@
1
+ Area Code,Region
2
+ 201,NJ
3
+ 202,DC
4
+ 203,CT
5
+ 204,MB
6
+ 205,AL
7
+ 206,WA
8
+ 207,ME
9
+ 208,ID
10
+ 209,CA
11
+ 210,TX
12
+ 212,NY
13
+ 213,CA
14
+ 214,TX
15
+ 215,PA
16
+ 216,OH
17
+ 217,IL
18
+ 218,MN
19
+ 219,IN
20
+ 224,IL
21
+ 225,LA
22
+ 226,ON
23
+ 228,MS
24
+ 229,GA
25
+ 231,MI
26
+ 234,OH
27
+ 239,FL
28
+ 240,MD
29
+ 242,Bahamas
30
+ 246,Barbados
31
+ 248,MI
32
+ 250,BC
33
+ 251,AL
34
+ 252,NC
35
+ 253,WA
36
+ 254,TX
37
+ 256,AL
38
+ 260,IN
39
+ 262,WI
40
+ 264,Anguilla
41
+ 267,PA
42
+ 268,Antigua and Barbuda
43
+ 269,MI
44
+ 270,KY
45
+ 276,VA
46
+ 281,TX
47
+ 284,British Virgin Islands
48
+ 289,ON
49
+ 301,MD
50
+ 302,DE
51
+ 303,CO
52
+ 304,WV
53
+ 305,FL
54
+ 306,SK
55
+ 307,WY
56
+ 308,NE
57
+ 309,IL
58
+ 310,CA
59
+ 312,IL
60
+ 313,MI
61
+ 314,MO
62
+ 315,NY
63
+ 316,KS
64
+ 317,IN
65
+ 318,LA
66
+ 319,IA
67
+ 320,MN
68
+ 321,FL
69
+ 323,CA
70
+ 325,TX
71
+ 330,OH
72
+ 334,AL
73
+ 336,NC
74
+ 337,LA
75
+ 339,MA
76
+ 340,USVI
77
+ 345,Cayman Islands
78
+ 347,NY
79
+ 351,MA
80
+ 352,FL
81
+ 360,WA
82
+ 361,TX
83
+ 386,FL
84
+ 401,RI
85
+ 402,NE
86
+ 403,AB
87
+ 404,GA
88
+ 405,OK
89
+ 406,MT
90
+ 407,FL
91
+ 408,CA
92
+ 409,TX
93
+ 410,MD
94
+ 412,PA
95
+ 413,MA
96
+ 414,WI
97
+ 415,CA
98
+ 416,ON
99
+ 417,MO
100
+ 418,QC
101
+ 419,OH
102
+ 423,TN
103
+ 424,CA
104
+ 425,WA
105
+ 430,TX
106
+ 432,TX
107
+ 434,VA
108
+ 435,UT
109
+ 438,QC
110
+ 440,OH
111
+ 441,Bermuda
112
+ 443,MD
113
+ 450,QC
114
+ 456,Reserved
115
+ 469,TX
116
+ 473,Grenada
117
+ 478,GA
118
+ 479,AR
119
+ 480,AZ
120
+ 484,PA
121
+ 500,Reserved
122
+ 501,AR
123
+ 502,KY
124
+ 503,OR
125
+ 504,LA
126
+ 505,NM
127
+ 506,NB
128
+ 507,MN
129
+ 508,MA
130
+ 509,WA
131
+ 510,CA
132
+ 512,TX
133
+ 513,OH
134
+ 514,QC
135
+ 515,IA
136
+ 516,NY
137
+ 517,MI
138
+ 518,NY
139
+ 519,ON
140
+ 520,AZ
141
+ 530,CA
142
+ 540,VA
143
+ 541,OR
144
+ 551,NJ
145
+ 559,CA
146
+ 561,FL
147
+ 562,CA
148
+ 563,IA
149
+ 567,OH
150
+ 570,PA
151
+ 571,VA
152
+ 573,MO
153
+ 574,IN
154
+ 580,OK
155
+ 585,NY
156
+ 586,MI
157
+ 600,Reserved
158
+ 601,MS
159
+ 602,AZ
160
+ 603,NH
161
+ 604,BC
162
+ 605,SD
163
+ 606,KY
164
+ 607,NY
165
+ 608,WI
166
+ 609,NJ
167
+ 610,PA
168
+ 612,MN
169
+ 613,ON
170
+ 614,OH
171
+ 615,TN
172
+ 616,MI
173
+ 617,MA
174
+ 618,IL
175
+ 619,CA
176
+ 620,KS
177
+ 623,AZ
178
+ 626,CA
179
+ 630,IL
180
+ 631,NY
181
+ 636,MO
182
+ 641,IA
183
+ 646,NY
184
+ 647,ON
185
+ 649,Turks & Caicos Islands
186
+ 650,CA
187
+ 651,MN
188
+ 660,MO
189
+ 661,CA
190
+ 662,MS
191
+ 664,Montserrat
192
+ 670,MP
193
+ 671,GU
194
+ 678,GA
195
+ 682,TX
196
+ 684,AS
197
+ 700,Reserved
198
+ 701,ND
199
+ 702,NV
200
+ 703,VA
201
+ 704,NC
202
+ 705,ON
203
+ 706,GA
204
+ 707,CA
205
+ 708,IL
206
+ 709,NL
207
+ 710,US Government
208
+ 712,IA
209
+ 713,TX
210
+ 714,CA
211
+ 715,WI
212
+ 716,NY
213
+ 717,PA
214
+ 718,NY
215
+ 719,CO
216
+ 720,CO
217
+ 724,PA
218
+ 727,FL
219
+ 731,TN
220
+ 732,NJ
221
+ 734,MI
222
+ 740,OH
223
+ 754,FL
224
+ 757,VA
225
+ 758,St. Lucia
226
+ 760,CA
227
+ 762,GA
228
+ 763,MN
229
+ 765,IN
230
+ 767,Dominica
231
+ 769,MS
232
+ 770,GA
233
+ 772,FL
234
+ 773,IL
235
+ 774,MA
236
+ 775,NV
237
+ 778,BC
238
+ 780,AB
239
+ 781,MA
240
+ 784,St. Vincent & Grenadines
241
+ 785,KS
242
+ 786,FL
243
+ 787,PR
244
+ 800,Toll Free
245
+ 801,UT
246
+ 802,VT
247
+ 803,SC
248
+ 804,VA
249
+ 805,CA
250
+ 806,TX
251
+ 807,ON
252
+ 808,HI
253
+ 809,Dominican Republic
254
+ 810,MI
255
+ 812,IN
256
+ 813,FL
257
+ 814,PA
258
+ 815,IL
259
+ 816,MO
260
+ 817,TX
261
+ 818,CA
262
+ 819,QC
263
+ 828,NC
264
+ 829,Dominican Republic
265
+ 830,TX
266
+ 831,CA
267
+ 832,TX
268
+ 843,SC
269
+ 845,NY
270
+ 847,IL
271
+ 848,NJ
272
+ 850,FL
273
+ 856,NJ
274
+ 857,MA
275
+ 858,CA
276
+ 859,KY
277
+ 860,CT
278
+ 862,NJ
279
+ 863,FL
280
+ 864,SC
281
+ 865,TN
282
+ 866,Toll Free
283
+ 867,YT
284
+ 868,Trinidad & Tobago
285
+ 869,St. Kitts & Nevis
286
+ 870,AR
287
+ 876,Jamaica
288
+ 877,Toll Free
289
+ 878,PA
290
+ 888,Toll Free
291
+ 900,Toll Calls
292
+ 901,TN
293
+ 902,NS
294
+ 903,TX
295
+ 904,FL
296
+ 905,ON
297
+ 906,MI
298
+ 907,AK
299
+ 908,NJ
300
+ 909,CA
301
+ 910,NC
302
+ 912,GA
303
+ 913,KS
304
+ 914,NY
305
+ 915,TX
306
+ 916,CA
307
+ 917,NY
308
+ 918,OK
309
+ 919,NC
310
+ 920,WI
311
+ 925,CA
312
+ 928,AZ
313
+ 931,TN
314
+ 936,TX
315
+ 937,OH
316
+ 939,PR
317
+ 940,TX
318
+ 941,FL
319
+ 947,MI
320
+ 949,CA
321
+ 951,CA
322
+ 952,MN
323
+ 954,FL
324
+ 956,TX
325
+ 970,CO
326
+ 971,OR
327
+ 972,TX
328
+ 973,NJ
329
+ 978,MA
330
+ 979,TX
331
+ 980,NC
332
+ 985,LA
333
+ 989,MI
@@ -0,0 +1,14 @@
1
+ require 'csv'
2
+
3
+ module Area
4
+ DATA = CSV.read(File.open(File.join(File.dirname(__FILE__), '..', 'data', 'areacodes.csv')))
5
+ end
6
+
7
+ class Integer
8
+ def to_region
9
+ Area::DATA.each do |row|
10
+ r = Regexp.new("#{self}")
11
+ return row[1] if r.match(row[0])
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # Area
2
+
3
+ Hi. This gem allows you to extract a region in the United States from an area code. Area uses public data and does not rely on any external services or have any dependencies.
4
+
5
+ ## Usage
6
+
7
+ In your gemfile: `gem 'area'`
8
+
9
+ In your code: `646.to_region #=> NY`
10
+
11
+ ### Testing and Contributing
12
+
13
+ Contributions are more than welcome. I'm testing with minitest.
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: area
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Vingiano
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This gem lets you find a region by an area code.
15
+ email:
16
+ - jgv@jonathanvingiano.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - data/areacodes.csv
22
+ - lib/area.rb
23
+ - MIT-LICENSE
24
+ - Rakefile
25
+ - readme.md
26
+ homepage: http://github.com/jgv/area
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project: area
46
+ rubygems_version: 1.8.24
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Look up a region by area code.
50
+ test_files: []