class Vagrant::UI::Prefixed
Constants
- OUTPUT_PREFIX
The prefix for ‘output` messages.
Public Class Methods
new(ui, prefix)
click to toggle source
Calls superclass method
Vagrant::UI::Interface::new
# File lib/vagrant/ui.rb, line 297 def initialize(ui, prefix) super() @prefix = prefix @ui = ui end
Public Instance Methods
client()
click to toggle source
# File lib/vagrant/ui.rb, line 308 def client @ui.client end
format_message(type, message, **opts)
click to toggle source
# File lib/vagrant/ui.rb, line 360 def format_message(type, message, **opts) opts = self.opts.merge(opts) prefix = "" if !opts.key?(:prefix) || opts[:prefix] prefix = OUTPUT_PREFIX prefix = " " * OUTPUT_PREFIX.length if \ type == :detail || type == :ask || opts[:prefix_spaces] end message = Util::CredentialScrubber.desensitize(message) # Fast-path if there is no prefix return message if prefix.empty? target = @prefix target = opts[:target] if opts.key?(:target) target = "#{target}:" if target != "" lines = [message] if message != "" lines = [].tap do |l| message.scan(/(.*?)(\n|$)/).each do |m| l << m.first if m.first != "" || (m.first == "" && m.last == "\n") end end lines << "" if message.end_with?("\n") end # Otherwise, make sure to prefix every line properly lines.map do |line| "#{prefix}#{target} #{line}" end.join("\n") end
initialize_copy(original)
click to toggle source
Calls superclass method
Vagrant::UI::Interface#initialize_copy
# File lib/vagrant/ui.rb, line 312 def initialize_copy(original) super @ui = original.instance_variable_get(:@ui).dup end
machine(type, *data)
click to toggle source
For machine-readable output, set the prefix in the options hash and continue it on.
# File lib/vagrant/ui.rb, line 345 def machine(type, *data) opts = {} opts = data.pop if data.last.is_a?(Hash) opts[:target] = @prefix data << opts @ui.machine(type, *data) end
opts()
click to toggle source
Return the parent’s opts.
@return [Hash]
# File lib/vagrant/ui.rb, line 356 def opts @ui.opts end
rewriting() { |ui| ... }
click to toggle source
# File lib/vagrant/ui.rb, line 395 def rewriting @ui.rewriting do |ui| yield ui end end
to_proto()
click to toggle source
# File lib/vagrant/ui.rb, line 304 def to_proto @ui.to_proto end