Sha256: 66e347ca4bed26c0c9cc9663497a74dee834004ff56047c73afa4b7ae1a85598

Contents?: true

Size: 765 Bytes

Versions: 8

Compression:

Stored size: 765 Bytes

Contents

require 'logger'

module SplitIoClient
  class SplitFactoryBuilder
    def self.build(api_key, config = {})
      case api_key
      when 'localhost'
        configuration = SplitConfig.new(config)
        LocalhostSplitFactory.new(split_file(config[:split_file], configuration.logger), configuration, config[:reload_rate])
      else
        SplitFactory.new(api_key, config)
      end
    end

    private

    def self.split_file(split_file_path, logger)
      return split_file_path unless split_file_path.nil?

      logger.warn('Localhost mode: .split mocks ' \
        'will be deprecated soon in favor of YAML files, which provide more ' \
        'targeting power. Take a look in our documentation.')

      File.join(Dir.home, '.split')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
splitclient-rb-7.0.0-java lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0 lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc3-java lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc3 lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc2-java lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc2 lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc1-java lib/splitclient-rb/split_factory_builder.rb
splitclient-rb-7.0.0.pre.rc1 lib/splitclient-rb/split_factory_builder.rb