Class: Cucumber::WireSupport::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/wire_support/configuration.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Configuration

Returns a new instance of Configuration.



14
15
16
17
18
19
# File 'lib/cucumber/wire_support/configuration.rb', line 14

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

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/cucumber/wire_support/configuration.rb', line 7

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/cucumber/wire_support/configuration.rb', line 7

def port
  @port
end

#unixObject (readonly)

Returns the value of attribute unix.



7
8
9
# File 'lib/cucumber/wire_support/configuration.rb', line 7

def unix
  @unix
end

Class Method Details

.from_file(wire_file) ⇒ Object



9
10
11
12
# File 'lib/cucumber/wire_support/configuration.rb', line 9

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

Instance Method Details

#timeout(message = nil) ⇒ Object



21
22
23
# File 'lib/cucumber/wire_support/configuration.rb', line 21

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

#to_sObject



25
26
27
28
# File 'lib/cucumber/wire_support/configuration.rb', line 25

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