From c3f92f166d469f9fb41491d8df0bf59bb7792fc8 Mon Sep 17 00:00:00 2001 From: HASUMI Hitoshi Date: Sun, 15 Oct 2023 00:17:41 +0900 Subject: [PATCH] Face::FaceConfig -> Face::Config --- lib/reline/face.rb | 6 +++--- test/reline/test_face.rb | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/reline/face.rb b/lib/reline/face.rb index 7dc140926b..af98d5fb82 100644 --- a/lib/reline/face.rb +++ b/lib/reline/face.rb @@ -55,7 +55,7 @@ class Reline::Face } }.freeze - class FaceConfig + class Config def initialize(name, &block) @name = name block.call(self) @@ -111,7 +111,7 @@ def rgb_expression?(color) CONFIGS = {} - private_constant :SGR_PARAMETERS, :FaceConfig, :CONFIGS + private_constant :SGR_PARAMETERS, :Config, :CONFIGS def self.[](name) CONFIGS[name] @@ -119,7 +119,7 @@ def self.[](name) def self.config(name, override = true, &block) return if CONFIGS[name] && !override - CONFIGS[name] = FaceConfig.new(name, &block) + CONFIGS[name] = Config.new(name, &block) end end diff --git a/test/reline/test_face.rb b/test/reline/test_face.rb index 30b5c0bda4..f8d3ddd7b5 100644 --- a/test/reline/test_face.rb +++ b/test/reline/test_face.rb @@ -83,43 +83,43 @@ def test_invalid_background_name end def test_private_constants - [:SGR_PARAMETER, :FaceConfig, :CONFIGS].each do |name| + [:SGR_PARAMETER, :Config, :CONFIGS].each do |name| assert_equal false, Reline::Face.constants.include?(name) end end end - class FaceConfigTest < self + class ConfigTest < self def setup - @face_config = Reline::Face.const_get(:FaceConfig).new(:my_config) { } + @config = Reline::Face.const_get(:Config).new(:my_config) { } end def test_rgb? - assert_equal true, @face_config.send(:rgb_expression?, "#FFFFFF") + assert_equal true, @config.send(:rgb_expression?, "#FFFFFF") end def test_invalid_rgb? - assert_equal false, @face_config.send(:rgb_expression?, "FFFFFF") - assert_equal false, @face_config.send(:rgb_expression?, "#FFFFF") + assert_equal false, @config.send(:rgb_expression?, "FFFFFF") + assert_equal false, @config.send(:rgb_expression?, "#FFFFF") end def test_format_to_sgr assert_equal( "\e[37;41;1;3m", - @face_config.send(:format_to_sgr, foreground: :white, background: :red, style: [:bold, :italicized]) + @config.send(:format_to_sgr, foreground: :white, background: :red, style: [:bold, :italicized]) ) end def test_format_to_sgr_with_single_style assert_equal( "\e[37;41;1m", - @face_config.send(:format_to_sgr, foreground: :white, background: :red, style: :bold) + @config.send(:format_to_sgr, foreground: :white, background: :red, style: :bold) ) end def test_sgr_rgb - assert_equal "38;2;255;255;255", @face_config.send(:sgr_rgb, :foreground, "#ffffff") - assert_equal "48;2;18;52;86", @face_config.send(:sgr_rgb, :background, "#123456") + assert_equal "38;2;255;255;255", @config.send(:sgr_rgb, :foreground, "#ffffff") + assert_equal "48;2;18;52;86", @config.send(:sgr_rgb, :background, "#123456") end end end