[前][次][番号順一覧][スレッド一覧]

ruby-changes:55993

From: Nobuyoshi <ko1@a...>
Date: Tue, 4 Jun 2019 18:09:39 +0900 (JST)
Subject: [ruby-changes:55993] Nobuyoshi Nakada: a57d6d2325 (trunk): colorize.rb: make `colors_file` optional

https://git.ruby-lang.org/ruby.git/commit/?id=a57d6d2325

From a57d6d2325ddc71363414acf2f923db0bf0ddc9c Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 4 Jun 2019 18:08:21 +0900
Subject: colorize.rb: make `colors_file` optional

[ci skip]

diff --git a/tool/colorize.rb b/tool/colorize.rb
index ed79858..92ed2b5 100644
--- a/tool/colorize.rb
+++ b/tool/colorize.rb
@@ -1,17 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/tool/colorize.rb#L1
 # frozen-string-literal: true
 
 class Colorize
-  def initialize(color = nil)
+  def initialize(color = nil, colors_file: nil)
     @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)
         @beg = "\e["
         colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
-        begin
-          File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
-            colors[n] ||= c
+        if colors_file
+          begin
+            File.read(colors_file).scan(/(\w+)=([^:\n]*)/) do |n, c|
+              colors[n] ||= c
+            end
+          rescue Errno::ENOENT
           end
-        rescue Errno::ENOENT
         end
         @colors = colors
         @reset = "#{@beg}m"
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]