Postal codes made easy
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
US.txt
postal_codes.dump
postjoy.gemspec

README.md

Postjoy

Postal codes made easy

Get Started

Add this line to your application’s Gemfile:

gem 'postjoy'

Lookup postal code

Postjoy.find(94109)
# =>
{
  city: "San Francisco",
  state: "California",
  state_code: "CA",
  latitude: 37.7917,
  longitude: -122.4186
}

Returns nil if the postal code does not exist

Validations

Also adds validations for Rails

class Address < ActiveRecord::Base
  validates :postal_code, postal_code: true
end

Credit

Data from GeoNames

TODO

  • international postal codes

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To update postal codes, download the updated list from GeoNames to US.txt and run:

rake create