Class: Furnish::Vagrant::UI
- Inherits:
-
Object
- Object
- Furnish::Vagrant::UI
- Includes:
- Logger::Mixins
- Defined in:
- lib/furnish/vagrant/ui.rb
Overview
This is a UI driver for Vagrant, that allows it to log through Furnish::Logger.
Class Attribute Summary collapse
-
.debug_level ⇒ Object
This is the debug_level concept from Furnish::Logger, and will be used to determine whether to log vagrant output or not.
Instance Attribute Summary collapse
-
#resource ⇒ Object
Resource name for Vagrant’s use.
Instance Method Summary collapse
-
#ask(*args) ⇒ Object
ask is useless for our needs so we just raise similar to Vagrant::UI::Silent.
-
#initialize(resource) ⇒ UI
constructor
Create a Furnish::Vagrant::UI object.
-
#say(message, opts = nil) ⇒ Object
We don’t really care about Vagrant’s log levels, so they all go to this call.
Constructor Details
#initialize(resource) ⇒ UI
Create a Furnish::Vagrant::UI object. See Vagrant::UI::Interface’s constructor for more information.
37 38 39 40 |
# File 'lib/furnish/vagrant/ui.rb', line 37 def initialize(resource) @resource = resource self.class.debug_level ||= 2 # XXX this modifies all instances, not just this one. end |
Class Attribute Details
.debug_level ⇒ Object
This is the debug_level concept from Furnish::Logger, and will be used to determine whether to log vagrant output or not.
This value is shared across all UI objects, and defaults to 2 the first time a UI object is constructed.
26 27 28 |
# File 'lib/furnish/vagrant/ui.rb', line 26 def debug_level @debug_level end |
Instance Attribute Details
#resource ⇒ Object
Resource name for Vagrant’s use. See Vagrant::UI::Interface.
31 32 33 |
# File 'lib/furnish/vagrant/ui.rb', line 31 def resource @resource end |
Instance Method Details
#ask(*args) ⇒ Object
ask is useless for our needs so we just raise similar to Vagrant::UI::Silent.
66 67 68 |
# File 'lib/furnish/vagrant/ui.rb', line 66 def ask(*args) raise Errors::UIExpectsTTY end |
#say(message, opts = nil) ⇒ Object
We don’t really care about Vagrant’s log levels, so they all go to this call. Makes an attempt to emulate vagrant’s log output, consults the debug_level to determine whether to send anything to the log. If a resource has been set, adds that to the beginning of the log line.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/furnish/vagrant/ui.rb', line 48 def say(, opts=nil) res = resource if_debug(self.class.debug_level) do if res puts "[%s] %s" % [res, ] else puts end end end |