ke_counties 0.0.0 → 0.0.2

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
  SHA256:
3
- metadata.gz: 2137e67183bfc1334eb922f2c29fde54442e0d3e41b808f63680a1aeb8d2991d
4
- data.tar.gz: a28de69649d55d5a29d6853b85b69e001f12c8b610cda1679dcce9079b12a11a
3
+ metadata.gz: cf99fa284a462a4a183fee4c1e3c44ed17818369d8ae108cc36d99c7f2ced9b1
4
+ data.tar.gz: 1d955b1c1955202ece741df81f59dc3842b35b15858af45736119313b0dce3e5
5
5
  SHA512:
6
- metadata.gz: b7213f8e76e78bd35247012ffd30d47fa64324379a202530c1966e1bacb992a87e036872a6f4821b811e72198ddb76ddc43e2f77c5460deb6d713349ea0500f8
7
- data.tar.gz: d6b6120cf8e07c7a22f3e31ff6a53e40cd79674022cbc3c73381966ce25871e6c30f640a0153acfd1efc264322261c83434799c490741a46dcb4ed2902f10566
6
+ metadata.gz: 8965f478c15541c531299ef11f0242bdebfaa59fa75f3e3dfcfceab0aea287e05ca0f20bfb77a94e5a109aa9c884f57327a5a9b04865826c1fc93529a54c5859
7
+ data.tar.gz: ede6c85e6c5ddfb0134c17a5efb5a7da4a858aba8c85b87161ae7436d529c1e853ec3086ad930c06219b141c92cda493ced0336b157d724584341468f2a2a35c
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ ke_counties-*
2
+ Gemfile.lock
data/README.md CHANGED
@@ -1 +1,56 @@
1
- # KE COUNTIES
1
+ ## KE COUNTIES
2
+
3
+ KeCounties is a tiny gem that provides the full list of Kenya county names, their codes, abbreviations and provinces(used popuraly used regions previously before the counties' formation).
4
+
5
+ ### Installation
6
+
7
+ In a Gemfile:
8
+
9
+ ```
10
+ gem 'ke_counties'
11
+ ```
12
+
13
+ Globally in your machine:
14
+
15
+ ```
16
+ gem install 'ke_counties'
17
+ ```
18
+
19
+ ### Usage
20
+
21
+ You can get all the county names with
22
+
23
+ ```
24
+ KeCounties.names
25
+ ```
26
+
27
+ Get all county codes
28
+
29
+ ```
30
+ KeCounties.codes
31
+ ```
32
+ To get the whole hash mapping each county name to its code, abbreviation, province and capital ; use
33
+
34
+ ```
35
+ KeCounties.all
36
+ ```
37
+
38
+ Other methods provides are `.code`, `.abbr`, `.capital`, `.province` which returns the code, abbreviation, capital and province respectively if passed in a capitalized county name. E.g
39
+
40
+ ```
41
+ KeCounties.code('Nakuru') # returns '032'
42
+
43
+ KeCounties.province('Nakuru') # returns 'Rift Valley'
44
+ ```
45
+ List of counties can be found in this [gist](https://gist.github.com/cesswairimu/56902588ed732b1abae2d7372e01f8fc)
46
+
47
+ ### Development
48
+
49
+ - Run `rspec` to run tests
50
+ - To install this gem locally on your machine, run `bundle exec rake install`.
51
+ - To release a new version, update the version number in `lib/version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version. Push your commits and tags and push the gemspec file to rubygems.org
52
+ - Then commit and make a PR to update the code on this repository
53
+
54
+ ### Contributing
55
+
56
+ Bugs reports and pull requests are welcome at https://github.com/cesswairimu/ke_counties
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ke_counties"
5
+
6
+ require "irb"
7
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/ke_counties.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.name = 'ke_counties'
7
7
  s.version = KeCounties::VERSION
8
8
  s.summary = 'Kenya Counties'
9
- s.description = 'Collection of county codes, their names, capitals and provinces'
9
+ s.description = 'Collection of Kenya county names, their codes, capitals, abbreviations and provinces'
10
10
  s.authors = ['cess']
11
11
  s.email = 'cesswairimu@gmail.com'
12
12
  #s.files = ["lib/ke_counties.rb"]
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = ['lib']
22
22
 
23
23
  s.add_development_dependency 'rspec', '~> 3.13.0'
24
- s.add_development_dependency 'rake', '~> 12.3.3'
25
- s.add_development_dependency 'bundler', '~> 13.1.0'
24
+ s.add_development_dependency 'rake', '~> 13.2.0'
25
+ s.add_development_dependency 'bundler', '~> 2.5.7'
26
26
  end
27
27
 
@@ -0,0 +1,80 @@
1
+ module KeCounties
2
+ class Counties
3
+ HASH = { 'Mombasa' => { code: '001', abbrv: 'MSA', capital: "Mombasa", province: 'Coast' },
4
+ 'Kwale' => { code: '002', abbrv: 'KWL', capital: 'Kwale', province: 'Coast' },
5
+ 'Kilifi' => { code: '003', abbrv: 'KLF', capital: 'Kilifi', province: 'Coast' },
6
+ 'Tana River' => { code: '004', abbrv: 'TRV', capital: 'Hola', province: 'Coast' },
7
+ 'Lamu' => { code: '005', abbrv: 'LMU', capital: 'Lamu', province: 'Coast' },
8
+ 'Taita Taveta' => { code: '006', abbrv: 'TVT', capital: 'Wundanyi', province: 'Coast' },
9
+ 'Garissa' => { code: '007', abbrv: 'GRS', capital: 'Garissa', province: 'North Eastern' },
10
+ 'Wajir' => { code: '008', abbrv: 'WJR', capital: 'Wajir', province: 'North Eastern' },
11
+ 'Mandera' => { code: '009', abbrv: 'MDR', capital: 'Mandera', province: 'North Eastern' },
12
+ 'Marsabit' => { code: '010', abbrv: 'MRS', capital: 'Marsabit', province: 'Eastern' },
13
+ 'Isiolo' => { code: '011', abbrv: 'ISL', capital: 'Isiolo', province: 'Eastern' },
14
+ 'Meru' => { code: '012', abbrv: 'MRU', capital: 'Meru', province: 'Eastern' },
15
+ 'Tharaka-Nithi' => { code: '013', abbrv: 'TNT', capital: 'Kathwana', province: 'Eastern' },
16
+ 'Embu' => { code: '014', abbrv: 'EMB', capital: 'Embu', province: 'Eastern' },
17
+ 'Kitui' => { code: '015', abbrv: 'KTU', capital: 'Kitui', province: 'Eastern' },
18
+ 'Machakos' => { code: '016', abbrv: 'MCK', capital: 'Machakos', province: 'Eastern' },
19
+ 'Makueni' => { code: '017', abbrv: 'MKN', capital: 'Wote', province: 'Eastern' },
20
+ 'Nyandarua' => { code: '018', abbrv: 'NDR', capital: 'Ol Kalou', province: 'Central' },
21
+ 'Nyeri' => { code: '019', abbrv: 'NYR', capital: 'Nyeri', province: 'Central' },
22
+ 'Kirinyaga' => { code: '020', abbrv: 'KRG', capital: 'Kerogoya', province: 'Central' },
23
+ "Murang'a" => { code: '021', abbrv: 'MRG', capital: "Murang'a", province: 'Central' },
24
+ 'Kiambu' => { code: '022', abbrv: 'KMB', capital: 'Kiambu', province: 'Central' },
25
+ 'Turkana' => { code: '023', abbrv: 'TRK', capital: 'Lodwar', province: 'Rift Valley' },
26
+ 'West Pokot' => { code: '024', abbrv: 'WPK', capital: 'Kapenguria', province: 'Rift Valley' },
27
+ 'Samburu' => { code: '025', abbrv: 'SBR', capital: 'Maralal', province: 'Rift Valley' },
28
+ 'Trans-Nzoia' => { code: '026', abbrv: 'TNZ', capital: 'Kitale', province: 'Rift Valley' },
29
+ 'Uasin Gishu' => { code: '027', abbrv: 'UGS', capital: 'Eldoret', province: 'Rift Valley' },
30
+ 'Elgeyo-Marakwet' => { code: '028', abbrv: 'EMK', capital: 'Iten', province: 'Rift Valley' },
31
+ 'Nandi' => { code: '029', abbrv: 'NDI', capital: 'Kapsabet', province: 'Rift Valley' },
32
+ 'Baringo' => { code: '030', abbrv: 'BRG', capital: 'Kabarnet', province: 'Rift Valley' },
33
+ 'Laikipia' => { code: '031', abbrv: 'LKP', capital: 'Rumuruti', province: 'Rift Valley' },
34
+ 'Nakuru' => { code: '032', abbrv: 'NKR', capital: 'Nakuru', province: 'Rift Valley' },
35
+ 'Narok' => { code: '033', abbrv: 'NRK', capital: 'Narok', province: 'Rift Valley' },
36
+ 'Kajiado' => { code: '034', abbrv: 'KJD', capital: 'Kajiado', province: 'Rift Valley' },
37
+ 'Kericho' => { code: '035', abbrv: 'KRC', capital: 'Kericho', province: 'Rift Valley' },
38
+ 'Bomet' => { code: '036', abbrv: 'BMT', capital: 'Bomet', province: 'Rift Valley' },
39
+ 'Kakamega' => { code: '037', abbrv: 'KKG', capital: 'Kakamega', province: 'Western' },
40
+ 'Vihiga' => { code: '038', abbrv: 'VHG', capital: 'Mbale', province: 'Western' },
41
+ 'Bungoma' => { code: '039', abbrv: 'BGM', capital: 'Bungoma', province: 'Western' },
42
+ 'Busia' => { code: '040', abbrv: 'BSA', capital: 'Busia', province: 'Western' },
43
+ 'Siaya' => { code: '041', abbrv: 'SYA', capital: 'Siaya', province: 'Nyanza' },
44
+ 'Kisumu' => { code: '042', abbrv: 'KSM', capital: 'Kisumu', province: 'Nyanza' },
45
+ 'Homa Bay' => { code: '043', abbrv: 'HBY', capital: 'Homa Bay', province: 'Nyanza' },
46
+ 'Migori' => { code: '044', abbrv: 'MGR', capital: 'Migori', province: 'Nyanza' },
47
+ 'Kisii' => { code: '045', abbrv: 'KSI', capital: 'Kisii', province: 'Nyanza' },
48
+ 'Nyamira' => { code: '046', abbrv: 'NMR', capital: 'Nyamira', province: 'Nyanza' },
49
+ 'Nairobi' => { code: '047', abbrv: 'NRB', capital: 'Nairobi', province: 'Nairobi' }
50
+ }.freeze
51
+
52
+ def self.all
53
+ HASH
54
+ end
55
+
56
+ def self.names
57
+ HASH.keys
58
+ end
59
+
60
+ def self.code(cty)
61
+ HASH.dig(cty, :code)
62
+ end
63
+
64
+ def self.abbr(cty)
65
+ HASH.dig(cty, :abbrv)
66
+ end
67
+
68
+ def self.capital(cty)
69
+ HASH.dig(cty, :capital)
70
+ end
71
+
72
+ def self.province(cty)
73
+ HASH.dig(cty, :province)
74
+ end
75
+
76
+ def self.content
77
+ HASH.values
78
+ end
79
+ end
80
+ end
@@ -1,3 +1,3 @@
1
1
  module KeCounties
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/ke_counties.rb CHANGED
@@ -1,2 +1,45 @@
1
- require 'ke_counties/version'
2
- require 'ke_counties/counties'
1
+ require_relative 'ke_counties/version'
2
+ require_relative 'ke_counties/counties'
3
+
4
+ module KeCounties
5
+ class << self
6
+
7
+ def all
8
+ counties.all
9
+ end
10
+
11
+ def names
12
+ counties.names
13
+ end
14
+
15
+ def code(cty)
16
+ counties.code(cty)
17
+ end
18
+
19
+ def abbr(cty)
20
+ counties.abbr(cty)
21
+ end
22
+
23
+ def capital(cty)
24
+ counties.capital(cty)
25
+ end
26
+
27
+ def province(cty)
28
+ counties.province(cty)
29
+ end
30
+
31
+ def codes
32
+ counties.content.map{ |i| i[:code]}
33
+ end
34
+
35
+ def abbrvs
36
+ counties.content.map{ |i| i[:abbrv]}
37
+ end
38
+
39
+ private
40
+
41
+ def counties
42
+ KeCounties::Counties
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ke_counties
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - cess
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-28 00:00:00.000000000 Z
11
+ date: 2024-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -30,40 +30,45 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 12.3.3
33
+ version: 13.2.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 12.3.3
40
+ version: 13.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 13.1.0
47
+ version: 2.5.7
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 13.1.0
55
- description: Collection of county codes, their names, capitals and provinces
54
+ version: 2.5.7
55
+ description: Collection of Kenya county names, their codes, capitals, abbreviations
56
+ and provinces
56
57
  email: cesswairimu@gmail.com
57
58
  executables: []
58
59
  extensions: []
59
60
  extra_rdoc_files: []
60
61
  files:
62
+ - ".gitignore"
61
63
  - ".rspec"
62
64
  - Gemfile
63
- - Gemfile.lock
64
65
  - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
65
69
  - ke_counties.gemspec
66
70
  - lib/ke_counties.rb
71
+ - lib/ke_counties/counties.rb
67
72
  - lib/ke_counties/version.rb
68
73
  homepage: https://github.com/cesswairimu/ke_counties
69
74
  licenses:
data/Gemfile.lock DELETED
@@ -1,36 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ke_counties (0.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.5.1)
10
- rake (13.1.0)
11
- rspec (3.13.0)
12
- rspec-core (~> 3.13.0)
13
- rspec-expectations (~> 3.13.0)
14
- rspec-mocks (~> 3.13.0)
15
- rspec-core (3.13.0)
16
- rspec-support (~> 3.13.0)
17
- rspec-expectations (3.13.0)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.13.0)
20
- rspec-mocks (3.13.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.13.0)
23
- rspec-support (3.13.1)
24
-
25
- PLATFORMS
26
- ruby
27
- x86_64-linux
28
-
29
- DEPENDENCIES
30
- bundler (>= 2.5.3)
31
- ke_counties!
32
- rake (>= 12.3.3)
33
- rspec (>= 3.13.0)
34
-
35
- BUNDLED WITH
36
- 2.5.3