Skip to content

Commit 744b743

Browse files
committed
Deprecate third and fourth parameter
1 parent a19c099 commit 744b743

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Other:
2222

2323
- Add keyword arguments to `Unicode::DisplayWidth.of`. If you are using a hash
2424
with overwrite value, be sure to put it in curly braces.
25+
- Using third parameter or explicit hash as fourth parameter is deprecated,
26+
please migrate to the keyword arguments API
2527
- Gem raises ArgumentError for ambiguous values other than 1 or 2
2628
- Performance optimizations
2729

lib/unicode/display_width.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DisplayWidth
3535
# Returns monospace display width of string
3636
def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
3737
unless old_options.empty?
38-
warn ArgumentError, "Unicode::DisplayWidth: Please migrate to keyword arguments: #{old_options.inspect}"
38+
warn "Unicode::DisplayWidth: Please migrate to keyword arguments - #{old_options.inspect}"
3939
options.merge! old_options
4040
end
4141

@@ -46,8 +46,8 @@ def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **option
4646
raise ArgumentError, "Unicode::DisplayWidth: Ambiguous width must be 1 or 2"
4747
end
4848

49-
if overwrite
50-
# warn "Unicode::DisplayWidth: Deprecated, please use overwrite: {} keyword options instead of passing overwrites as third parameter"
49+
if overwrite && !overwrite.empty?
50+
warn "Unicode::DisplayWidth: Please migrate to keyword arguments - overwrite: #{overwrite.inspect}"
5151
options[:overwrite] = overwrite
5252
end
5353
options[:overwrite] ||= {}

0 commit comments

Comments
 (0)