Skip to content
CAI
Software that uses CAICheck a score

daddyz/phonelib

66.9

Adequate · 20 September 2026

2.4k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

Phonelib is a Ruby library for parsing, validating, and formatting international phone numbers, built upon Google's libphonenumber data. It provides structured validation with detailed error diagnostics and integrates with Rails via an ActiveModel validator that supports strict type and country constraints. The system includes tools for importing phone metadata and comprehensive test coverage across multiple Rails and Ruby versions.

How it got here

2012 — Phonelib gem initial release

7 changes.

This period marks the initial release of the Phonelib gem, introducing a modular architecture for parsing, validating, and formatting international phone numbers with structured error diagnostics. The work involved migrating the test suite to RSpec, dropping support for older Ruby versions, and replacing legacy static data files with an importer based on Google's libphonenumber.

2013–2026 — validation enhancement and test infrastructure

9 changes.

This period focused on introducing structured error reporting for phone number validation using the Phonelib library, enabling granular diagnostic details. Concurrently, the project established a robust testing framework by migrating to RSpec, adding comprehensive test suites for the dummy Rails application, and configuring CI gemfiles to support a wide range of Ruby and Rails versions.

Features

Added Ruby development and testing shell scripts

New executable scripts have been added to the bin directory to facilitate local development and testing. The bin/console script initializes a Ruby environment with the Phonelib and Pry gems, providing an interactive console for experimentation. The bin/rspec script serves as a Bundler-generated binstub to run the RSpec test suite, ensuring consistent execution context for tests.

bin · high confidence

New phone number validation capability with structured error reporting

The lib/validators directory now includes a new PhoneValidator class that validates phone numbers using the Phonelib library. This validator supports multiple configuration options including enforcing specific phone types (mobile, fixed), restricting valid countries, controlling whether extensions are allowed, requiring explicit international prefixes, and enforcing E.164 format. A key behavioral addition is the support for detailed/structured error reporting via the 'detailed\_errors' option, which provides granular validation failure reasons rather than a single generic error message.

lib/validators · high confidence

Phonelib gem initial release with structured validation and extended data

Phonelib is introduced as a new gem for parsing, validating, and formatting international phone numbers. It provides structured validation diagnostics via a new \validation\ method and \Errors\ collection, replacing simple boolean checks with detailed error reasons (e.g., \:too\_short\, \:invalid\_country\_code\). The library includes an importer to generate phone data from the official libphonenumber repository, supporting extended data for geocoding, timezones, and carriers. Key features include support for vanity number conversion, extension parsing, and configurable parsing behaviors like strict checking and special type parsing.

lib/phonelib · high confidence

Removals

Removed phone\_data.yml

The static phone data file (phone\_data.yml) has been deleted from the repository. This removes the embedded YAML-based phone number metadata and formatting rules from the data directory, likely as part of a migration to a different data source or format.

data · high confidence

Behavioural changes

Drops support for Ruby versions older than 2.0 and migrates test suite to RSpec

The library now requires Ruby 2.0 or later, as indicated by the new .ruby-version file and changelog entry for version 0.6.55. Additionally, the project has migrated its test infrastructure from Rake/Ruby's built-in test unit to RSpec, evidenced by the new .rspec configuration, the switch from Rake::TestTask to RSpec::Core::RakeTask in the Rakefile, and the relocation of test fixtures from the test/ directory to spec/. Documentation generation has also been updated to use YARD instead of RDoc.

(repo-wide) · high confidence

Refactored library structure and added structured validation support

The library has been reorganized into modular components (core, analyzer, formatter, validation) to improve maintainability and support eager loading in Rails applications. A new structured validation system has been introduced, providing detailed error diagnostics via ValidationError and ValidationResult classes, allowing users to access specific validation failure reasons rather than simple boolean results. Additionally, the library now automatically loads I18n locale files if the I18n gem is present and conditionally loads the Rails Railtie only when Rails is detected, ensuring better compatibility and reduced overhead in non-Rails environments.

lib · high confidence

Simplified phone data import task

