Navigation Menu

Skip to content

Commit

Permalink
PublicSuffix::List is no longer enumerable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weppos committed Jan 24, 2017
1 parent 010c60b commit 958ecfa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions lib/public_suffix/list.rb
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion test/unit/list_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 958ecfa

Please sign in to comment.