Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readline fixes #95

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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