Sha256: 5a9f4db566372e52a276eeb34d5f8d440a70edb03d66f288fc8d3fc4f5b1aa41
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module Rvm2 module Ui class Multi attr_reader :handlers def initialize(rvm2_plugins = nil) @rvm2_plugins = rvm2_plugins || Pluginator.find("rvm2", extends: %i{first_class}) @handlers = [] end def add(handler, *args) @handlers << @rvm2_plugins.first_class!('ui/output', handler).new(*args) end def remove @handlers.pop end def with(handler, *args, &block) add(handler, *args) block.call remove end # ui.command "message" { do_something; } def command(name, &block) raise "No block given" unless block_given? @handlers.each {|h| h.start(name) } status = block.call @handlers.each {|h| h.finish(status) } status end # ui.log 'message' # ui.log 'message', :important # standard types => :log, :warn, :important, :error # in case unsupported type is used :log will be used def log(message, type = :log) @handlers.each {|h| h.log(message, type) } end def stdout @stdout ||= IoWriteRouter.new(self, :stdout) end def stderr @stderr ||= IoWriteRouter.new(self, :stderr) end end end end require_relative 'multi/io_write_router'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rvm2-ui-0.9.0 | lib/rvm2/ui/multi.rb |