Sha256: f40bd063999b7eb3c98aa3328a25e3be53f0cf4c6c4589e4522e92ce4f1ec802

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'logger'

module Verdict
  extend self

  attr_accessor :default_logger, :directory

  def [](handle)
    Verdict.repository[handle.to_s]
  end

  def repository
    if @repository.nil?
      @repository = {}
      discovery
    end

    @repository
  end

  def discovery
    Dir[File.join(Verdict.directory, '**', '*.rb')].each { |f| require f } if @directory
  end

  class Error < StandardError; end
  class SegmentationError < Verdict::Error; end
  class InvalidSubject < Verdict::Error; end
  class EmptySubjectIdentifier < Verdict::Error; end
  class StorageError < Verdict::Error; end

  class ExperimentHandleNotUnique < Verdict::Error
    attr_reader :handle

    def initialize(handle)
      @handle = handle
      super("Another experiment with handle #{handle.inspect} is already defined!")
    end
  end
end

require "verdict/version"
require "verdict/railtie" if defined?(Rails)

require "verdict/metadata"
require "verdict/experiment"
require "verdict/group"
require "verdict/assignment"
require "verdict/conversion"
require "verdict/segmenter"
require "verdict/storage"
require "verdict/event_logger"

Verdict.default_logger ||= Logger.new("/dev/null")
Verdict.directory = nil

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
verdict-0.2.0 lib/verdict.rb
verdict-0.1.1 lib/verdict.rb
verdict-0.1.0 lib/verdict.rb