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.



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

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.



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

def opts
  @opts
end

#stderrIO

Returns UI error output. Defaults to $stderr.

Returns:

  • (IO)

    UI error output. Defaults to $stderr.



35
36
37
# File 'lib/vagrant/ui.rb', line 35

def stderr
  @stderr
end

#stdinIO

Returns UI input. Defaults to $stdin.

Returns:

  • (IO)

    UI input. Defaults to $stdin.



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

def stdin
  @stdin
end

#stdoutIO

Returns UI output. Defaults to $stdout.

Returns:

  • (IO)

    UI output. Defaults to $stdout.



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

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)


71
72
73
# File 'lib/vagrant/ui.rb', line 71

def color?
  return false
end

#initialize_copy(original) ⇒ Object



46
47
48
49
# File 'lib/vagrant/ui.rb', line 46

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



79
80
81
# File 'lib/vagrant/ui.rb', line 79

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:



86
87
88
# File 'lib/vagrant/ui.rb', line 86

def rewriting
  yield self
end

#to_protoObject

Raises:

  • (NotImplementedError)


90
91
92
93
# File 'lib/vagrant/ui.rb', line 90

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