Sha256: cece3d770b3cd888e799f0bfd009cb78eafa94146c7a4df26ddba0d7990dfdeb
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module WebTranslateIt class Util DEFAULT_TERMINAL_COLORS = "\e[0m\e[37m\e[40m" MONOCHROME_OUTPUT = "\\1" def self.version hash = YAML.load_file File.join(File.dirname(__FILE__), '..', '..' '/version.yml') [hash[:major], hash[:minor], hash[:patch]].join('.') end def self.colourise_output? @colourise_output = !!(RUBY_PLATFORM !~ /mswin/ || defined?(Win32::Console::ANSI)) if @colourise_output.nil? @colourise_output end def self.subs_colour(data) data = data.gsub(%r{<b>(.*?)</b>}m, colourise_output? ? "\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT) data.gsub!(%r{<red>(.*?)</red>}m, colourise_output? ? "\e[1m\e[31m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT) data.gsub!(%r{<green>(.*?)</green>}m, colourise_output? ? "\e[1m\e[32m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT) data.gsub!(%r{<yellow>(.*?)</yellow>}m, colourise_output? ? "\e[1m\e[33m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT) data.gsub!(%r{<banner>(.*?)</banner>}m, colourise_output? ? "\e[33m\e[44m\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT) data end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
web_translate_it-1.4.2 | lib/web_translate_it/util.rb |
web_translate_it-1.4.1 | lib/web_translate_it/util.rb |