The \phonelib:import\_data\ rake task has been refactored to delegate the import logic to the \Phonelib::DataImporter\ class, replacing the previous inline implementation that manually parsed XML and wrote YAML. This change removes direct dependencies on \net/http\, \yaml\, and \nokogiri\ within the task file, streamlining the data import process and improving code maintainability.

lib/tasks · high confidence

Structured phone validation errors

Phonelib now returns structured, immutable validation diagnostics instead of simple boolean or string results. The new ValidationError class provides specific error codes (such as invalid\_country\_code, too\_short, or type\_not\_allowed) with associated details, allowing users to programmatically identify exactly why a phone number failed validation. These errors support internationalization via i18n keys and are wrapped in a ValidationResult object that exposes validity status and individual error instances, enabling more precise error handling in applications.

phonelib · high confidence

Test coverage

Added test assets and migrated test suite to RSpec; Added test coverage for Phone model validations; Added test suite and benchmarking infrastructure; Added test suite for Phone resource views and helpers; Added test suite for phone validation in the dummy Rails application; Removed legacy test infrastructure files.

Dependencies

Added CI gemfiles for Rails 3.1–7.0 and Ruby 1.9–2.0

The project now includes dedicated gemfiles for continuous integration testing across a wide range of supported environments. New files have been added for Rails versions 3.1.x through 7.0.x, as well as Ruby 1.9.x and 2.0.x. These gemfiles pin specific versions of dependencies such as rspec-rails, sqlite3, and nokogiri to ensure compatibility and stable test execution across these different framework and language versions.

gemfiles · high confidence

Phonelib gem initialization and dependency setup

The Phonelib gem is initialized with its core specification, including author details, MIT license, and a summary describing it as a phone number validation gem based on Google's libphonenumber. The project sets up its development and runtime dependencies, pinning \json\ to version 2.3.1 and \rack-cache\ to 1.2, while conditionally selecting \nokogiri\ versions based on the Ruby version (e.g., \~\> 1.15 for Ruby \> 2.7). It also includes development tools like \pry\, \rspec\ (pinned to 2.14.1 in the main Gemfile), \simplecov\, and benchmarking libraries (\benchmark-ips\, \benchmark-memory\).

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 67.

Lenses

  • Code Health 98
  • Architecture 100
  • Maturity 69
  • Readiness 70
  • Security 57

Changes since last survey

  • 300 commits — 268 feature/other, 32 fixes

By area

  • (root) — 114 commits
  • data/extended_data.dat — 57 commits
  • lib/phonelib — 56 commits
  • (repo) — 28 commits
  • .circleci/config.yml — 13 commits
  • spec/dummy — 6 commits
  • gemfiles/Gemfile — 5 commits
  • lib/phonelib.rb — 4 commits
  • spec/rails_integration_spec.rb — 4 commits
  • data/phone_data.dat — 3 commits
  • gemfiles/Gemfile.rails-6.1.x — 3 commits
  • spec/phonelib_spec.rb — 3 commits
  • lib/validators — 2 commits
  • gemfiles/Gemfile.rails-3.1.x — 1 commit
  • gemfiles/Gemfile.rails-4.2.x — 1 commit

Notable commits

  • fix: Fix ArgumentError: wrong number of arguments (given 2, expected 1)
  • fix: Merge branch 'master' into fix-issue-356
  • fix: Merge pull request #358 from npadgett/fix-issue-356
  • fix: another fix to nokogiri
  • fix: finalizing test fixes
  • fix: fix: align structured validation diagnostics
  • fix: fix: load validator regardless of require order
  • fix: fixed deprecated warning in importer
  • fix: fixed issue #303
  • fix: fixed issue #304 - fix for national prefix replacement
  • fix: fixed issue #309
  • fix: fixed issue #324 with additional regexes
  • fix: fixed issue #325 and #326
  • fix: fixed issue #326
  • fix: fixed issue #332
  • fix: fixed issue #336
  • fix: fixed issue #343
  • fix: fixed issue #348
  • fix: fixed issue #352
  • fix: fixed issue #355
  • …and 280 more

Architecture

  • 0 containers · 1 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

daddyz/phonelib was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit d03d7c4d4aad5c2d2c9d618c6e66ef8b946f668a — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.