Skip to content

Conversation

@nevans
Copy link
Collaborator

@nevans nevans commented Feb 7, 2025

Backports all of the following PRs to v0.4-stable:

With only a few simple exceptions (relating to differences in rdoc, versioned defaults in config.rb, and the autoloads in response_data.rb) cherry-picking went smoothly and without conflicts.

This adds the following new methods to Net::IMAP::SequenceSet:

  • #count_with_duplicates: The ordered entries version of #count.
  • #count_duplicates: The difference between #count and #count_with_duplicates.
  • #has_duplicates?: Returns whether #count_duplicates is positive.
  • #each_ordered_number: The ordered entries version of #each_number.
  • #find_ordered_index: The ordered entries version of #find_index.
  • #ordered_at: The ordered entries version of #at.

nevans added 12 commits February 7, 2025 09:02
`===` is not an alias for `cover?`.  It delegates to `cover?` but
handles errors differently.
`#each_range` and `#each_number` were previously tested indirectly via
`#ranges` and `#numbers`, but this adds tests on them directly.
This splits off "normalized" vs "order preserving" methods in the
"What's here?" sections.
Adds three new SequenceSet methods for querying about "duplicates":
* `#has_duplicates?`: Returns whether the ordered entries contain any
  duplicates.
* `#count_duplicates`: Returns the count of duplicates in the ordered
  entries.
* `#count_with_duplicates`: Returns the count of numbers in the ordered
  entries, including any repeated numbers.

This is useful for adding guards to `CopyUIDData` and `UIDPlusData`, and
for getting the size of `SequenceSet#each_ordered_number` (another PR).
Less duplication, still fairly easy to read, IMO.
Yields each number in the ordered entries and returns +self+.
In `#count`, "*" is treated as if it is effectively UINT32_MAX.  That
was also the intention for `#count_with_duplicates`.

Unlike `#count`, which can assume that `*` only appears at most once,
`#count_with_duplicates` needs to check each entry.

This means that, e.g:
   SequenceSet["#{UINT32_MAX}:*"].count_with_duplicates == 1
   SequenceSet["#{UINT32_MAX},*"].count_with_duplicates == 2
This is the ordered entries version of `#find_index`.
Some of the `#[negative index]` specs were using non-negative indexes.
They've been updated to use negative indexes.

Previously, `#at` was indirectly tested only by the `SequenceSet#[]`
test and the randomized "compare to reference Set" tests.  The new tests
specifically explicitly focus on `#[]`.
This is the ordered entries variation of `#at`.
@nevans nevans added documentation Improvements or additions to documentation enhancement New feature or request backport This issue or PR is for a stable release branch labels Feb 7, 2025
@nevans nevans merged commit 6b4b143 into v0.4-stable Feb 7, 2025
30 checks passed
@nevans nevans deleted the backport-0.4-sequence_set-ordered branch February 7, 2025 14:42
@nevans nevans added the sequence-set Any code the IMAP `sequence-set` data type or grammar rule, especially the SequenceSet class. label Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This issue or PR is for a stable release branch documentation Improvements or additions to documentation enhancement New feature or request sequence-set Any code the IMAP `sequence-set` data type or grammar rule, especially the SequenceSet class.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants