summaryrefslogtreecommitdiff
path: root/tool/colorize.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-04 18:10:09 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-04 18:10:49 +0900
commitfade26afa72282ee9e2dbbc2e74cd9ea45674dc6 (patch)
tree6e75e03431d9751211f30131870253982cb17362 /tool/colorize.rb
parenta57d6d2325ddc71363414acf2f923db0bf0ddc9c (diff)
colorize.rb: get rid of syntax errors on older versions
Diffstat (limited to 'tool/colorize.rb')
-rw-r--r--tool/colorize.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/tool/colorize.rb b/tool/colorize.rb
index 92ed2b5765..855e1331ad 100644
--- a/tool/colorize.rb
+++ b/tool/colorize.rb
@@ -1,13 +1,13 @@
# frozen-string-literal: true
class Colorize
- def initialize(color = nil, colors_file: nil)
+ def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
@colors = @reset = nil
if color or (color == nil && STDOUT.tty?)
- if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
+ if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", :err => IO::NULL, &:read) rescue nil)
@beg = "\e["
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
- if colors_file
+ if opts and colors_file = opts[:colors_file]
begin
File.read(colors_file).scan(/(\w+)=([^:\n]*)/) do |n, c|
colors[n] ||= c