Skip to content
CAI
Software that uses CAICheck a score

public-activity/public_activity

65.6

Adequate · 5 November 2026

1.4k

lines of production code

Ruby

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

PublicActivity is a Ruby gem that provides activity tracking for models across multiple Object-Relational Mappers, including ActiveRecord, Mongoid, and MongoMapper. It enables applications to record and display user actions by linking activities to trackable, owner, and recipient entities through polymorphic associations. The system supports flexible configuration, allowing developers to enable or disable tracking per model and customize activity data, while ensuring thread-safe context handling for rendering in web applications.

How it got here

2011 — PublicActivity 3.0 release and scaffolding

7 changes.

This period focused on rebranding the KeepTrack library to PublicActivity and establishing a modern project structure with updated dependencies for Ruby 3.0 and Rails 6.1+. It introduced a new generator system for creating activity tracking migrations and released version 3.0.2, which added thread-safe configuration and improved controller context handling in templates.

2012–2022 — Multi-ORM support and architectural refactoring

11 changes.

This period focused on expanding the library's compatibility by introducing dedicated ORM adapters for ActiveRecord, Mongoid, and MongoMapper, alongside comprehensive test coverage for these integrations. The codebase underwent significant internal refactoring to improve organization, including the extraction of activity actions into separate modules, the addition of recipient tracking support, and the implementation of per-model deactivation features.

Features

Add Mongoid ORM adapter for activity tracking

Introduces support for Mongoid as an Object-Relational Mapping backend for the PublicActivity gem. This change adds the necessary model definitions (Activity), association modules (Activist for owners/recipients, Trackable for sources), and an adapter layer that enables users to record and query activities using Mongoid documents instead of ActiveRecord models. The Activity model includes polymorphic associations for trackable, owner, and recipient, and conditionally includes dynamic attributes based on the Mongoid version.

_lib/public\activity/orm/mongoid · high confidence

Add initial MongoMapper ORM support

Introduces the first set of files to enable PublicActivity with MongoMapper. This includes the Activity document model with polymorphic associations for trackable, owner, and recipient, an adapter for creating activities, and modules to extend models as activists (for listing activities by owner) and trackables (for listing activities on the model itself).

_lib/public\_activity/orm/mongo\mapper · high confidence

Added ORM adapters for ActiveRecord, MongoMapper, and Mongoid

The library now supports multiple Object-Relational Mappers by introducing specific adapter modules for ActiveRecord, MongoMapper, and Mongoid. These new files in the \lib/public\_activity/orm\ directory act as entry points that load the corresponding activity, adapter, activist, and trackable implementations for each ORM, allowing users to track public activity across these different data persistence layers.

_lib/public\activity/orm · high confidence

Added PublicActivity generator base module

A new generator base module has been added to the library, providing the source root configuration required to locate migration templates for the PublicActivity gem. This change introduces the foundational structure for the generator, enabling the creation of activity tracking tables via the command line.

lib/generators · high confidence

Initial project scaffolding and configuration

The repository is initialized with standard project configuration files, including \.editorconfig\ for consistent code formatting, \.gitignore\ to exclude build artifacts and IDE files, and \.travis.yml\ to define the CI matrix for Ruby and Rails versions. The \Appraisals\ file is added to manage testing across multiple Rails versions (6.1, 7.0, 7.1). Documentation is established with a comprehensive \README.md\ and a \CHANGELOG.md\ tracking versions from 0.5.4 to 3.0.2. Legacy Rails plugin hooks (\init.rb\, \install.rb\, \uninstall.rb\) are removed, and the \Rakefile\ is updated to use YARD for documentation generation instead of RDoc.

(repo-wide) · high confidence

Introduce ActiveRecord ORM support for PublicActivity

This change adds the initial implementation of ActiveRecord support for the PublicActivity gem, enabling activity tracking for Rails applications. It introduces the \PublicActivity::Activity\ model, which defines polymorphic associations for \trackable\, \owner\, and \recipient\, and handles database connection errors gracefully during serialization setup. The \Activist\ module allows models to include \activist\ to expose \activities\_as\_owner\ and \activities\_as\_recipient\ associations, while the \Trackable\ module provides the standard \activities\ association. The \Adapter\ class implements the core logic for creating activities via \create\_activity\ and \create\_activity!\.

_lib/public\_activity/orm/active\record · high confidence

New migration generator for adding recipient support to activities

A new generator (\public\_activity:migration\_upgrade\) is introduced to help users upgrade their existing activity tracking setup. Running this generator creates a migration that alters the \activities\ table by adding a polymorphic \recipient\ association, enabling the system to track who received specific activities.

_lib/generators/public\_activity/migration\upgrade · high confidence

New migration generator for creating activity tracking tables

A new generator class has been added to create database migrations for the public\_activity gem. Users can now run this generator to scaffold a migration file (defaulting to 'create\_activities') that sets up the necessary schema for tracking activities, simplifying the initial setup process.

_lib/generators/public\activity/migration · high confidence

Behavioural changes

New per-class deactivation and refined tracking configuration

The library now includes a new \Deactivatable\ role that allows users to disable PublicActivity on a per-model basis using \public\_activity\_off\ and \public\_activity\_on\ class methods, providing finer control over which models generate activity records. Additionally, the \Tracked\ role has been refactored to support custom fields on all three tiers (global, class, and instance) and ensures that custom fields do not leak between parent and child classes, while also clarifying that ORM-dependent associations are handled within this module.

