Skip to content

fiyinadebayo/locations_ng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Locations NG CircleCI Gem Version Code Climate Issue Count

Locations NG is a gem that provides methods to get all states, their cities and LGAs in Nigeria.

Requirements

  • Rails version >= 4.2.6

  • Ruby version >= 2.3.1

Getting Started

Add this line to your Gemfile

gem 'locations_ng'

And then execute:

$ bundle install

Or install it yourself

$ gem install locations_ng

Usage

Require the gem

require 'locations_ng'

1. GET all States, canonical

LocationsNg::State.all

Response

[
  {:name=>"Abia", :capital=>"Umuahia"},
  {:name=>"Adamawa", :capital=>"Yola"},
  {:name=>"Akwa Ibom", :capital=>"Uyo"},
  ...
  ...
  {:name=>"Zamfara",:capital=>"Gusau"}
]

2. GET detailed data of a State

LocationsNg::State.details('Lagos')

Response

{'minLat'=>6.3936419,
 'name'=>'Lagos',
 'capital'=>'Ikeja',
 'latitude'=>6.5243793,
 'minLong'=>3.0982732,
 'maxLat'=>6.7027984,
 'longitude'=>3.3792057,
 'maxLong'=>3.696727799999999,
 'alias'=>'lagos',
 'area'=>3345
 'cities'=>['Agege', 'Ikeja'],
 'lgas'=>['Agege', 'Ajeromi-Ifelodun', 'Alimosho',
          'Amuwo-Odofin', 'Badagry', 'Apapa', 'Epe',
          'Eti Osa', 'Ibeju-Lekki', 'Ifako-Ijaiye',
          'Ikeja', 'Ikorodu', 'Kosofe', 'Lagos Island',
          'Mushin', 'Lagos Mainland', 'Ojo', 'Oshodi-Isolo',
          'Shomolu', 'Surulere Lagos State']
}

3. GET State capital

LocationsNg::State.capital('Lagos')

Response

Ikeja

4. GET all Cities

LocationsNg::City.all

Response

[
  {
    "state":"Akwa Ibom",
    "alias":"akwa_ibom",
    "cities":["Eket", "Ikot Ekpene", "Oron", "Uyo"]
  },
  {
    "state":"Bauchi",
    "alias":"bauchi",
    "cities":["Bauchi"]
  },
  ...
  ...
  {
    "state":"Zamfara",
    "alias":"zamfara",
    "cities":["Gusau"]
  }
]

5. GET Cities in a State

LocationsNg::City.cities('Akwa Ibom')

Response

['Eket', 'Ikot Ekpene', 'Oron', 'Uyo']

6. GET all LGAs

LocationsNg::Lga.all

Response

[
  {
    "state"=>"Adamawa",
    "alias"=>"adamawa",
    "lgas"=>[
      "Demsa",
      "Fufure",
      "Ganye",
      "Gayuk",
      "Gombi",
      "Grie",
      "Hong",
      "Jada",
      "Larmurde",
      "Madagali",
      "Maiha",
      "Mayo Belwa",
      "Michika",
      "Mubi North",
      "Mubi South",
      "Numan",
      "Shelleng",
      "Song",
      "Toungo",
      "Yola North",
      "Yola South"
    ]
  },
  ...
  ...
  {
    "state"=>"Abia",
    "alias"=>"abia",
    "lgas"=>[
      "Aba North",
      "Arochukwu",
      "Aba South",
      "Bende",
      "Isiala Ngwa North",
      "Ikwuano",
      "Isiala Ngwa South",
      "Isuikwuato",
      "Obi Ngwa",
      "Ohafia",
      "Osisioma",
      "Ugwunagbo",
      "Ukwa East",
      "Ukwa West",
      "Umuahia North",
      "Umuahia South",
      "Umu Nneochi"
    ]
  }
]

7. GET LGAs in a State

LocationsNg::Lga.lgas('Lagos')

Response

['Agege', 'Ajeromi-Ifelodun', 'Alimosho',
 'Amuwo-Odofin', 'Badagry', 'Apapa', 'Epe',
 'Eti Osa', 'Ibeju-Lekki', 'Ifako-Ijaiye',
 'Ikeja', 'Ikorodu', 'Kosofe', 'Lagos Island',
 'Mushin', 'Lagos Mainland', 'Ojo', 'Oshodi-Isolo',
 'Shomolu', 'Surulere Lagos State']

8. GET Localities for LGAs in a State (query with state and LGA)

LocationsNg::Lga.localities('Abia', 'Aba North')

Response

['Ariaria', 'Asaokpoja', 'Asaokpulor',
 'Eziama  ward', 'Industrial', 'Ogbor 1',
 'Ogbor 2', 'Old GRA', 'Osusu 1', 'Osusu 2',
 'St. Eugene', 'Umuogor', 'Umuola', 'Uratta']

Contributing

  • Fork this repository and clone locally.
  • Create an upstream remote and sync your local copy before you branch.
  • Branch for each separate piece of work.
  • Push to your origin repository.
  • Create a new Pull Request, ensure that the "base fork" points to the correct repository and branch.

License

MIT

About

States, Cities and LGAs in Nigeria.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages