Skip to content

Commit

Permalink
[fix] Readline fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fazibear committed Jun 19, 2023
1 parent 4498bb6 commit 2985e83
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AllCops:
TargetRubyVersion: 2.6
DisplayCopNames: false
StyleGuideCopsOnly: false
NewCops: enable
Layout/AccessModifierIndentation:
Description: Check indentation of private/protected visibility modifiers.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
Expand Down
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
source 'https://rubygems.org'

gemspec

gem 'json', '~> 2.0', :group => :development
gem 'minitest', '~> 5.0', :group => :development
gem 'rake', '~> 13.0', :group => :development
gem 'rubocop', '~> 1.0', :group => :development
gem 'rubocop-github', '~> 0.20', :group => :development
gem 'rubocop-minitest', '~> 0.29.0', :group => :development
gem 'rubocop-performance', '~> 1.16', :group => :development
gem 'rubocop-rake', '~> 0.6', :group => :development
9 changes: 0 additions & 9 deletions colorize.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ Gem::Specification.new do |s|

s.require_paths = ['lib']

s.add_development_dependency 'json', '~> 2.0'
s.add_development_dependency 'minitest', '~> 5.0'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rubocop', '~> 1.0'
s.add_development_dependency 'rubocop-github', '~> 0.20'
s.add_development_dependency 'rubocop-minitest', '~> 0.29.0'
s.add_development_dependency 'rubocop-performance', '~> 1.16'
s.add_development_dependency 'rubocop-rake', '~> 0.6'

s.files = [
'LICENSE',
'CHANGELOG.md',
Expand Down
2 changes: 1 addition & 1 deletion lib/colorize/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def mode(mode)
# Scan for colorized string
#
def scan_for_colors
scan(/\001\033\[([0-9;]+)m\002(.+?)\001\033\[0m\002|([^\001\033]+)/m).map do |match|
scan(/\001?\033\[([0-9;]+)m\002?(.+?)\001?\033\[0m\002?|([^\001?\033]+)/m).map do |match|
split_colors(match)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/colorize/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Gem version
#
module Colorize
VERSION = '1.0.0'
VERSION = '1.0.1'
end
4 changes: 4 additions & 0 deletions test/test_colorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,8 @@ def test_prevent_colors

String.prevent_colors false
end

def test_colorized_string_without_readline
assert_equal "\e[0;31;49mgreen\e[0m".green, 'green'.green
end
end
8 changes: 5 additions & 3 deletions test/test_colorized_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ def test_already_colored_string_with_one_value
end

def test_color_matrix_method
assert_raises NoMethodError do
ColorizedString.color_matrix
end
assert_raises(NoMethodError) { ColorizedString.color_matrix }
end

def test_color_samples_method
Expand Down Expand Up @@ -211,4 +209,8 @@ def test_prevent_colors

ColorizedString.prevent_colors false
end

def test_colorized_string_without_readline
assert_equal ColorizedString["\e[0;31;49mgreen\e[0m"].green, ColorizedString['green'].green
end
end

0 comments on commit 2985e83

Please sign in to comment.