# ab_rules **Repository Path**: rubygems/ab_rules ## Basic Information - **Project Name**: ab_rules - **Description**: No description available - **Primary Language**: Ruby - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-10-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AbRules AbRules is a light ruby library to fulfill A/B testing. Inspired by Split, AbRules aims to simplify the A/B testing logic, focus on providing flexible rules to generate different contents. ## Requirements - Ruby 1.9.3 or higher ## Setup ```bash gem install ab_rules ``` ## Usage Example: A/B testing by ID ```ruby require "ab_rules" AbRules.split_by_id(122, "control", "test") #=> "control" AbRules.split_by_id(333, "control", "test") #=> "test" AbRules.split_by_id(333, "control", "test") do |alternative| "The version is #{alternative}" end #=> "The version is test" ``` Example: A/B testing by rules ```ruby require "ab_rules" SITES = [123, 567, 999] NETWORKS = [1, 4, 6] rules = [ AbRules.rule(:control) do |subjects| subjects[:country] == "uk" end, AbRules.rule(:test) do |subjects| subjects[:id] && subjects[:id].even? end, AbRules.rule(:default) ] AbRules.split_by_rule({ country: "uk" }, rules) #=> :control AbRules.split_by_rule({ id: 2 }, rules) #=> :test AbRules.split_by_rule({}, rules) do |content| "Cotent is #{content}" end #=> "Cotent is default" ``` ## Questions, Feedback Feel free to message me on Github (fdf515) or Twitter (@JIAZHENXIE) :) ## Contributing to AbRules Fork, fix, then send a pull request. ## Copyright Copyright (c) 2015 Jiazhen Xie. See MIT-LICENSE for further details.