module FieldTest
formulas from www.evanmiller.org/bayesian-ab-testing.html
Constants
- UUID_NAMESPACE
same as ahoy
- VERSION
Public Class Methods
cache()
click to toggle source
# File lib/field_test.rb, line 41 def self.cache config["cache"] end
config()
click to toggle source
# File lib/field_test.rb, line 29 def self.config @config ||= YAML.load(ERB.new(File.read(config_path)).result) end
config_path()
click to toggle source
# File lib/field_test.rb, line 24 def self.config_path path = defined?(Rails) ? Rails.root : File path.join("config", "field_test.yml") end
events_supported?()
click to toggle source
# File lib/field_test.rb, line 57 def self.events_supported? unless defined?(@events_supported) connection = FieldTest::Membership.connection table_name = "field_test_events" @events_supported = if connection.respond_to?(:data_source_exists?) connection.data_source_exists?(table_name) else connection.table_exists?(table_name) end end @events_supported end
exclude_bots?()
click to toggle source
# File lib/field_test.rb, line 37 def self.exclude_bots? config["exclude"] && config["exclude"]["bots"] end
excluded_ips()
click to toggle source
# File lib/field_test.rb, line 33 def self.excluded_ips @excluded_ips ||= Array(config["exclude"] && config["exclude"]["ips"]).map { |ip| IPAddr.new(ip) } end
legacy_participants()
click to toggle source
# File lib/field_test.rb, line 49 def self.legacy_participants config["legacy_participants"] end
mask_ip(ip)
click to toggle source
# File lib/field_test.rb, line 71 def self.mask_ip(ip) addr = IPAddr.new(ip) if addr.ipv4? # set last octet to 0 addr.mask(24).to_s else # set last 80 bits to zeros addr.mask(48).to_s end end
precision()
click to toggle source
# File lib/field_test.rb, line 53 def self.precision config["precision"] || 0 end