{"id":13513562,"url":"https://github.com/ianks/mini_phone","last_synced_at":"2025-05-15T20:04:34.505Z","repository":{"id":45768837,"uuid":"324084921","full_name":"ianks/mini_phone","owner":"ianks","description":"A fast phone number parser, validator and formatter for Ruby. This gem binds to Google's C++ libphonenumber for spec-compliance and performance.","archived":false,"fork":false,"pushed_at":"2024-11-14T19:41:47.000Z","size":160,"stargazers_count":159,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-10T05:36:34.689Z","etag":null,"topics":["libphonenumber","phone","phone-number","phonelib","phonenumber","ruby","telephone"],"latest_commit_sha":null,"homepage":"","language":"C++","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/ianks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":["ianks"]}},"created_at":"2020-12-24T06:33:23.000Z","updated_at":"2025-04-23T13:33:48.000Z","dependencies_parsed_at":"2024-01-13T19:23:37.470Z","dependency_job_id":"9d929f29-6660-4358-be44-13cbfc3b4954","html_url":"https://github.com/ianks/mini_phone","commit_stats":{"total_commits":104,"total_committers":4,"mean_commits":26.0,"dds":"0.038461538461538436","last_synced_commit":"10a43050d79be852d21fb05e3e8040211e544358"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianks%2Fmini_phone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianks%2Fmini_phone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianks%2Fmini_phone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianks%2Fmini_phone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ianks","download_url":"https://codeload.github.com/ianks/mini_phone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414499,"owners_count":22067272,"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","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":["libphonenumber","phone","phone-number","phonelib","phonenumber","ruby","telephone"],"created_at":"2024-08-01T05:00:31.410Z","updated_at":"2025-05-15T20:04:33.041Z","avatar_url":"https://github.com/ianks.png","language":"C++","readme":"# MiniPhone\n\nA Ruby gem which plugs directly into Google's native C++\n[libphonenumber](https://github.com/google/libphonenumber) for extremely\n_fast_ and _robust_ phone number parsing, validation, and formatting. On\naverage, most methods are 70x to 80x faster than other Ruby phone number\nlibraries.\n\n## Usage\n\n### Checking if a phone number is valid\n\n```ruby\nMiniPhone.valid?('+14043841399')                     # true\nMiniPhone.valid_for_country?('(404) 384-1399', 'US') # true\nMiniPhone.valid_for_country?('(404) 384-1399', 'GB') # false\n```\n\n### Formatting a number\n\n```ruby\nMiniPhone.default_country = 'US'\n\nphone_number = MiniPhone.parse('404-384-1399')\n\nphone_number.e164                 # +14043841399\nphone_number.national             # (404) 384-1399\nphone_number.raw_national         # 4043841399\nphone_number.dasherized_national  # 404-384-1399\nphone_number.international        # +1 404-384-1399\nphone_number.rfc3966              # tel:+1-404-384-1384\n```\n\n### Checking if a phone number is possible\n\n```ruby\nphone_number = MiniPhone.parse('-12')\n\nphone_number.possible? # false\n```\n\n### Getting the type of a phone number\n\n```ruby\nMiniPhone.parse('+12423570000').type # :mobile\nMiniPhone.parse('+12423651234').type # :fixed_line\n```\n\nThe possible types are directly mapped from [this\nenum](https://github.com/google/libphonenumber/blob/4e9954edea7cf263532c5dd3861a801104c3f012/cpp/src/phonenumbers/phonenumberutil.h#L91):\n\n```ruby\n:fixed_line\n:mobile\n:fixed_line_or_mobile\n:toll_free\n:premium_rate\n:shared_cost\n:voip\n:personal_number\n:pager\n:uan\n:voicemail\n:unknown\n```\n\n## Compatibility with PhoneLib\n\nMiniPhone aims to be compatible with\n[Phonelib](https://github.com/daddyz/phonelib). In many cases it can be a\ndrop in replacement. It has a smaller feature set, so it is not a\nreplacement for every use case. If there is a feature you need, open\nan issue and we will try to support it.\n\n## Benchmarks\n\nOn average, most methods are 40x to 50x faster than other libraries. To run\nthe benchmarks locally, execute: `bundle exec rake bench`\n\n### Results from my Linux (5.10.6-arch1-10)\n\n```\nComparison:\n   MiniPhone:    valid?:    33382.0 i/s\n    Phonelib:    valid?:      422.8 i/s - 78.95x  (± 0.00) slower\nTelephoneNumber: valid?:      164.3 i/s - 203.13x  (± 0.00) slower\n\nComparison:\n     MiniPhone:  e164:    41187.5 i/s\n      Phonelib:  e164:      579.0 i/s - 71.14x  (± 0.00) slower\nTelephoneNumber: e164:      228.8 i/s - 179.99x  (± 0.00) slower\n```\n\n## Installation\n\n1. Install libphonenumber\n\n   ```sh\n   brew install libphonenumber # mac\n   ```\n\n   ```sh\n   apt-get install -y libphonenumber-dev # debian / ubuntu\n   ```\n\n2. Add this line to your application's Gemfile:\n\n   ```ruby\n   gem 'mini_phone'\n   ```\n\n3. And then execute:\n\n   ```sh\n   bundle install\n   ```\n\n   Or install it yourself as:\n\n   ```sh\n   gem install mini_phone\n   ```\n\n### Installation on Heroku\n\n1. In addition to the steps above add the [apt buildpack](https://github.com/heroku/heroku-buildpack-apt) to your Heroku app:\n\n   ```sh\n   heroku buildpacks:add --index 1 heroku-community/apt\n   ```\n\n2. Create Aptfile in your repo with the following content:\n   \n   ```\n   libphonenumber-dev\n   ```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then,\nrun `rake spec` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\nTo release a new version, update the version number in `version.rb`, and then\nrun `bundle exec rake release`, which will create a git tag for the version,\npush git commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/ianks/mini_phone. This project is intended to be a\nsafe, welcoming space for collaboration, and contributors are expected to\nadhere to the [code of\nconduct](https://github.com/ianks/mini_phone/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT\nLicense](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the MiniPhone project's codebases, issue trackers,\nchat rooms and mailing lists is expected to follow the [code of\nconduct](https://github.com/ianks/mini_phone/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":["https://github.com/sponsors/ianks"],"categories":["C++","\u003ca name=\"cpp\"\u003e\u003c/a\u003eC++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianks%2Fmini_phone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianks%2Fmini_phone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianks%2Fmini_phone/lists"}