{"id":15505496,"url":"https://github.com/aldavigdis/postnumer-gem","last_synced_at":"2026-02-20T18:30:48.783Z","repository":{"id":65751021,"uuid":"597559066","full_name":"aldavigdis/postnumer-gem","owner":"aldavigdis","description":"Validate and use Icelandic postal codes with Ruby.","archived":false,"fork":false,"pushed_at":"2024-07-18T11:55:08.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T12:22:17.025Z","etag":null,"topics":["gem","iceland","postal-code","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aldavigdis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"aldavigdis"}},"created_at":"2023-02-04T22:42:30.000Z","updated_at":"2024-07-18T11:55:04.000Z","dependencies_parsed_at":"2024-07-18T13:55:12.802Z","dependency_job_id":null,"html_url":"https://github.com/aldavigdis/postnumer-gem","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"858c35390eb440e93e19171acb8de6740e7c0ec9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aldavigdis/postnumer-gem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldavigdis%2Fpostnumer-gem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldavigdis%2Fpostnumer-gem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldavigdis%2Fpostnumer-gem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldavigdis%2Fpostnumer-gem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aldavigdis","download_url":"https://codeload.github.com/aldavigdis/postnumer-gem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldavigdis%2Fpostnumer-gem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29660018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T16:33:43.953Z","status":"ssl_error","status_checked_at":"2026-02-20T16:33:43.598Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","iceland","postal-code","ruby"],"created_at":"2024-10-02T09:23:41.916Z","updated_at":"2026-02-20T18:30:48.748Z","avatar_url":"https://github.com/aldavigdis.png","language":"Ruby","funding_links":["https://github.com/sponsors/aldavigdis"],"categories":[],"sub_categories":[],"readme":"# Postnumer\n\nThe Postnumer class validates, looks up and associates an Icelandic postal code\nwith its postal locality.\n\nIcelandic postal codes are three numeric digits and may be handled as integers\n(as this gem does internally) or as strings (as you should do in your database).\n\n## What this gem does not and will not do\n\nAs the role of the Icelandic postal code system is to facilitate mail sorting\nand distrubution. This gem will therefore mainly facilitate the validation or\nautocompletion of a pair of postal codes and their assigned localities.\n\nWhat this gem will *not* do is to facilitate the assumtion of other attributes\noften associated with Icelandic postal codes. This means that if you plan to use\npostal codes to assume things such as wether an Icelandic postal code is rural,\nis for a P.O. box, if it is within the Reykjavik Metropolitan Area or which\nadministrative region it belongs to, you should roll your own solution for your\nown application and I wish you good luck in all your future endevours.\n\nThe [author of this gem](https://aldavigdis.is/) will gladly provide a paid\nlecture on the pitfalls of postal addressing and postal code systems in Iceland\nand around the world.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add postnumer\n\nIf bundler is not being used to manage dependencies:\n\n    $ gem install postnumer-gem\n\n## Usage\n\n### Using class methods\n\n```ruby\n# For getting a hash of every Icelandic postal code and its locality,\n# you can use `Postnumer::all` to get a list of every valid postal code:\nPostnumer.all\n=\u003e\n{101=\u003e\"Reykjavík\",\n 102=\u003e\"Reykjavík\",\n 103=\u003e\"Reykjavík\",\n 104=\u003e\"Reykjavík\"}\n\n# `Postnumer.all_options` provides every available postal code in Iceland as an\n# array of arrays:\nPostnumer.all_options\n=\u003e\n[[\"101 Reykjavík\", 101],\n [\"102 Reykjavík\", 102],\n [\"103 Reykjavík\", 103],\n [\"104 Reykjavík\", 104]]\n\n# In Rails, you can use features from the `FormOptionsHelper` such as `select`\n# or `options_for_select` to build a form field from `Postnumer.all_options`.\n\n# In Rails:\nselect('customer', 'postal_code', Postnumer.all_options)\n\n# In Formtastic or ActiveAdmin:\nf.input(:author, :as =\u003e :select,\n                 :collection =\u003e options_for_select(Postnumer::all_options)\n)\n\n# If you just want to validate a postal code, you can do it like so:\nPostnumer.valid?(310)\n=\u003e true\n\n# Numeric strings can also be passed to any method and will be cast internally using `String::to_i`:\n# (You should always store postal codes as strings in your database.)\nPostnumer.valid?(\"101\")\n=\u003e true\n\n# The `Postnumer.valid?` method will return `false` if the provided code is invalid:\nPostnumer.valid?(90210)\n=\u003e false\n\n# The `Postnumer.locality` method will provide the postal locality associated with the postal code:\nPostnumer.locality(310)\n=\u003e \"Borgarnes\"\n\n# The `Postnumer.locality` method will simply return `nil` if the postal code is invalid.\nPostnumer.locality(90210)\n=\u003e nil\n```\n\n### Using an instance of the Postnumer class\n\n```ruby\n# You can initialize an instance of Postnumer by initializing it.\n# Note: Postnumer.new will throw an `ArgumentError` if the postal code is invalid.\npnr = Postnumer.new(310)\n=\u003e #\u003cPostnumer:0x00007fe5f2401958 @code=310, @locality=\"Borgarnes\"\u003e\n\n# Once initialized, the locality can be read by using the `locality` accessor:\npnr.locality\n=\u003e \"Borgarnes\"\n\n# The postal code is also stored in the instance and can be read using the `code` accessor:\npnr.code\n=\u003e 310\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/aldavigdis/postnumer-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/aldavigdis/postnumer-gem/blob/master/CODE_OF_CONDUCT.md).\n\nDon't be afraid of using Rubocop for correcting your code and to make it conform to the standards defined in `.rubocop.yml`. If you need to add an exception, the please do so in your pull request and it will be looked into.\n\nYou will want to run `bundle exec rubocop -A` to see if your code has any errors and correct them on the fly.\n\nAny pull request is welcome. Please write rspec tests for any contributed code if you have the capacity to.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Postnumer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/aldavigdis/postnumer-gem/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldavigdis%2Fpostnumer-gem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldavigdis%2Fpostnumer-gem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldavigdis%2Fpostnumer-gem/lists"}