Class: Vagrant::UI::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/ui.rb,
lib/vagrant/ui/remote.rb

Overview

Vagrant UIs handle communication with the outside world (typically through a shell). They must respond to the following methods:

  • info
  • warn
  • error
  • success

Direct Known Subclasses

Basic, MachineReadable, Prefixed, Silent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterface

Returns a new instance of Interface.



35
36
37
38
39
40
41
42
# File 'lib/vagrant/ui.rb', line 35

def initialize
  @logger   = Log4r::Logger.new("vagrant::ui::interface")
  @opts     = {}

  @stdin  = $stdin
  @stdout = $stdout
  @stderr = $stderr
end

Instance Attribute Details

#optsObject

Opts can be used to set some options. These options are implementation specific. See the implementation for more docs.



24
25
26
# File 'lib/vagrant/ui.rb', line 24

def opts
  @opts
end

#stderrIO

Returns UI error output. Defaults to $stderr.

Returns:

  • (IO)

    UI error output. Defaults to $stderr.



33
34
35
# File 'lib/vagrant/ui.rb', line 33

def stderr
  @stderr
end

#stdinIO

Returns UI input. Defaults to $stdin.

Returns:

  • (IO)

    UI input. Defaults to $stdin.



27
28
29
# File 'lib/vagrant/ui.rb', line 27

def stdin
  @stdin
end

#stdoutIO

Returns UI output. Defaults to $stdout.

Returns:

  • (IO)

    UI output. Defaults to $stdout.



30
31
32
# File 'lib/vagrant/ui.rb', line 30

def stdout
  @stdout
end

Class Method Details

.inherited(klass) ⇒ Object



15
16
17
# File 'lib/vagrant/ui/remote.rb', line 15

def self.inherited(klass)
  klass.prepend(Reformatter)
end

Instance Method Details

#color?false

Returns:

  • (false)


69
70
71
# File 'lib/vagrant/ui.rb', line 69

def color?
  return false
end

#initialize_copy(original) ⇒ Object



44
45
46
47
# File 'lib/vagrant/ui.rb', line 44

def initialize_copy(original)
  super
  @opts = original.opts.dup
end

#machine(type, *data) ⇒ Object

For machine-readable output.

Parameters:

  • type (String)

    The type of the data

  • data (Array)

    The data associated with the type



77
78
79
# File 'lib/vagrant/ui.rb', line 77

def machine(type, *data)
  @logger.info("Machine: #{type} #{data.inspect}")
end

#rewriting {|_self| ... } ⇒ Object

Yields self (UI) Provides a way for selectively displaying or not displaying updating content like download progress.

Yields:

  • (_self)

Yield Parameters:



84
85
86
# File 'lib/vagrant/ui.rb', line 84

def rewriting
  yield self
end

#to_protoObject

Raises:

  • (NotImplementedError)


88
89
90
91
# File 'lib/vagrant/ui.rb', line 88

def to_proto
  raise NotImplementedError,
    "Vagrant::UI::Interface#to_proto"
end