Skip to content

v1.0.0 — bonkers-bitfields (maintained fork of grosser/bitfields)

Choose a tag to compare

@benwalsh benwalsh released this 29 Jun 20:21
dfb7fb2

First release of bonkers-bitfields, a maintained fork of
grosser/bitfields. Modernized for current
Ruby and Rails, with safer bit declarations.

Upgrading from bitfields

Only your Gemfile changes — the library path and module are unchanged:

gem "bonkers-bitfields"   # was: gem "bitfields"
require "bitfields"       # unchanged
include Bitfields         # unchanged — all generated methods keep working

Highlights

Breaking

  • Renamed the published gem to bonkers-bitfields (require path / Bitfields module unchanged).
  • Positional declarations now warn by default. bitfield :flags, :a, :b maps each name to
    2**index, so reordering silently shifts stored bits. Control with Bitfields.positional_bits
    (:warn default / :forbid / :allow); prefer explicit bitfield :flags, 1 => :a, 2 => :b.
  • Duplicate bit names across columns now raise DuplicateBitNameError at declaration time.
  • Dropped support for Ruby < 3.1 and ActiveRecord < 6.1. Now tested on Ruby 3.1–4.0 × AR 6.1–8.0.

Added

  • Bitfields.positional_bits configuration, with nil / :_skip bit-position placeholders.
  • with_bitfields / without_bitfields class query methods (Arel-based, survive eager-load
    aliasing) — resolves the long-standing README TODO and grosser#45.
  • GitHub Actions CI on every branch and PR; tag-triggered RubyGems publishing via Trusted Publishing.

Fixed

  • Cross-column duplicate bit names no longer silently misbehave (grosser#21).
  • README SQL examples and a duplicated assertion in the have_a_bitfield matcher.

Full changelog: CHANGELOG.md