ruby-changes:55586
From: Takashi <ko1@a...>
Date: Sun, 28 Apr 2019 21:52:13 +0900 (JST)
Subject: [ruby-changes:55586] Takashi Kokubun:f2d7ba6a74 (trunk): make sync-default-gems GEM=irb
https://git.ruby-lang.org/ruby.git/commit/?id=f2d7ba6a74 From f2d7ba6a7473b408002c90b77b021fc837f93561 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Sun, 28 Apr 2019 21:51:35 +0900 Subject: make sync-default-gems GEM=irb from https://github.com/ruby/irb/commit/e8e79d569ed59fe4ed4fbca968917ce799f02a5e. This colorizes Range object on IRB inspect. diff --git a/lib/irb/color.rb b/lib/irb/color.rb index aec66cd..7af7118 100644 --- a/lib/irb/color.rb +++ b/lib/irb/color.rb @@ -47,17 +47,17 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L47 end def inspect_colorable?(obj) - if obj.is_a?(Module) && obj.name - return true - end - case obj + when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass + true when Hash obj.all? { |k, v| inspect_colorable?(k) && inspect_colorable?(v) } when Array obj.all? { |o| inspect_colorable?(o) } - when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass - true + when Range + inspect_colorable?(obj.begin) && inspect_colorable?(obj.end) + when Module + !obj.name.nil? else false end diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index e6186ef..3305c24 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -44,6 +44,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L44 ['foo', :bar] => true, { a: 4 } => true, /reg/ => true, + (1..3) => true, Object.new => false, Struct => true, Test => true, -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/