Sha256: 0d22c6015824581bbc40a1fbcada6fd3457d89ebe8af7ae6d064b99a578da29f

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

class BrokerConfig
  class << self
    def config
      adapter_file = File.expand_path("../../.adapter_under_test", __FILE__)
      @adapter, @version = (ENV['ADAPTER'] || (File.exist?(adapter_file) && File.read(adapter_file).chomp)).split(":")
      case @adapter
      when 'bunny'
        {
          adapter: :bunny,
          vhost: 'message-driver-test'
        }
      when 'in_memory'
        {adapter: :in_memory}
      when 'stomp'
        {
          adapter: :stomp,
          vhost: 'message-driver-test',
          hosts: [{host: 'localhost', login: 'guest', passcode: 'guest'}],
          reliable: false,
          max_reconnect_attempts: 1
        }
      else
        {adapter: :in_memory}
      end
    end

    def all_adapters
      %w(in_memory bunny stomp)
    end

    def current_adapter
      config[:adapter]
    end

    def adapter_version
      config unless @version
      @version
    end

    def unconfigured_adapters
      all_adapters - [current_adapter]
    end

    def current_adapter_port
      case current_adapter
      when :bunny
        5672
      when :stomp
        61613
      else
        nil
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message-driver-0.2.2 test_lib/broker_config.rb
message-driver-0.2.1 test_lib/broker_config.rb
message-driver-0.2.0 test_lib/broker_config.rb
message-driver-0.2.0.rc2 test_lib/broker_config.rb
message-driver-0.2.0.rc1 test_lib/broker_config.rb