Project

zip-codes

0.14
Low commit activity in last 3 years
There's a lot of open issues
A long-lived project that still receives updates
Simple gem to get city, state, and time zone for a given zip code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0.0
~> 1.39.0
~> 0.6.0
 Project Readme

ZipCodes Gem Version

Simple gem to get city, state, and time zone for a given zip code. It has a yaml database bundled with it, so you need several mb of memory for the whole hash.

The gem currently supports only US zip codes. The data origin is https://download.geonames.org/export/zip/

The main maintainer is https://github.com/brodyhoskins

Installation

Add this line to your application's Gemfile:

gem 'zip-codes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zip-codes

Usage

ZipCodes.identify('30301')
# => {:state_code=>"GA", :state_name=>"Georgia", :city=>"Atlanta", :time_zone=>"America/New_York"}
# First run will take a while, as the yaml has to be loaded

If you are using Rails, you can load the hash on app startup for production and staging.

# config/initializers/load_zip_codes.rb
ZipCodes.load unless Rails.env.development?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request