diff options
author | Pete Higgins <pete@peterhiggins.org> | 2017-06-23 16:06:35 -0700 |
---|---|---|
committer | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-06-25 01:13:25 -0300 |
commit | 09bf55b401ee1d6082f15dffc8b460d7c7c71732 (patch) | |
tree | a09820fd8ae5968fced9a05306f2ebdfc4399701 | |
parent | 84d2a24e83e069069d09ff02460446a0a67e28e6 (diff) | |
download | highline-09bf55b401ee1d6082f15dffc8b460d7c7c71732.tar.gz |
Add method to reset use_color setting.
-rwxr-xr-x | lib/highline.rb | 11 | ||||
-rwxr-xr-x | test/test_highline.rb | 7 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index 33ae934..8476bcc 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -52,6 +52,14 @@ class HighLine @use_color end + # Resets the use of color. + def self.reset_use_color + @use_color = true + end + + # Use color output by default. + reset_use_color + # For checking if the current version of HighLine supports RGB colors # Usage: HighLine.supports_rgb_color? rescue false # rescue for compatibility with older versions # Note: color usage also depends on HighLine.use_color being set @@ -96,10 +104,11 @@ class HighLine end # Reset HighLine to default. - # Clears Style index and reset color scheme. + # Clears Style index and resets color_scheme and use_color settings. def self.reset Style.clear_index reset_color_scheme + reset_use_color end # Reset color scheme to default (+nil+) diff --git a/test/test_highline.rb b/test/test_highline.rb index 7897326..94e6f2c 100755 --- a/test/test_highline.rb +++ b/test/test_highline.rb @@ -603,6 +603,13 @@ class TestHighLine < Minitest::Test $terminal = old_glob_term end + def test_reset_use_color + HighLine.use_color = false + refute HighLine.use_color? + HighLine.reset_use_color + assert HighLine.use_color? + end + def test_uncolor # instance method assert_equal( "This should be reverse underlined magenta!\n", |