From 2add52e094d9b3307aba4928214f0d038b60081b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 27 Dec 2018 00:02:02 -0800 Subject: [PATCH 1/2] Require Ruby 2.2 or later Remove support for EOL Ruby releases and remove the unf gem that is no longer required by doing so. This greatly reduces memory usage. Signed-off-by: Tim Smith --- .travis.yml | 5 ----- domain_name.gemspec | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index e120c4c..f3cbfc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,5 @@ language: ruby rvm: - - 1.8.7 - - ree - - 1.9.3 - - 2.0.0 - - 2.1.9 - 2.2.5 - 2.3.1 - ruby-head diff --git a/domain_name.gemspec b/domain_name.gemspec index 7ac4c82..e927706 100644 --- a/domain_name.gemspec +++ b/domain_name.gemspec @@ -19,8 +19,7 @@ Suffix List. gem.licenses = ["BSD-2-Clause", "BSD-3-Clause", "MPL-2.0"] gem.files = `git ls-files`.split($/) - gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.test_files = gem.files.grep(%r{^test/}) gem.require_paths = ["lib"] gem.extra_rdoc_files = [ @@ -28,7 +27,8 @@ Suffix List. "README.md" ] - gem.add_runtime_dependency("unf", ["< 1.0.0", ">= 0.0.5"]) + gem.required_ruby_version = ">= 2.2" + gem.add_development_dependency("test-unit", "~> 2.5.5") gem.add_development_dependency("bundler", [">= 1.2.0"]) gem.add_development_dependency("rake", [">= 0.9.2.2", *("< 11" if RUBY_VERSION < "1.9")]) From cffb14a5215eff45e84d27e8ef63e69267a5754f Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 27 Dec 2018 00:04:58 -0800 Subject: [PATCH 2/2] Use unicode_normalize instead of unf Signed-off-by: Tim Smith --- lib/domain_name.rb | 4 ++-- test/test_domain_name-punycode.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/domain_name.rb b/lib/domain_name.rb index 739570b..436c8d2 100644 --- a/lib/domain_name.rb +++ b/lib/domain_name.rb @@ -8,7 +8,7 @@ require 'domain_name/version' require 'domain_name/punycode' require 'domain_name/etld_data' -require 'unf' +require 'unicode_normalize/normalize' require 'ipaddr' # Represents a domain name ready for extracting its registered domain @@ -286,7 +286,7 @@ class << self # Normalizes a _domain_ using the Punycode algorithm as necessary. # The result will be a downcased, ASCII-only string. def normalize(domain) - DomainName::Punycode.encode_hostname(domain.chomp(DOT).to_nfc).downcase + DomainName::Punycode.encode_hostname(domain.chomp(DOT).unicode_normalize).downcase end end end diff --git a/test/test_domain_name-punycode.rb b/test/test_domain_name-punycode.rb index 5e601f2..7a76d3b 100644 --- a/test/test_domain_name-punycode.rb +++ b/test/test_domain_name-punycode.rb @@ -91,7 +91,7 @@ class TestDomainName < Test::Unit::TestCase '-> $1.00 <--'] ].each { |title, cps, punycode| assert_equal punycode, DomainName::Punycode.encode(cps.pack('U*')), title - assert_equal cps.pack('U*').to_nfc, DomainName::Punycode.decode(punycode), title + assert_equal cps.pack('U*').unicode_normalize, DomainName::Punycode.decode(punycode), title } end end