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 106 def initialize super @lock = Mutex.new end
Public Instance Methods
ask(*args, **opts)
click to toggle source
Calls superclass method
# File lib/vagrant/ui.rb, line 112 def ask(*args, **opts) 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 125 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 # Avoid locks in a trap context introduced from Ruby 2.0 Thread.new do @lock.synchronize do safe_puts("#{Time.now.utc.to_i},#{target},#{type},#{data.join(",")}") end end.join(THREAD_MAX_JOIN_TIMEOUT) end