class Vagrant::UI::MachineReadable

Public Class Methods

new() click to toggle source
Calls superclass method Vagrant::UI::Interface.new
# File lib/vagrant/ui.rb, line 75
def initialize
  super

  @lock = Mutex.new
end

Public Instance Methods

ask(*args) click to toggle source
Calls superclass method
# File lib/vagrant/ui.rb, line 81
def ask(*args)
  super

  # Machine-readable can't ask for input
  raise Errors::UIExpectsTTY
end
machine(type, *data) click to toggle source
# File lib/vagrant/ui.rb, line 88
def machine(type, *data)
  opts = {}
  opts = data.pop if data.last.kind_of?(Hash)

  target = opts[:target] || ""

  # Prepare the data by replacing characters that aren't outputted
  data.each_index do |i|
    data[i] = data[i].to_s.dup
    data[i].gsub!(",", "%!(VAGRANT_COMMA)")
    data[i].gsub!("\n", "\\n")
    data[i].gsub!("\r", "\\r")
  end

  @lock.synchronize do
    safe_puts("#{Time.now.utc.to_i},#{target},#{type},#{data.join(",")}")
  end
end