0.0
The project is in a healthy, maintained state
Stores FIPS codes for US States and Counties
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
~> 13.0
~> 3.2
~> 1.21
~> 0.2
~> 3.0

Runtime

~> 2.0
~> 2.8
 Project Readme

FIPS Lookup

fips_lookup is a ruby gem that functions as a lookup for U.S. states, counties, and county subdivisions using Census FIPS identifiers and names.

Lookup results are hashes containing the fields for the requested geography. Lookup data is stored in a bundled SQLite database and queried read-only at runtime.

Installation

Add the gem to your application's Gemfile:

gem "fips_lookup"

Then run bundle install

What version is right for you?

fips_lookup >= 1.0 - SQLite database, with indexed lookups, zeitwerk, lightning fast lookups, more infrastructure required to run SQLite

fips lookup < 1.0 - CSV memoization and indexed lookup, lightweight, zeitwerk compatible,

Usage

Require the gem if your application does not use Bundler's automatic loading:

require "fips"

Examples in Gist

Check out this RunRuby.dev gist of examples of how to use the gem, and what parameters are available FIPS examples

Source data

The raw and intermediate CSV datasets are retained under source_data/ for rebuilding and auditing. They are development inputs, are not used at runtime, and are not included in the published gem. Runtime lookups and collection methods use the bundled SQLite database.

Database build

The checked-in schema is in db/schema.sql. The bundled database is built from the 2020 Census county and county-subdivision source files. To rebuild it from the source text files and state data, run:

bundle exec ruby bin/db/build

Errors

Malformed or insufficient inputs raise ArgumentError. Validly formatted identifiers that do not match a record raise FIPS::NotFoundError, a subclass of StandardError:

begin
  FIPS::County.lookup(fips: "02999")
rescue FIPS::NotFoundError => error
  warn error.message
end

Development

Install dependencies with bin/setup. Run tests and lint with:

bundle exec rspec
bundle exec rubocop

Open an IRB console with bin/console. Install locally with bundle exec rake install.

Contributing

Bug reports and pull requests are welcome in the FIPS repository. Contributors are expected to follow the Code of Conduct.

License

This gem is available under the terms of the MIT License. See LICENSE.txt.