From 958ecfa500d08c393e353a81b37994a04ec056b2 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Mon, 23 Jan 2017 18:22:22 -0800 Subject: [PATCH] PublicSuffix::List is no longer enumerable Although the list is still a collection of rules, the idea is that the internal list representation is shifting away from a simple collection, and looping over rules is not only discouraged but it may actually be impossible in the future. Moreover, including Enumerable will introduce a bunch of methods. Instead, if you really need to iterate over the collection, simply use #each that returns an Enumerator. --- CHANGELOG.md | 2 +- lib/public_suffix/list.rb | 3 --- test/unit/list_test.rb | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5a393b..ec8be7fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - CHANGED: `PublicSuffix::List#rules` is now protected. You should not rely on it as the internal rule representation is subject to change to optimize performances. - CHANGED: Removed `PublicSuffix::List.clear`, it was an unnecessary accessor method. Use `PublicSuffix::List.default = nil` if you **really** need to reset the default list. You shouldn't. - CHANGED: `PublicSuffix::List#select` is now private. You should not use it, instead use ``PublicSuffix::List#find`. - +- CHANGED: `PublicSuffix::List` no longer implements Enumerable. Instead, use `#each` to loop over, or get an Enumerator. #### Release 2.0.5 diff --git a/lib/public_suffix/list.rb b/lib/public_suffix/list.rb index fdf7b64f..549d35c6 100644 --- a/lib/public_suffix/list.rb +++ b/lib/public_suffix/list.rb @@ -35,10 +35,7 @@ module PublicSuffix # The {PublicSuffix::List.default} rule list is used # to tokenize and validate a domain. # - # {PublicSuffix::List} implements +Enumerable+ module. - # class List - include Enumerable DEFAULT_LIST_PATH = File.join(File.dirname(__FILE__), "..", "..", "data", "list.txt") diff --git a/test/unit/list_test.rb b/test/unit/list_test.rb index 5ef4de4c..15d3e6ca 100644 --- a/test/unit/list_test.rb +++ b/test/unit/list_test.rb @@ -224,7 +224,7 @@ def test_self_parse assert_equal 4, list.size rules = %w( com *.uk !british-library.uk blogspot.com ).map { |name| PublicSuffix::Rule.factory(name) } - assert_equal rules, list.to_a + assert_equal rules, list.each.to_a # private domains assert_equal false, list.find("com").private