Sha256: 493d86b2ec51b64982c4b15649d705f5c432b1a8e2dd4b004df964c35dd5cb55

Contents?: true

Size: 826 Bytes

Versions: 10

Compression:

Stored size: 826 Bytes

Contents

require 'yaml'
require 'erb'

module Lucid
  module WireSupport
    class Configuration
      attr_reader :host, :port, :unix

      def self.from_file(wire_file)
        settings = YAML.load(ERB.new(File.read(wire_file)).result)
        new(settings)
      end

      def initialize(args)
        @host = args['host']
        @port = args['port']
        @unix = args['unix'] if RUBY_PLATFORM !~ /mingw|mswin/
        @timeouts = DEFAULT_TIMEOUTS.merge(args['timeout'] || {})
      end

      def timeout(message = nil)
        return @timeouts[message.to_s] || 3
      end

      def to_s
        return @unix if @unix
        "#{@host}:#{@port}"
      end

      DEFAULT_TIMEOUTS = {
        'connect' => 11,
        'invoke' => 120,
        'begin_scenario' => 120,
        'end_scenario' => 120
      }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lucid-0.3.0 lib/lucid/wire_support/configuration.rb
lucid-0.2.1 lib/lucid/wire_support/configuration.rb
lucid-0.2.0 lib/lucid/wire_support/configuration.rb
lucid-0.1.1 lib/lucid/wire_support/configuration.rb
lucid-0.1.0 lib/lucid/wire_support/configuration.rb
lucid-0.0.9 lib/lucid/wire_support/configuration.rb
lucid-0.0.8 lib/lucid/wire_support/configuration.rb
lucid-0.0.7 lib/lucid/wire_support/configuration.rb
lucid-0.0.6 lib/lucid/wire_support/configuration.rb
lucid-0.0.5 lib/lucid/wire_support/configuration.rb