egonSchiele/contracts.ruby
71.9
Strong · 19 September 2026
2.1k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is a Ruby library that provides runtime type checking and contract validation for methods and attributes. It enables developers to define strict function signatures using built-in contract types, ensuring arguments and return values adhere to specified constraints. The library also supports advanced features like method overloading via pattern matching and class invariants, while offering detailed error reporting for violations.
How it got here
2012 — Ruby 3.0 modernization and refactoring
4 changes.
The project was updated to support Ruby 3.0+, establishing a modern development environment with RuboCop and RSpec configurations. Core validation logic was refactored to improve maintainability and error reporting, while comprehensive test fixtures were added to ensure robust contract behavior.
2013–2024 — modular refactoring and test expansion
10 changes.
The project underwent a significant structural refactoring, splitting the monolithic contracts engine and library into modular components to improve code organization and maintainability. This period also saw the extensive expansion of the test suite, introducing comprehensive RSpec and Cucumber tests for core behaviors, built-in contracts, and Ruby version-specific edge cases.
Features
New documentation release scripts and Ruby 2.1 Rubocop runner
Added two new executable scripts, \script/docs-release\ and \script/docs-staging\, which automate pushing documentation to the relish platform for production and staging environments respectively. Additionally, introduced \script/rubocop.rb\ to run Rubocop with debug output enabled, but only when executing on Ruby 2.1.
script · high confidence
Behavioural changes
Contracts library restructured into modular components with new attribute helpers
The contracts library has been refactored from a single monolithic file into a modular structure under the \lib/contracts\ directory, introducing dedicated modules for core functionality (\Core\), method decoration (\MethodDecorators\, \MethodHandler\), validation strategies (\Validators\), and error handling (\Errors\). This change introduces a new \Contracts::Attrs\ module that provides \attr\_reader\_with\_contract\, \attr\_writer\_with\_contract\, and \attr\_accessor\_with\_contract\ methods, allowing users to define attributes with contract validation directly. The \Builtin\ module now contains all built-in contract classes (e.g., \Num\, \Int\, \Nat\, \Or\, \And\, \Xor\), and the engine logic is centralized in \Engine\ and \CallWith\. The version is bumped to 0.17.3.
lib/contracts · high confidence
Initialize Aruba Cucumber support for CLI testing
Added a new support file (features/support/env.rb) that integrates the Aruba gem for Cucumber, enabling command-line interface testing. The setup configures a default timeout of 5 seconds for standard Ruby runs and 30 seconds for JRuby environments to accommodate potential performance differences.
features/support · high confidence
Refactored contract validation and error reporting architecture
The library's core validation logic has been restructured to improve readability and maintainability. The \Contract\ class now explicitly manages argument, keyword, and return value validators, separating the parsing of complex method signatures from the validation execution. Error reporting has been enhanced with a dedicated \failure\_msg\ method that provides structured, pretty-printed details including expected vs. actual values, argument positions, and method context. Additionally, the \failure\_callback\ mechanism now supports pattern matching logic, allowing for more granular control over how contract violations are handled during execution.
lib · high confidence
Refactored contracts engine into modular components
The contracts engine implementation has been split from a single file into three distinct modules: \Engine::Base\ for core class decoration logic, \Engine::Eigenclass\ to handle class-level method decorators, and \Engine::Target\ to manage the activation and retrieval of engines for specific classes. This structural change improves code organization and clarifies the separation between instance and class method contract handling, while maintaining the same external API for enabling and applying contracts.
lib/contracts/engine · high confidence
Test coverage
Add documentation and tests for functype and contract violation scenarios; Added Ruby version-specific contract tests; Added benchmark suite for contract performance analysis; Added comprehensive test suite for contract validation features; Added fixture definitions for contract testing; Documentation and tests for builtin contracts; Documentation of method overloading via pattern matching.
Dependencies
Initial gem release with Ruby 3.0+ support and modern test dependencies
This change introduces the core gem specification and development environment for the 'contracts' library. The gemspec now requires Ruby version 3.0 or higher (but less than 5), aligning with the project's shift to modern Ruby versions. The Gemfile establishes the dependency structure, pinning test dependencies to Cucumber \>= 9.2.1 and RuboCop \>= 1.0.0 to ensure compatibility with current Ruby versions and CI standards, while including development tools like RSpec, Aruba, and Method Profiler.
(dependencies) · high confidence
Housekeeping
Add RuboCop configuration and RSpec defaults
The project now includes a \.rubocop.yml\ file to enforce code style (targeting Ruby 3.0) and a \.rubocop\_todo.yml\ to track existing offenses, alongside a \.rspec\ file to set default test runner options like color output and requiring the spec helper.
(repo-wide) · 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 72.
Lenses
- Code Health 96
- Architecture 100
- Maturity 56
- Readiness 75
- Security 96
Changes since last survey
- 300 commits — 253 feature/other, 47 fixes
By area
- (root) — 95 commits
- (repo) — 64 commits
- lib/contracts — 62 commits
- .github/workflows — 20 commits
- features/builtin_contracts — 19 commits
- lib/contracts.rb — 8 commits
- spec/contracts_spec.rb — 8 commits
- features/basics — 6 commits
- spec/builtin_contracts_spec.rb — 5 commits
- benchmarks/hash.rb — 2 commits
- features/advanced — 2 commits
- spec/override_validators_spec.rb — 2 commits
- spec/ruby_version_specific — 2 commits
- .github/dependabot.yml — 1 commit
- benchmarks/io.rb — 1 commit
- script/cucumber — 1 commit
- script/docs-release — 1 commit
- spec/validators_spec.rb — 1 commit
Notable commits
- fix: ! Fix CI due to changed #inspect output
- fix: ! Fix a failed test case in 3.4 due to error message format diff in ruby 3.4
- fix: ! Fix cucumber for ruby 3.4
- fix: ! Fix keyword arguments contract when used with optional positional arguments
- fix: ! Fix pattern matching
- fix: $ Fix RuboCop violations
- fix: $ Fix RuboCop violations
- fix: FIX: methods created with attr_* don't have a source_location. In that case just return the empty string.
- fix: Fix GH Action config
- fix: Fix Pos,Neg contracts which fail incorrectly for nil values
- fix: Fix StrictHash contract for extra keys (#254)
- fix: Fix broken contracts.coffee link in README.
- fix: Fix contracts used in AR-models
- fix: Fix defined?(super) for ruby 1.9.2
- fix: Fix errors related to rspec upgrade
- fix: Fix for 1.8
- fix: Fix for jruby and hopefully ruby 1.8
- fix: Fix maybe proc
- fix: Fix tutorial builtin namespacing
- fix: Fixed #165: "Bug: comparison of Symbol with 0 failed"
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
egonSchiele/contracts.ruby 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 19 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 0673e474bd8057862a864e41878ae0476e2e7c99 — 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.