ABMeter Gem
A simple A/B testing client library for Ruby applications.
Breaking change in 0.3.0:
ABMeter.reset!now discards queued data without any network I/O; useABMeter.resetfor the previous drain-on-exit behavior.
Supported Ruby versions
abmeter supports Ruby 3.2 and newer.
Installation
Add this line to your application's Gemfile:
gem 'abmeter'
And then execute:
$ bundle install
Usage
# configure the client
ABMeter.configure do |config|
config.api_key = ENV['ABMETER_API_KEY']
end
# Somewhere in the renedring code:
user = ABMeter.user(id: current_user.id, email: current_user.email)
text = ABMeter.param('welcome_text', user)
# Somewhere in the model code:
current_user.plan = purchased_plan.name
user = ABMeter.user(id: current_user.id, email: current_user.email)
ABMeter.event(`user_purchases_plan`, user, {plan: purchased_plan.name, price: purchased_plan.price})
Shutdown
# Graceful — bounded blocking, flushes pending exposures/events.
# Returns true on clean shutdown, false if the timeout elapsed.
ABMeter.reset(timeout: 5.0)
# Immediate — non-blocking, discards anything still queued.
# Use only when the process is exiting *right now* and you cannot afford I/O.
ABMeter.reset!
Development
The gem uses mise to pin Ruby (mise.toml). Pure-Ruby — no Postgres / Redis required.
brew install mise # one-time
mise install # one-time: install pinned Ruby
bundle install
bundle exec rspec # tests
bundle exec rubocop # lint (if .rubocop.yml present)
The gem is tested against Ruby 3.2, 3.3, 3.4, and 4.0.
License
The gem is available as open source under the terms of the MIT License.