Identify city and state for given zip code
Ruby
Pull request Compare This branch is 16 commits behind monterail:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
zip-codes.gemspec

README.md

ZipCodes

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

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"}
# First run will take while, as yaml has to be loaded

If you are using Rails, you can load 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