{"id":15386930,"url":"https://github.com/joallard/ca-postal-code","last_synced_at":"2025-07-22T23:02:34.457Z","repository":{"id":31812559,"uuid":"128999667","full_name":"joallard/ca-postal-code","owner":"joallard","description":"A toolbox for Canadian postal codes: validating, normalizing and guessing their region.","archived":false,"fork":false,"pushed_at":"2023-03-08T18:15:30.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T04:37:15.858Z","etag":null,"topics":["canada","canada-post","postalcode","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/joallard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-04-10T21:57:51.000Z","updated_at":"2025-01-19T15:30:14.000Z","dependencies_parsed_at":"2022-08-07T16:31:09.126Z","dependency_job_id":"c4312bf4-b20d-451c-9c06-fc231c1bac24","html_url":"https://github.com/joallard/ca-postal-code","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"25842db0a3d7527217fbb01e7cdb80f77f4f513d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/joallard/ca-postal-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joallard%2Fca-postal-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joallard%2Fca-postal-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joallard%2Fca-postal-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joallard%2Fca-postal-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joallard","download_url":"https://codeload.github.com/joallard/ca-postal-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joallard%2Fca-postal-code/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266586840,"owners_count":23952200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["canada","canada-post","postalcode","ruby"],"created_at":"2024-10-01T14:50:48.331Z","updated_at":"2025-07-22T23:02:34.409Z","avatar_url":"https://github.com/joallard.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CAPostalCode\nA toolbox for Canadian postal codes: validating, normalizing and guessing their region.\n\n```ruby\nCAPostalCode.valid?(\"h1b2p3\")\n# =\u003e true\n\nCAPostalCode.normalize(\"e3b.4k5 \")\n# =\u003e \"E3B 4K5\"\n\nCAPostalCode.guess_region(\"K1A 0B3\")\n# =\u003e \"ON\"\n\nCAPostalCode.guess_region(\"X0C 1A1\")\n# =\u003e \"NU\"\n```\n\n## Usage\n### Validity\nAfter normalizing the string, verifies if it fits the format for a postal code.\n\nStrings containing letters D, F, I, O, Q, and those starting with W or Z are invalid.\n```ruby\nCAPostalCode.valid?(\"h1b2p3\")\n# =\u003e true\n\nCAPostalCode.valid?(\"F8G 1A1\")\n# =\u003e false\n\nCAPostalCode.valid?(\"potato\")\n# =\u003e false\n\nCAPostalCode.valid?(\"P0T 4T0\")\n# =\u003e true\n```\n\n### Normalization\nNormalize the string to look like a postal code.\n\nIt does not check for validity. Rather, the `.valid?` method relies on this one to make its work easier.\n\n```ruby\nCAPostalCode.normalize(\"e3b.4k5 \")\n# =\u003e \"E3B 4K5\"\n\nCAPostalCode.normalize(\"g1c 4z9\")\n# =\u003e \"G1C 4Z9\"\n\nCAPostalCode.normalize(\"potato\")\n# =\u003e \"POT ATO\"\n```\n\n### Region guessing\nGuesses the Canadian province or territory (*region*) based on the postal code.\n\nFor provinces and Yukon, it will guess based on the first letter. For Northwest Territories and Nunavut, it will check the first two or three characters.\n\n```ruby\nCAPostalCode.guess_region(\"G1A 1A1\")\n# =\u003e \"QC\"\n\nCAPostalCode.guess_region(\"X0C 1A1\")\n# =\u003e \"NU\"\n\nCAPostalCode.guess_region(\"B6A 1A1\")\n# =\u003e \"NS\"\n```\n\n## Installation\nIn your Gemfile:\n\n    gem \"ca_postal_code\"\n\nOr install it yourself:\n\n    gem install ca_postal_code\n\n## Development\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\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at https://github.com/joallard/ca-postal-code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoallard%2Fca-postal-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoallard%2Fca-postal-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoallard%2Fca-postal-code/lists"}