1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
# frozen_string_literal: true
require 'yaml'
require 'erb'
module Cucumber
module Wire
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'] unless RUBY_PLATFORM.match?(/mingw|mswin/)
@timeouts = DEFAULT_TIMEOUTS.merge(args['timeout'] || {})
end
def timeout(message = nil)
@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
|