Class: VagrantPlugins::GatlingRsync::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-gatling-rsync/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



10
11
12
13
14
# File 'lib/vagrant-gatling-rsync/config.rb', line 10

def initialize
  @latency = UNSET_VALUE
  @time_format = UNSET_VALUE
  @rsync_on_startup = UNSET_VALUE
end

Instance Attribute Details

#latencyObject

Returns the value of attribute latency.



6
7
8
# File 'lib/vagrant-gatling-rsync/config.rb', line 6

def latency
  @latency
end

#rsync_on_startupObject

Returns the value of attribute rsync_on_startup.



8
9
10
# File 'lib/vagrant-gatling-rsync/config.rb', line 8

def rsync_on_startup
  @rsync_on_startup
end

#time_formatObject

Returns the value of attribute time_format.



7
8
9
# File 'lib/vagrant-gatling-rsync/config.rb', line 7

def time_format
  @time_format
end

Instance Method Details

#finalize!Object



16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-gatling-rsync/config.rb', line 16

def finalize!
  @latency = 1.5 if @latency == UNSET_VALUE
  @time_format = "%I:%M:%S %p" if @time_format == UNSET_VALUE
  if @rsync_on_startup == UNSET_VALUE
    @rsync_on_startup = true
  else
    @rsync_on_startup = !!@rsync_on_startup
  end
end

#validate(machine) ⇒ Object

@TODO: This does not appear to be called.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vagrant-gatling-rsync/config.rb', line 27

def validate(machine)
  errors = _detected_errors

  if @latency == UNSET_VALUE
    return
  elsif not @latency.is_a? Numeric
    @latency = 1.5
    # @TODO: Translate.
    errors << "The latency must be set to a number. Substituting 1.5 as a value."
  elsif @latency < 0.2
    @latency = 0.2
    # @TODO: Translate.
    errors << "The latency may not be below 0.2 seconds."
  end

  { "gatling" => errors }
end