-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add color aliases #75
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some files could not be reviewed due to errors:
cannot load such file -- rubocop-minitest
cannot load such file -- rubocop-minitest /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `require' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `each' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:43:in `load_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:83:in `configuration_from_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_store.rb:44:in `for' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:181:in `apply_default_formatter' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:40:in `run' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:13:in `block in ' /usr/local/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:12:in `' /home/linters/.bundle/bin/rubocop:23:in `load' /home/linters/.bundle/bin/rubocop:23:in `' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in ' /usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some files could not be reviewed due to errors:
cannot load such file -- rubocop-minitest
cannot load such file -- rubocop-minitest /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `require' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `each' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:43:in `load_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:83:in `configuration_from_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_store.rb:44:in `for' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:181:in `apply_default_formatter' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:40:in `run' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:13:in `block in ' /usr/local/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:12:in `' /home/linters/.bundle/bin/rubocop:23:in `load' /home/linters/.bundle/bin/rubocop:23:in `' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in ' /usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some files could not be reviewed due to errors:
cannot load such file -- rubocop-minitest
cannot load such file -- rubocop-minitest /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `require' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `each' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:43:in `load_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_loader.rb:83:in `configuration_from_file' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/config_store.rb:44:in `for' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:181:in `apply_default_formatter' /home/linters/.bundle/gems/rubocop-0.54.0/lib/rubocop/cli.rb:40:in `run' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:13:in `block in ' /usr/local/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' /home/linters/.bundle/gems/rubocop-0.54.0/bin/rubocop:12:in `' /home/linters/.bundle/bin/rubocop:23:in `load' /home/linters/.bundle/bin/rubocop:23:in `' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load' /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch' /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in ' /usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors' /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `'
@@ -1,5 +1,6 @@ | |||
# frozen_string_literal: true | |||
|
|||
require File.expand_path('colorize/errors', File.dirname(__FILE__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
# Check if color is missing | ||
# | ||
def check_if_color_exist!(color) | ||
color_codes[color] || fail(::Colorize::ColorDontExist, "Colorize: color :#{color} don't exist!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [102/80]
# Check if color exists | ||
# | ||
def check_if_color_available!(color) | ||
color_codes[color] && fail(::Colorize::ColorAlreadyExist, "Colorize: color named :#{color} already exist!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [113/80]
end | ||
|
||
define_method "on_#{key}" do | ||
colorize(:background => key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
# | ||
def add_color_method(key) | ||
define_method key do | ||
colorize(:color => key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
String.add_color_alias(extra_color_e: :gray, :extra_color_f => :blue) | ||
|
||
assert_equal 'example string'.gray, 'example string'.extra_color_e | ||
assert_equal 'example string'.on_blue, 'example string'.on_extra_color_f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
def test_add_color_alias_with_multi_hash_mixed | ||
String.add_color_alias(extra_color_e: :gray, :extra_color_f => :blue) | ||
|
||
assert_equal 'example string'.gray, 'example string'.extra_color_e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
|
||
def test_add_color_alias_with_multi_hash_mixed | ||
String.add_color_alias(extra_color_e: :gray, :extra_color_f => :blue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
String.add_color_alias(:extra_color_c => :gray, :extra_color_d => :blue) | ||
|
||
assert_equal 'example string'.gray, 'example string'.extra_color_c | ||
assert_equal 'example string'.on_blue, 'example string'.on_extra_color_d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
def test_add_color_alias_with_multi_hash_with_arrow | ||
String.add_color_alias(:extra_color_c => :gray, :extra_color_d => :blue) | ||
|
||
assert_equal 'example string'.gray, 'example string'.extra_color_c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
== 1.0.0 / 2023-03-23