Sha256: f80d816870ea9ad45f4e88d7b6223b5c93eb305285f6b61d228c0b24de326541
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
# dependencies require "active_support" require "browser" require "ipaddr" # modules require "field_test/calculations" require "field_test/experiment" require "field_test/helpers" require "field_test/participant" require "field_test/version" # integrations require "field_test/engine" if defined?(Rails) module FieldTest class Error < StandardError; end class ExperimentNotFound < Error; end class UnknownParticipant < Error; end # same as ahoy UUID_NAMESPACE = "a82ae811-5011-45ab-a728-569df7499c5f" def self.config_path path = defined?(Rails) ? Rails.root : File path.join("config", "field_test.yml") end def self.config @config ||= YAML.load(ERB.new(File.read(config_path)).result) end def self.exclude_bots? config["exclude"] && config["exclude"]["bots"] end def self.cache config["cache"] end def self.cookies config.key?("cookies") ? config["cookies"] : true end def self.legacy_participants config["legacy_participants"] end def self.precision config["precision"] || 0 end 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 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 end ActiveSupport.on_load(:action_controller) do require "field_test/controller" include FieldTest::Controller end ActiveSupport.on_load(:action_mailer) do require "field_test/mailer" include FieldTest::Mailer end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
field_test-0.3.1 | lib/field_test.rb |
field_test-0.3.0 | lib/field_test.rb |