class ChefApply::UI::PlainTextElement
Public Class Methods
new(format, opts)
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 21 def initialize(format, opts) @orig_format = format @format = format @output = opts[:output] end
Public Instance Methods
auto_spin()
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 74 def auto_spin; end
error()
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 64 def error @err = true @succ = false end
run() { || ... }
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 27 def run(&block) yield end
success()
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 69 def success @succ = true @err = false end
update(params)
click to toggle source
# File lib/chef_apply/ui/plain_text_element.rb, line 31 def update(params) # Some of this is particular to our usage - # prefix does not cause a text update, but does # change the prefix for future messages. if params.key?(:prefix) @format = @orig_format.gsub(":prefix", params[:prefix]) return end if @succ ind = "OK" @succ = false log_method = :info elsif @err ind = "ERR" @err = false log_method = :error else log_method = :debug ind = " - " end # Since this is a generic type, we can replace any component # name in this regex - but for now :spinner is the only component # we're standing in for. msg = @format.gsub(/:spinner/, ind) params.each_pair do |k, v| msg.gsub!(/:#{k}/, v) end ChefApply::Log.send(log_method, msg) @output.puts(msg) end