Sha256: a4a4224f67ff7bc6b3cec4f0cfb8b792640733b2df09deea098129b0b8b9d6d0
Contents?: true
Size: 1.14 KB
Versions: 56
Compression:
Stored size: 1.14 KB
Contents
# -*- coding: utf-8 -*- # # Copyright 2013 whiteleaf. All rights reserved. # class String if $disable_color def termcolor TermColorLight.strip_tag(self, false) end else require "termcolorlight/html" def termcolor TermColorLight.to_html(self) end end end # # 標準出力をフックする # # $stdout を介した出力は echo イベントとして全てのクライアントへ送信される # class Narou::StreamingLogger < StringIO include Narou::LoggerModule attr_reader :push_server def initialize(push_server = nil) super() @push_server = push_server end def tty? false end def copy_instance self.class.new(@push_server).tap do |obj| obj.silent = silent end end def strip_color(str) if $disable_color str else str.gsub(%r!</?span.*?>!, "") end end def push_streaming(str) unless @is_silent @push_server.send_all(echo: str) if @push_server end end def write(str) str = str.to_s if str.encoding == Encoding::ASCII_8BIT str.force_encoding(Encoding::UTF_8) end super(str) push_streaming(str) end end
Version data entries
56 entries across 56 versions & 1 rubygems