Project

geolist

0.0
No commit activity in last 3 years
No release in over 3 years
Useful to make forms and validations. It uses MaxMind database.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

 Project Readme

GeoList is a very simple ruby gem to get a list of all countries, cities and suburbs.

Install

gem 'geolist', '~> 0.1.0'

Examples

List of countries:

GeoList.countries
# [{:name=>"Australia", :alpha2=>"AU", :alpha3=>"AUS"}, ...]

List of cities:

GeoList.cities('Australia')
# => ["Adak", "Akhiok", "Akiachak", "Akiak", "Akutan", "Alakanuk", ...]

List of suburbs (only for Hong Kong):

GeoList.suburbs('Hong Kong')
# ["Aberdeen", "Causeway Bay", "Central District","Cha Kwo Ling", "Chai Wan Kok", "Chek Chue", ...]

Simplified syntax with get method:

  • GeoList.get: list of countries (equivalent to GeoList.countries)
  • GeoList.get(country): list of cities (equivalent to GeoList.cities(country))
  • GeoList.get(country, city): list of suburbs (equivalent to GeoList.suburbs(city))

Geo data update

GeoList.update_data

# Will update data file to the latest version (using MaxMind free databases)
# Can be added to migration or in some scheduler

# Database is updated weekly, every Tuesday.