knykode 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler"
12
+ gem "jeweler"
13
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.7)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ git (1.2.5)
8
+ i18n (0.6.0)
9
+ jeweler (1.8.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rdoc
14
+ json (1.7.4)
15
+ multi_json (1.3.6)
16
+ rake (0.9.2.2)
17
+ rdoc (3.12)
18
+ json (~> 1.4)
19
+ shoulda (3.1.1)
20
+ shoulda-context (~> 1.0)
21
+ shoulda-matchers (~> 1.2)
22
+ shoulda-context (1.0.0)
23
+ shoulda-matchers (1.2.0)
24
+ activesupport (>= 3.0.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler
31
+ jeweler
32
+ rdoc (~> 3.12)
33
+ shoulda
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 georgeG
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Introduction
2
+ ===
3
+ This library is a work in progress and aims at providing postal,telephone and other Kenyan common codes.
4
+
5
+ Usage
6
+ ==
7
+ ```ruby
8
+ require 'knykode'
9
+ # working with the postcode class
10
+ posta = Knykode::Postcode.new
11
+
12
+ #get a postcode given a post office name
13
+ puts posta.postcode("Kerugoya") #10300
14
+ puts posta.postcode("Tom Mboya St") #00400
15
+ puts posta.postcode("Ol Butyo") #20229
16
+
17
+ #get postoffice name given a postcode
18
+ puts posta.postoffice('20229') #Ol Butyo
19
+
20
+ #working with the mobile class
21
+ mobile = Knykode::Mobile.new
22
+
23
+ #list an array of available carriers
24
+ puts mobile.carriers.inspect #["Safaricom", "Airtel", "Yu", "Orange", "Telkom"]
25
+
26
+ #list prefix codes for safaricom
27
+ puts mobile.safaricom_prefixes
28
+
29
+ #given a number detect the carrier. Note that international number
30
+ #format(e.g. +254733######) is not recognised at the moment
31
+ puts mobile.detect_carrier('0733######')
32
+
33
+ #get a list of counties
34
+ counties = Knykode::Counties.new
35
+ puts counties.names #an array of county names
36
+ ```
37
+
38
+ License
39
+ ==
40
+ See LICENSE
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "knykode"
18
+ gem.homepage = "http://github.com/georgeG/knykode"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{provides postal,telephone and other common codes in Kenya}
21
+ gem.description = %Q{provides postal,telephone and other common codes in Kenya}
22
+ gem.email = "georgkam@gmail.com"
23
+ gem.authors = ['George Githinji','Njeri Chelimo']
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'spec/**/*_spec.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ #require 'rcov/rcovtask'
36
+ #Rcov::RcovTask.new do |test|
37
+ #test.libs << 'test'
38
+ #test.pattern = 'test/**/test_*.rb'
39
+ #test.verbose = true
40
+ #test.rcov_opts << '--exclude "gems/*"'
41
+ #end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "knykode #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,29 @@
1
+ Bungoma,55
2
+ Eldoret,53
3
+ Embu,68
4
+ Garissa,46
5
+ Homa Bay,59
6
+ Kajiado,23
7
+ Kakamega,56
8
+ Karuri,66
9
+ Kericho,52
10
+ Kisii,58
11
+ Kisumu,57
12
+ Kitale,54
13
+ Kwale,40
14
+ Machakos,44
15
+ Malindi,42
16
+ Marsabit,69
17
+ Meru,64
18
+ Mombasa,41
19
+ Muranga,60
20
+ Nairobi,20
21
+ Naivasha,50
22
+ Nakuru,51
23
+ Nanyuki,62
24
+ Nyahururu,65
25
+ Nyeri,61
26
+ Thika,67
27
+ Voi,43
28
+ Wajir,46
29
+ Wajir,46
@@ -0,0 +1,47 @@
1
+ Baringo
2
+ Bomet
3
+ Bungoma
4
+ Busia
5
+ Elgeyo-Marakwet
6
+ Embu
7
+ Garissa
8
+ Homabay
9
+ Isiolo
10
+ Kajiado
11
+ Kakamega
12
+ Kericho
13
+ Kiambu
14
+ Kilifi
15
+ Kirinyaga
16
+ Kisii
17
+ Kisumu
18
+ Kitui
19
+ Kwale
20
+ Laikipia
21
+ Lamu
22
+ Machakos
23
+ Makueni
24
+ Mandera
25
+ Marsabit
26
+ Meru
27
+ Migori
28
+ Mombasa
29
+ Muranga
30
+ Nairobi
31
+ Nakuru
32
+ Nandi
33
+ Narok
34
+ Nyamira
35
+ Nyandarua
36
+ Nyeri
37
+ Samburu
38
+ Siaya
39
+ Taita-Taveta
40
+ Tana-River
41
+ Tharakanithi
42
+ Trans-Nzoia
43
+ Turkana
44
+ Uasin-Gishu
45
+ Vihiga
46
+ Wajir
47
+ West-Pokot
@@ -0,0 +1,669 @@
1
+ Adungosi,50413
2
+ Agenga,40406
3
+ Ahero,40101
4
+ Ainabkoi,30101
5
+ Akado,40114
6
+ Akala,40139
7
+ Aluor,40140
8
+ Alupe,50414
9
+ Amagoro,50244
10
+ Amukura,50403
11
+ Andingo,40136
12
+ Angurai,50412
13
+ Anyiko,40616
14
+ Anyuongi,40617
15
+ Aram,40618
16
+ Archers Post,60302
17
+ Arror,30708
18
+ Asembo Bay,40619
19
+ Asumbi,40309
20
+ Athi River,00204
21
+ Awach Bridge,40115
22
+ Banja,50316
23
+ Bar Ober,50411
24
+ Baragoi,20601
25
+ Baraton,30306
26
+ Baricho,10302
27
+ Bartabwa,30409
28
+ Bartolimo,30408
29
+ Barwesa,30411
30
+ Bibirioni,00226
31
+ Bissil,01101
32
+ Boito,20409
33
+ Bokoli,50206
34
+ Bomet,20400
35
+ Bondeni,20101
36
+ Bondo,40601
37
+ Boro,40620
38
+ Budalangi,50415
39
+ Bukura,50105
40
+ Bulimbo,50109
41
+ Bumala,50404
42
+ Bumutiru,50418
43
+ Bungoma,50200
44
+ Bunyore,50301
45
+ Bura Tana,70104
46
+ Burnt Forest,30102
47
+ Buru Buru,00515
48
+ Busia,50400
49
+ Butere,50101
50
+ Butula,50405
51
+ Buyofu,50210
52
+ Chamakhanga,50302
53
+ Changamwe,80102
54
+ Chavakali,50317
55
+ Chebara,20138
56
+ Chebiemit,30706
57
+ Cheborge,20215
58
+ Chebororwa,30125
59
+ Chebunyo,20226
60
+ Chemamul,20222
61
+ Chemaner,20407
62
+ Chemase,40143
63
+ Chemelil,40116
64
+ Chemiron,30206
65
+ Chepareria,30605
66
+ Chepchoina,30207
67
+ Chepkemel,20216
68
+ Chepkiswet,20137
69
+ Chepkorio,30129
70
+ Chepkunyuk,30308
71
+ Chepsonoi,30309
72
+ Cheptais,50201
73
+ Cheptalal,20410
74
+ Chepterwai,30121
75
+ Cheptongei,30709
76
+ Chesamisi,50243
77
+ Chesinendet,20217
78
+ Chesoi,30712
79
+ Chogoria,60401
80
+ Chuka,60400
81
+ Chuluni,90219
82
+ Chumvini,80314
83
+ Chwele,50202
84
+ City Square,00200
85
+ Coast Gen Hsp,80103
86
+ Community,00201
87
+ Dadaab,70103
88
+ Dago,40112
89
+ Daraja Mbili,40117
90
+ Dede,40331
91
+ Diani Beach,80401
92
+ Docks,80104
93
+ Dol Dol,10401
94
+ Donyo Sabuk,01027
95
+ Dorofu,50213
96
+ Dudi,40621
97
+ Dundori,20118
98
+ Eastleigh,00610
99
+ Egerton University,20115
100
+ Ekalakala,90139
101
+ El Wak,70301
102
+ Elburgon,20102
103
+ Eldama Ravine,20103
104
+ Eldoret Airport,30124
105
+ Eldoret,30100
106
+ Elementaita,20119
107
+ Elugulu,50429
108
+ Emali,90121
109
+ Emarinda,50110
110
+ Embakasi,00501
111
+ Embu,60100
112
+ Emining,20140
113
+ Emuhaya,50314
114
+ Endarasha,10107
115
+ Endau,90206
116
+ Endebess,30201
117
+ Enosaen,40703
118
+ Enterprise Road,00500
119
+ Equator,30122
120
+ Eregi,50303
121
+ Esso Plaza,00620
122
+ Etago,40208
123
+ Faza,80501
124
+ Fort Ternan,20209
125
+ Funyula,50406
126
+ Gacharageini,10210
127
+ Gachika,00238
128
+ Gachoka,60119
129
+ Gaitu,60209
130
+ Gakere Road,10109
131
+ Gakindu,10111
132
+ Gakoe,01005
133
+ Gakurwe,10211
134
+ Gambogi,50318
135
+ Ganze,80205
136
+ Garba Tulla,60301
137
+ Garissa,70100
138
+ Garsen,80201
139
+ Gatara,10212
140
+ Gatarakwa,10112
141
+ Gathiruini,00239
142
+ Gathugu,00240
143
+ Gathuthi,10113
144
+ Gatitu,10114
145
+ Gatondo,10115
146
+ Gatugura,10305
147
+ Gatukuyu,01028
148
+ Gatundu,01030
149
+ Gatunga,60404
150
+ Gatura,01013
151
+ Gede,80208
152
+ Gembe,40312
153
+ Gesima,40503
154
+ Githunguri,00216
155
+ Gitimene,60212
156
+ Gituamba,01003
157
+ Gitugi,10209
158
+ Gongoni,80206
159
+ Gorgor,20411
160
+ Got Oyaro,40313
161
+ Griftu,70202
162
+ Habaswein,70201
163
+ Hakati,50407
164
+ Hamisi,50312
165
+ Hawinga,40640
166
+ Highridge,00612
167
+ Hola,70101
168
+ Homa Bay,40300
169
+ Huruma,30109
170
+ Ichichi,10227
171
+ Ilasit,00214
172
+ Ileho,50111
173
+ Imanga,50112
174
+ Indechero,50113
175
+ Iriwa,80310
176
+ Ishiara,60102
177
+ Isibania,40414
178
+ Isinya,01102
179
+ Isiolo,60300
180
+ Isulu,50114
181
+ Iten,30700
182
+ Ithanga,01015
183
+ Itibo,40504
184
+ Itumbe,40210
185
+ Jebrok,50319
186
+ Juja Road,00622
187
+ KICC,00203
188
+ Kabarnet,30400
189
+ Kabartonjo,30401
190
+ Kabati,90205
191
+ Kabatini,20120
192
+ Kabazi,20114
193
+ Kabete,00602
194
+ Kabianga,20201
195
+ Kabiemit,30130
196
+ Kabimoi,20139
197
+ Kabiyet,30303
198
+ Kaboson,20412
199
+ Kabula,50214
200
+ Kacheliba,30601
201
+ Kadel,40314
202
+ Kadongo,40223
203
+ Kagicha,10119
204
+ Kagio,10306
205
+ Kagumo,10307
206
+ Kagunduini,01033
207
+ Kagwe,00223
208
+ Kaheho,20304
209
+ Kahuhia,10206
210
+ Kahuro,10201
211
+ Kahuti,10214
212
+ Kaibichbich,30606
213
+ Kaiboi,30310
214
+ Kaimosi,50305
215
+ Kainuk,30604
216
+ Kairi,01007
217
+ Kairo,10215
218
+ Kajiado,01100
219
+ Kakamega,50100
220
+ Kakemer,50419
221
+ Kakibora,30216
222
+ Kakoneni,80209
223
+ Kakuma,30501
224
+ Kakunga,50115
225
+ Kakuzi,01014
226
+ Kalamba,90306
227
+ Kalawa,90126
228
+ Kalimoni,01001
229
+ Kalokol,30502
230
+ Kaloleni,80105
231
+ Kamaget,20218
232
+ Kamahuha,10217
233
+ Kamara,20134
234
+ Kamberua,10216
235
+ Kambiri,50116
236
+ Kambiti,10226
237
+ Kamiti,00607
238
+ Kampi Ya Moto,20121
239
+ Kampi Ya Samaki,30406
240
+ Kamukuywa,50216
241
+ Kamuriai,50408
242
+ Kamuwongo,90403
243
+ Kamwaura,20132
244
+ Kamwosor,30113
245
+ Kanam,40315
246
+ Kandara,01034
247
+ Kanyoni,01011
248
+ Kanyuambora,60106
249
+ Kanziko,90208
250
+ Kapcheno,30304
251
+ Kapcherany,20413
252
+ Kapcherop,30204
253
+ Kapchorwa,30311
254
+ Kapedo,30410
255
+ Kapenguria,30600
256
+ Kapkateny,50232
257
+ Kapkatet,20214
258
+ Kapkelek,20219
259
+ Kapkenda,30119
260
+ Kapkesosio,20414
261
+ Kapkoros,20415
262
+ Kerugoya,10300
263
+ Laare,60601
264
+ Laboret,30126
265
+ Labuiywo,40144
266
+ Ladhri Awasi,40122
267
+ Lamu,80500
268
+ Lamuria,10139
269
+ Lanet,20112
270
+ Langas,30112
271
+ Langata,00509
272
+ Lavington,00603
273
+ Lela,40134
274
+ Lengita,20506
275
+ Leseru,30115
276
+ Leshau,20310
277
+ Lessos,30302
278
+ Likoni,80110
279
+ Limuru,00217
280
+ Lita,90109
281
+ Lodwar,30500
282
+ Loitokitok,00209
283
+ Loiyangalani,60501
284
+ Lokichar,30505
285
+ Lokichoggio,30503
286
+ Lokitaung,30504
287
+ Lokori,30506
288
+ Lolgorian,40701
289
+ Lolwe,40128
290
+ Londiani,20203
291
+ Longisa,20402
292
+ Longonot,20146
293
+ Lorugum,30507
294
+ Lower Kabete,00604
295
+ Luanda,50307
296
+ Luandanyi,50219
297
+ Luandeti,50240
298
+ Lugari,50108
299
+ Lugingo,40622
300
+ Lugulu,50218
301
+ Luhano,40623
302
+ Lukolis,50421
303
+ Lukore,80408
304
+ Lukume,50132
305
+ Lukusi,50230
306
+ Lumakanda,50242
307
+ Lunga Lunga,80402
308
+ Lunza,50119
309
+ Lurambi,50120
310
+ Lusingeti,00905
311
+ Lusiola,50320
312
+ Lutaso,50121
313
+ Lwakhakha,50220
314
+ Maai Mahiu,20147
315
+ Mabusi,50235
316
+ Machakos,90100
317
+ Madaraka,01002
318
+ Madeya,40641
319
+ Madiany,40613
320
+ Madina,80207
321
+ Magada,50321
322
+ Magadi,00205
323
+ Mageta,40624
324
+ Mago,50325
325
+ Magombo,40507
326
+ Magumoni,60403
327
+ Magunga,40307
328
+ Magutuni,60407
329
+ Magwagwa,40508
330
+ Mahanga,50322
331
+ Maiella,20148
332
+ Mairo Inya,20314
333
+ Maji Mazuri,20145
334
+ Makimeny,20228
335
+ Makindu,90138
336
+ Makongeni,00510
337
+ Maktau,80315
338
+ Makueni,90300
339
+ Makumbi,20149
340
+ Makunga,50133
341
+ Makupa,80112
342
+ Makutano,20141
343
+ Makuyu,01020
344
+ Malaha,50122
345
+ Malakisi,50209
346
+ Malava,50103
347
+ Maliki,50221
348
+ Malindi,80200
349
+ Malinya,50123
350
+ Mandera,70300
351
+ Manga,40509
352
+ Manyani,80301
353
+ Manyatta,60101
354
+ Manyuanda,40625
355
+ Manyulia,50126
356
+ Maragi,10221
357
+ Maragoli,50300
358
+ Maragua,10205
359
+ Maralal,20600
360
+ Marani,40214
361
+ Mariakani,80113
362
+ Marigat,30403
363
+ Marima,60408
364
+ Marimanti,60215
365
+ Marinde,40318
366
+ Mariwa,40408
367
+ Marmanet,20322
368
+ Marsabit,60500
369
+ Marua,10127
370
+ Masana,50324
371
+ Maseno,40105
372
+ Mashini,80312
373
+ Mashuru,01103
374
+ Masii,90101
375
+ Masimba,40215
376
+ Masinga,90141
377
+ Mataara,1009
378
+ Nairage Enkare,20504
379
+ Nairobi GPO,00100
380
+ Naishi,20142
381
+ Naitiri,50211
382
+ Naivasha,20117
383
+ Nakuru,20100
384
+ Nalondo,50227
385
+ Namanga,00207
386
+ Nambacha,50127
387
+ Nambale,50409
388
+ Namorio,50231
389
+ Nandi Hills,30301
390
+ Nandolia,50228
391
+ Nangili,50239
392
+ Nango,40615
393
+ Nanyuki,10400
394
+ Naro Moru,10105
395
+ Naro Sura,20505
396
+ Narok,20500
397
+ Ndakaini,01025
398
+ Ndalani,90118
399
+ Ndalat,30123
400
+ Ndalu,30219
401
+ Ndanai,20404
402
+ Ndaragwa,20306
403
+ Ndaraweta,20420
404
+ Ndenderu,00230
405
+ Ndere,40629
406
+ Nderu,00229
407
+ Ndhiwa,40302
408
+ Ndigwa,40630
409
+ Ndiru,40321
410
+ Ndithini,01016
411
+ Ndiyisi,50229
412
+ Ndooa,90202
413
+ Ndori,40602
414
+ Ndunyu Njeru,20317
415
+ Ngambwa,80311
416
+ Nganduri,60115
417
+ Ngano,20308
418
+ Ngara Rd,00600
419
+ Ngarua,20328
420
+ Ngecha,00218
421
+ Ngelesha,20324
422
+ Ngewa,00901
423
+ Nginyang,30404
424
+ Ngiya,40603
425
+ Ngoliba,01012
426
+ Ngonda,10229
427
+ Ngong Hills,00208
428
+ Ngong Rd,00505
429
+ Ngorika,20126
430
+ Ngorongo,00225
431
+ Nguni,90407
432
+ Nguyoini,10224
433
+ Ngwata,90129
434
+ Njipiship,40702
435
+ Njoro,20107
436
+ Nkondi,60214
437
+ Nkubu,60202
438
+ North Kinangop,20154
439
+ Ntimaru,40417
440
+ Nunguni,90130
441
+ Nuu,90408
442
+ Nyabondo,40124
443
+ Nyaburi,40322
444
+ Nyacheki,40217
445
+ Nyadorera,40631
446
+ Nyahururu,20300
447
+ Nyakwere,40125
448
+ Nyali,80118
449
+ Nyamache,40203
450
+ Nyamarambe,40206
451
+ Nyambunwa,40205
452
+ Nyamira,40500
453
+ Nyamonye,40632
454
+ Nyamtiro,40419
455
+ Nyangande,40126
456
+ Nyangori,40127
457
+ Nyangusu,40218
458
+ Nyangweso,40311
459
+ Nyansiongo,40502
460
+ Nyanturago,40219
461
+ Nyaramba,40514
462
+ Nyaru,30131
463
+ Nyatike,40402
464
+ Nyawara,40633
465
+ Nyayo Stadium,00506
466
+ Nyeri,10100
467
+ Nyilima,40611
468
+ Nzeeka,90136
469
+ Nziu,90308
470
+ Nzoia,50237
471
+ Obekai,50427
472
+ Oboch,40129
473
+ Ogembo,40204
474
+ Ogen,40130
475
+ Ogongo,40323
476
+ Okia,90301
477
+ Ol Butyo,20229
478
+ Ol Joro Orok,20302
479
+ Ol Kalou,20303
480
+ Olenguruone,20152
481
+ Olkurto,20502
482
+ Olololunga,20503
483
+ Oloomirani,20507
484
+ Oltepesi,00213
485
+ Omboga,40306
486
+ Omogonchoro,40221
487
+ Ongata Rongai,00511
488
+ Oriang,40227
489
+ Ortum,30602
490
+ Otaro,40324
491
+ Othaya,10106
492
+ Othoch Rakuom,40411
493
+ Othoro,40224
494
+ Otonglo,40108
495
+ Oyugis,40222
496
+ Pala,40329
497
+ Pap Onditi,40111
498
+ Parklands,00623
499
+ Passenga,20311
500
+ Paw Akuche,40131
501
+ Pembe Tatu,40113
502
+ Plateau,30116
503
+ Port Victoria,50410
504
+ Quarry Road,00624
505
+ Rabuor,40132
506
+ Racecourse Road,00617
507
+ Ragengni,40604
508
+ Rakwaro,40325
509
+ Ramba,40330
510
+ Ramula,40142
511
+ Ranen,40412
512
+ Rangala,40634
513
+ Rangwe,40303
514
+ Rapogi,40403
515
+ Ratta,40137
516
+ Reru,40133
517
+ Rhamu,70302
518
+ Rigoma,40511
519
+ Ringa,40226
520
+ Riochanda,40512
521
+ Riosiri,40220
522
+ Riruta,00512
523
+ Rodi Kopany,40326
524
+ Ronald Ngala St,00300
525
+ Ronda,20127
526
+ Rongai,20108
527
+ Rongo,40404
528
+ Roret,20204
529
+ Ruaraka,00618
530
+ Ruiru,00232
531
+ Rumuruti,20321
532
+ Runyenjes,60103
533
+ Ruri,20313
534
+ Ruringu,10133
535
+ Rusinga,40327
536
+ Ruthangati,10134
537
+ Saba Saba,10208
538
+ Sabatia,20143
539
+ Saboti,30211
540
+ Sagalla,80308
541
+ Sagana,10230
542
+ Samburu,80120
543
+ Samitsi,50128
544
+ Sare,40405
545
+ Sarit Centre,00606
546
+ Sasumua Road,00513
547
+ Sawagongo,40612
548
+ Sega,40614
549
+ Serem,50308
550
+ Seretunin,30407
551
+ Shabaab,20150
552
+ Shianda,50106
553
+ Shiatsala,50129
554
+ Shibuli,50130
555
+ Shimanyiro,50131
556
+ Shimba Hills,80407
557
+ Shinyalu,50107
558
+ Siakago,60104
559
+ Siaya,40600
560
+ Sidindi,40605
561
+ Sifuyo,40643
562
+ Sigomre,40635
563
+ Sigor,20405
564
+ Sigoti,40135
565
+ Sigowet,20212
566
+ Sikinwa,30217
567
+ Silibwet,20422
568
+ Simat,30127
569
+ Sindo,40308
570
+ Singore,30703
571
+ Sio Port,50401
572
+ Siongiroi,20230
573
+ Sipili,20326
574
+ Sirembe,40636
575
+ Sirende,30213
576
+ Sirisia,50208
577
+ Sirongo,40642
578
+ Solai,20128
579
+ Sololo,60701
580
+ Sondu,40109
581
+ Songhor,40110
582
+ Sorget,20223
583
+ Sosiot,20205
584
+ Sotik,20227
585
+ South Horr,20604
586
+ South Kinangop,20155
587
+ Soy,30105
588
+ Suba Kuria,40418
589
+ Subukia,20109
590
+ Suguta Mar Mar,20602
591
+ Sulmac,20151
592
+ Sultan Hamud,90132
593
+ Suna,40400
594
+ Suwerwa,30212
595
+ Tabani,30220
596
+ Tala,90131
597
+ Tambach,30704
598
+ Tarasaa,80203
599
+ Tausa,80309
600
+ Taveta,80302
601
+ Tawa,90133
602
+ Tenges,30405
603
+ Thaara,10110
604
+ Thangathi,10135
605
+ Thare,01026
606
+ Thigio,00210
607
+ Thika,01000
608
+ Tigiji,60210
609
+ Timau,10402
610
+ Timber Mill Rd,20110
611
+ Timboroa,30108
612
+ Tiriki,50309
613
+ Tom Mboya St,00400
614
+ Tombe,40513
615
+ Tongaren,30218
616
+ Torongo,20153
617
+ Tot,30707
618
+ Tseikuru,90409
619
+ Tulia,90203
620
+ Tumu Tumu,10136
621
+ Tunyai,60213
622
+ Turbo,30106
623
+ Turi,20129
624
+ Uaso Nyiro,10137
625
+ Ugunja,40606
626
+ Uhuru Gardens,00000
627
+ Ukunda,80400
628
+ Ukwala,40607
629
+ Uplands,00222
630
+ Uranga,40608
631
+ Uriri,40228
632
+ Usenge,40609
633
+ Usigu,40637
634
+ Uthiru,00605
635
+ Valley Arcade,00514
636
+ Vihiga,50310
637
+ Village Market,00621
638
+ Vipingo,80119
639
+ Vitengeni,80211
640
+ Viwandani,00507
641
+ Voi,80300
642
+ Voo,90212
643
+ Wagusu,40638
644
+ Waithaka,00613
645
+ Wajir,70200
646
+ Wamagana,10138
647
+ Wamba,20603
648
+ Wamunyu,90103
649
+ Wamwangi,01010
650
+ Wangige,00614
651
+ Wanguru,10303
652
+ Wanjengi,10225
653
+ Wanjohi,20305
654
+ Watalii Road,80204
655
+ Watamu,80202
656
+ Webuye,50205
657
+ Weiwei,30603
658
+ Werugha,80303
659
+ Westlands,00800
660
+ Winam,40141
661
+ Witu,80504
662
+ Wiyumiririe,20329
663
+ Wodanga,50311
664
+ Wundanyi,80304
665
+ Yala,40610
666
+ Yaya Towers,00508
667
+ Yoani,90134
668
+ Ziwa,30214
669
+ Zombe,90213
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "knykode"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["George Githinji", "Njeri Chelimo"]
12
+ s.date = "2012-08-13"
13
+ s.description = "provides postal,telephone and other common codes in Kenya"
14
+ s.email = "georgkam@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "data/areacodes.txt",
27
+ "data/counties.txt",
28
+ "data/postcodes.txt",
29
+ "knykode.gemspec",
30
+ "lib/knykode.rb",
31
+ "lib/knykode/counties.rb",
32
+ "lib/knykode/mobile.rb",
33
+ "lib/knykode/parser.rb",
34
+ "lib/knykode/postcode.rb",
35
+ "spec/mobile_spec.rb",
36
+ "spec/postcode_spec.rb"
37
+ ]
38
+ s.homepage = "http://github.com/georgeG/knykode"
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = "1.8.24"
42
+ s.summary = "provides postal,telephone and other common codes in Kenya"
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_development_dependency(%q<bundler>, [">= 0"])
51
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
52
+ else
53
+ s.add_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_dependency(%q<bundler>, [">= 0"])
56
+ s.add_dependency(%q<jeweler>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
+ s.add_dependency(%q<bundler>, [">= 0"])
62
+ s.add_dependency(%q<jeweler>, [">= 0"])
63
+ end
64
+ end
65
+
@@ -0,0 +1,3 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'knykode','postcode')
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'knykode','mobile')
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'knykode','counties')
@@ -0,0 +1,7 @@
1
+ module Knykode
2
+ class Counties
3
+ def names
4
+ codes = Parser.new.read("data/counties.txt").map{|entry|entry.chomp}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,54 @@
1
+ module Knykode
2
+
3
+ class Mobile
4
+ def carriers
5
+ ['Safaricom','Airtel','Yu','Orange','Telkom']
6
+ end
7
+
8
+ #given a phone number determine the carrier
9
+ def detect_carrier(number)
10
+ prefix = number.to_s[0,4] unless number.start_with?('+')
11
+
12
+ case
13
+ when safaricom_prefixes.include?(prefix)
14
+ carrier = 'Safaricom'
15
+
16
+ when yu_prefixes.include?(prefix)
17
+ carrier = 'Yu'
18
+
19
+ when airtel_prefixes.include?(prefix)
20
+ carrier = 'Airtel'
21
+
22
+ when orange_prefixes.include?(prefix)
23
+ carrier = 'Orange'
24
+ else
25
+ carrier = 'unrecognized format'
26
+
27
+ end
28
+ carrier
29
+ end
30
+
31
+ def safaricom_prefixes
32
+ ['0700','0701','0702','0703','0704','0705','0706','0707','0708','0709','0710',
33
+ '0711','0712','0713','0714','0715','0716','0717','0718','0719','0720','0721',
34
+ '0722','0723','0724','0725','0726','0728','0729']
35
+ end
36
+
37
+ def airtel_prefixes
38
+ ['0730','0731','0732','0733','0734','0735','0746','0737','0738','0739']
39
+ end
40
+
41
+ def yu_prefixes
42
+ ['0750','0751','0752','0753','0754','0755']
43
+ end
44
+
45
+ def orange_prefixes
46
+ ['0770','0772','0773','0774','0775']
47
+ end
48
+
49
+ private
50
+ def prefix_str(arr)
51
+ arr.join(',')
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ class Parser
2
+ def read(file)
3
+ IO.readlines(file)
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ module Knykode
2
+
3
+ require_relative 'parser'
4
+
5
+ class Postcode
6
+ def postcodes
7
+ codes = Parser.new.read("data/postcodes.txt").
8
+ map{|entry|entry.chomp}.
9
+ map{|postcode| postcode.
10
+ split(',')}.flatten
11
+ Hash[*codes]
12
+ end
13
+
14
+ def postcode(postoffice)
15
+ check_nil(postcodes[postoffice])
16
+ end
17
+
18
+ def postoffice(postcode)
19
+ check_nil(postcodes.invert[postcode])
20
+ end
21
+
22
+ def number_of_postoffices
23
+ postcodes.size
24
+ end
25
+
26
+ #returns an array of all post-offices in the record.
27
+ def postoffices
28
+ postcodes.keys.sort
29
+ end
30
+
31
+ #Returns a YML formated output of all the postcodes and postoffices
32
+ def yml_output
33
+ postcodes.to_yaml
34
+ end
35
+
36
+ private
37
+ def check_nil(value)
38
+ value || "unknown"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ #mobile = Knykode::Mobile.new
2
+
3
+ #list an array of available carriers
4
+ #puts mobile.carriers #["Safaricom", "Airtel", "Yu", "Orange", "Telkom"]
5
+
6
+ #list prefix codes for safaricom
7
+ #puts mobile.safaricom_prefixes
8
+
9
+ #given a number detect the carrier
10
+ #puts mobile.detect_carrier('0733######')
11
+
12
+ #get a list of counties
13
+ #counties = Knykode::Counties.new
14
+ #puts counties.names #an array of county names
@@ -0,0 +1,19 @@
1
+ require 'knykode/postcode'
2
+
3
+ describe Postcode do
4
+ before(:each) do
5
+ @postcode = Knykode::Postcode.new
6
+ end
7
+
8
+ end
9
+
10
+ # working with the postcode class
11
+ #posta = Knykode::Postcode.new
12
+
13
+ #get a postcode given a post office name
14
+ #puts posta.postcode("Kerugoya") #10300
15
+ #puts posta.postcode("Tom Mboya St") #00400
16
+ #puts posta.postcode("Ol Butyo") #20229
17
+
18
+ #get postoffice name given a postcode
19
+ #puts posta.postoffice('20229') #Ol Butyo
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knykode
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - George Githinji
9
+ - Njeri Chelimo
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-08-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shoulda
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rdoc
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '3.12'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '3.12'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: jeweler
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: provides postal,telephone and other common codes in Kenya
80
+ email: georgkam@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files:
84
+ - LICENSE
85
+ - README.md
86
+ files:
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE
90
+ - README.md
91
+ - Rakefile
92
+ - VERSION
93
+ - data/areacodes.txt
94
+ - data/counties.txt
95
+ - data/postcodes.txt
96
+ - knykode.gemspec
97
+ - lib/knykode.rb
98
+ - lib/knykode/counties.rb
99
+ - lib/knykode/mobile.rb
100
+ - lib/knykode/parser.rb
101
+ - lib/knykode/postcode.rb
102
+ - spec/mobile_spec.rb
103
+ - spec/postcode_spec.rb
104
+ homepage: http://github.com/georgeG/knykode
105
+ licenses:
106
+ - MIT
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
118
+ - 0
119
+ hash: -1137196966615017639
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 1.8.24
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: provides postal,telephone and other common codes in Kenya
132
+ test_files: []