Sha256: ae5bbdfc5f34ce234a8a7861e27c4ae91671c61377e45bcf935c36423d85719d

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

require "vagrant"

module VagrantPlugins
  module RsyncBlitz
    class Config < Vagrant.plugin(2, :config)
      attr_accessor :autostart
      attr_accessor :latency
      attr_accessor :time_format

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

      def finalize!
        @autostart = false if @autostart == UNSET_VALUE
        @latency = 2.0 if @latency == UNSET_VALUE
        @time_format = "%I:%M:%S %p" if @time_format == UNSET_VALUE
      end

      def validate(machine)
        errors = _detected_errors

        if @latency == UNSET_VALUE
          return
        elsif not @latency.is_a? Numeric
          @latency = 2.0
          errors << "Latency must be a number, setting to 2.0"
        elsif @latency < 0.2
          @latency = 0.2
          errors << "Latency must not be too low, setting to 0.2 seconds"
        end

        { "blitz" => errors }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-rsync-blitz-2.0.0 lib/vagrant-rsync-blitz/config.rb