_lib/public\activity/roles · high confidence

PublicActivity 3.0.2 release with thread-safe configuration and rendering improvements

This release updates the gem to version 3.0.2 and introduces thread-safe configuration storage using thread-local variables, ensuring that settings like ORM, table name, and enabled status are isolated per request thread rather than shared globally. It also enhances the activity rendering logic by passing the controller and current user to view templates via locals, allowing templates to access \current\_user\ and other controller context safely. Additionally, the \render\ method now supports passing \:locals\ to merge with default template variables, and the \text\ method for i18n translations accepts additional runtime parameters.

_lib/public\activity · high confidence

Rebranding to PublicActivity with new module structure

The library has been rebranded from KeepTrack to PublicActivity. The main entry point is now the PublicActivity module, which provides global configuration and toggles (enabled/enabled=) to control activity tracking. The module includes a Model concern for ActiveRecord models that integrates tracking, deactivation, and activist association features. The old keep\_track.rb file has been removed.

lib · high confidence

Refactored activity actions into separate modules with Rails 5.1 compatibility

The activity tracking logic for creation, destruction, and updates has been extracted into dedicated modules (Creation, Destruction, Update) to improve code organization. The update action now supports Rails 5.1+ by using the \saved\_changes?\ method when available, falling back to \changed?\ for older versions, ensuring compatibility across Rails versions.

_lib/public\activity/actions · high confidence

Refactored activity storage and rendering utilities

The library has reorganized its internal structure by introducing dedicated utility modules for controller context management and view rendering. A new \StoreController\ module now explicitly handles storing and retrieving the current controller instance via thread-local storage, ensuring activities have access to the correct context during rendering. Additionally, a \ViewHelpers\ module provides the \render\_activity\ (and aliased \render\_activities\) helper, which allows views to render single activities or collections of activities, including support for lazy-loaded collections that respond to \map\. These changes streamline how activities are stored and displayed without altering the public API surface.

_lib/public\activity/utility · high confidence

Updated migration template to use Rails 6.1 and polymorphic associations

The generated migration template for the activities table has been updated to target Rails 6.1, ensuring compatibility with newer Rails versions. The schema now uses polymorphic associations for the trackable, owner, and recipient columns, allowing activities to be linked to any model type rather than a single specific one. Additionally, the template includes the frozen\_string\_literal pragma for improved Ruby performance and safety.

_lib/generators/public\activity/migration/templates · high confidence

Test coverage

Added comprehensive test suite for PublicActivity; Added test migration files for Rails 6.1 compatibility.

Dependencies

Add support for Rails 7.1 and configure bundle retry

The gemfiles directory now includes dedicated Appraisal gemfiles for Rails 6.1, 7.0, and 7.1, enabling testing against these specific versions. Additionally, a .bundle/config file has been added to enable bundle install retries, improving resilience during dependency resolution.

gemfiles · high confidence

Update gem dependencies and Ruby version requirements

The public\_activity gem now requires Ruby 3.0.0 or higher and has updated its runtime dependencies to support Rails 6.1 and later (actionpack, railties, and activerecord). Development dependencies have been refreshed to include appraisal, minitest, mocha, pry, simplecov, sqlite3 (\~\> 1.4), and yard, while the gemspec now explicitly defines these dependencies rather than relying on a separate Gemfile for resolution.

(dependencies) · high confidence

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

How this codebase got here

Score

  • CAI 66 → 66 (-0.1)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 76 → 76 (+0.0)
  • Architecture 69 → 69 (+0.0)
  • Maturity 56 → 56 (+0.0)
  • Readiness 71 → 71 (+0.0)
  • Security 97 → 95 (-1.5)
  • Domain Modelling 100 → 100 (+0.0)

Resolved (3)

  • Inconsistent bang method semantics across modules. In Ruby, the bang (!) suffix typically implies a side effect like raising an exception on failure or mutating state in place. Here, Common and Adapter both expose create_activity and create_activity!. However, without seeing the implementation, it is ambiguous whether the bang version raises an exception while the non-bang version returns nil/false, or if they differ in validation strictness. More critically, the parameter names differ (args vs trackable, options), suggesting different abstraction levels, but the naming convention for the 'strict' variant is duplicated across two distinct layers (Common and Adapter) without clear documentation of the divergence.
  • Inconsistent setter/getter naming convention in Config. The Config class exposes both setter methods (orm=, enabled=) and getter-like methods with the same name (orm, enabled) that accept arguments. In Ruby, a method named orm usually implies a getter (no args), while orm= is a setter. Having Config.orm(orm) suggests it might be a setter or a builder, which conflicts with the standard Ruby convention where Config.orm would be a read-only accessor. This creates ambiguity: is Config.orm(value) a setter, and Config.orm a getter? The presence of explicit orm= and enabled= setters makes the argument-taking orm and enabled methods redundant or confusingly named.
  • Off-boarding risk: anonymized user #1

New (1)

  • Off-boarding risk: anonymized user #1

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

Survey your own repository

public-activity/public_activity 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 5 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 1f3a5568adcb55317552b7528cc489b8ccbbb306 — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.