Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add basic ESearch support #333

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on Nov 25, 2024

  1. ✨ Add Data polyfill for ruby 3.1

    For new data structs, I don't want to commit to supporting the entire
    Struct API and I'd prefer frozen by default.  `Data` is exactly what I
    want but it's not available until ruby 3.2.
    
    So this adds a DataLite class that closely matches ruby 3.2's Data
    class and can be a drop-in replacement for Data.  Net::IMAP::Data is an
    alias for Net::IMAP::DataLite, so when we remove this implementation,
    the constant will resolve to ruby's ::Data.  The most noticable
    incompatibility is that member names must be valid local variable names.
    
    Ideally, we wouldn't define this on newer ruby versions at all, but that
    breaks the YAML serialization for our test fixtures.  So, on newer
    versions of ruby, this class inherits from `Data` and only reimplements
    the two methods that are needed for YAML serialization.  This serves the
    additional purpose of ensuring that the same tests pass for both the
    core `Data` class and our reimplementation.
    
    Most of the test code and some of the implementation code has been
    copied from the polyfill-data gem and updated so that they use "Data" as
    it is resolved inside the "Net::IMAP" namespace.  Copyright notices have
    been added to the appropriate files to satisfy the MIT license terms.
    
    Co-authored-by: Jim Gay <[email protected]>
    nevans and saturnflyer committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    15c1692 View commit details
    Browse the repository at this point in the history
  2. ♻️ Extract superclass for (internal) command data

    The new `CommandData` superclass uses `Data` to add the pattern matching
    and equality methods while also simplifying the implementation.
    
    Specifically, I wanted RawData#deconstruct for the basic `ESEARCH`
    support branch.  It seemed reasonable to apply the same change to all of
    the internal command data classes.
    
    Please note: this does change these objects to be frozen.  However,
    these classes are explicitly undocumented and considered "internal", so
    this will _not_ be treated as a "breaking change".
    nevans committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    da3b43d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5f053cf View commit details
    Browse the repository at this point in the history
  4. ✨ Parsing ESEARCH, with examples from RFC9051

    Parses +ESEARCH+ into ESearchResult, with support for:
    * RFC4466 syntax
    * RFC4731 `ESEARCH`
    * RFC5267 `CONTEXT=SEARCH`
    * RFC6203 `SEARCH=FUZZY`
    * RFC9394 `PARTIAL`
    
    For compatibility, `ESearchResult#to_a` returns an array of integers
    (sequence numbers or UIDs) whenever any `ALL` or `PARTIAL` result is
    available.
    nevans committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    43dc285 View commit details
    Browse the repository at this point in the history
  5. ✨ Gather ESEARCH response to #search/#uid_search

    If the server returns both `ESEARCH` and `SEARCH`, both are cleared from
    the responses hash, but only the `ESEARCH` is returned.
    
    When the server doesn't send any search responses:  If return options
    are passed, return an empty ESearchResult.  It will have the appropriate
    `tag` and `uid` values, but no `data`.  Otherwise return an empty
    `SearchResult` (changed from empty array).
    nevans committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    a535b1f View commit details
    Browse the repository at this point in the history