ClosureTree/closure_tree
66.2
Adequate · 19 September 2026
1.5k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is a Ruby gem that implements hierarchical tree structures within ActiveRecord models using a closure table pattern. It provides capabilities for managing parent-child relationships, including node adoption, deterministic ordering, and concurrent access safety via advisory locking. The library supports multiple database backends and includes tooling for automatic migration generation and comprehensive testing across different database adapters.
How it got here
2011 — v9.8.0 API rewrite and modernization
8 changes.
The project underwent a comprehensive rewrite to version 9.8.0, replacing raw SQL with Arel and migrating to Zeitwerk autoloading for improved cross-database compatibility. This period also involved modernizing the development infrastructure by switching the test suite to Minitest, updating Ruby and Rails dependencies, and establishing multi-database support for local testing.
2014–2022 — Test infrastructure and generator enhancements
5 changes.
This period focused on expanding the test suite with comprehensive coverage for core hierarchy operations, including re-parenting, locking, and STI inheritance. It also introduced new tooling such as an RSpec matcher, a migration generator for hierarchy tables, and Rails/Rake binstubs to streamline engine development and testing.
Features
New migration generator for hierarchy tables
Added a new \MigrationGenerator\ and its corresponding ERB template to automatically create the closure tree hierarchy table. This generator handles the creation of the necessary schema (including ancestor/descendant IDs, generations, and unique indexes) and respects ActiveRecord table name prefixes and suffixes, ensuring generated migration files are correctly named and compatible with the configured database settings.
lib/generators · high confidence
Behavioural changes
Added Rails and Rake binstubs for engine testing
The bin directory now includes executable scripts for rails and rake. The rails binstub is configured to load the Rails engine commands using a dummy application located in test/dummy, enabling direct execution of Rails commands within the engine's test environment. The rake binstub delegates to the Bundler-managed rake executable, ensuring consistent task execution.
bin · high confidence
ClosureTree v9.8.0: Complete API rewrite with Arel and modular architecture
ClosureTree has been rewritten from the ground up to replace raw SQL string interpolation with Arel for all database queries, improving compatibility across different database adapters (such as PostgreSQL, MySQL, and Oracle) and modernizing the codebase. The library now uses a modular architecture with separate concerns for association setup, hierarchy maintenance, deterministic ordering, and finders, reducing namespace pollution in models. Key behavioral changes include the deprecation of the \database\_less\ configuration option (which is now a no-op), the introduction of \dependent: :adopt\ for handling child nodes when a parent is destroyed, and improved advisory locking to prevent deadlocks. The public API remains largely compatible, but internal implementation details have changed significantly to support these enhancements.
_lib/closure\tree · high confidence
Migration to Zeitwerk autoloading and API cleanup
The library has been rewritten to use Zeitwerk for autoloading, replacing the previous manual require structure and the old \Closure::Tree\ module namespace with a modern \ClosureTree\ module. This change includes the removal of the legacy \ClosureTree.configure\ method, which now emits a deprecation warning as configuration is no longer required, and updates the gem's entry point to properly initialize the autoloader while extending ActiveRecord with the tree functionality.
lib · high confidence
Project infrastructure modernization and multi-database support
The repository has been updated to support modern development workflows and multi-database testing. A new \.env.example\ file and \docker-compose.yml\ configuration allow developers to easily spin up PostgreSQL and MySQL instances for local testing, reflecting the gem's support for multiple database backends. The project has migrated its documentation tooling from RDoc to YARD (evidenced by the new \.yardopts\ file) and updated its Ruby version requirement to 3.4.8 via \.tool-versions\. Additionally, the release process is now automated using \release-please\ (via \release-please-config.json\ and \.release-please-manifest.json\), and the Rakefile has been restructured to explicitly define test tasks and load the dummy Rails application, replacing the previous generic Bundler helper setup.
(repo-wide) · high confidence
Test coverage
Added RSpec matcher for Closure Tree validation; Added comprehensive test suite for closure\_tree functionality; Added database schemas for multi-database and SQLite test environments; Added test dummy Rails application configuration; Added test support utilities for query counting and tag example isolation; Migrate test suite to Minitest; Test suite expanded with new dummy app models and multi-database setup.
Dependencies
Update gemspec and Gemfile for modern Ruby and Rails compatibility
The project has migrated from the legacy 'closure-tree' gemspec to a new 'closure\_tree' gemspec, enforcing a minimum Ruby version of 3.3.0 and requiring ActiveRecord 7.2.0 or higher. Runtime dependencies now explicitly include 'with\_advisory\_lock' (\>= 7.6.0) and 'zeitwerk' (\~\> 2.7), replacing older autoload mechanisms. The Gemfile has been updated to use HTTPS for the RubyGems source, dynamically resolve Rails versions via environment variables for testing, and shift development dependencies to include 'rubocop' and 'maxitest'.
(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 66.
Lenses
- Code Health 100
- Architecture 99
- Maturity 57
- Readiness 53
- Security 100
Changes since last survey
- 300 commits — 241 feature/other, 59 fixes
By area
- (root) — 131 commits
- (repo) — 67 commits
- lib/closure_tree — 65 commits
- .github/workflows — 6 commits
- test/closure_tree — 6 commits
- test/dummy — 5 commits
- gemfiles/activerecord_4.2.gemfile — 3 commits
- spec/closure_tree — 3 commits
- spec/db — 3 commits
- spec/label_spec.rb — 3 commits
- spec/generators — 2 commits
- spec/support — 2 commits
- lib/generators — 1 commit
- spec/has_closure_tree_root_spec.rb — 1 commit
- spec/spec_helper.rb — 1 commit
- spec/tag_examples.rb — 1 commit
Notable commits
- fix: Fix ActiveSupport 5.1 deprecation warnings.
- fix: Fix tree.find_by_tree([]) returning tree.first
- fix: Fix deprecation for exists?
- fix: Fix https://github.com/ClosureTree/closure_tree/issues/264
- fix: Fix https://github.com/ClosureTree/closure_tree/issues/308
- fix: Fix kwargs usage for Ruby 2.7
- fix: Fix master build
- fix: Fix mistake
- fix: Fix mysql2 version for older rails
- fix: Fix pg version for rails prior 5.1
- fix: Fix the uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger error (#447)
- fix: Fix uninitialized variables
- fix: Fix unused variable warnings (#327)
- fix: Fix warning for alignment of end with def
- fix: Fixed Rails 5 Active Record method name collision.
- fix: Fixed a anchor link for in the README
- fix: Fixed bugs with *_including_tree argument list
- fix: Fixes #220. Refactored how default default tree scope is generated. The scope should be generated from the existing chained scope, rather than built from model_class.
- fix: Merge pull request #172 from hendricius/fix-uuid-graphviz
- fix: Merge pull request #182 from martin-schmidt/fix-tests
- …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
ClosureTree/closure_tree 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 ca04a8a7034a2caccacf6c762b639ade170d5a90 — 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-13a154b7f5d1.