Sha256: cf6925631be78b4dbfe728c3e98c2ea00b3bd1b73123116eeff4c301eba2c1a1

Contents?: true

Size: 712 Bytes

Versions: 5

Compression:

Stored size: 712 Bytes

Contents

require "email/mboxrd/message"
require "imap/backup/serializer/mbox_enumerator"

module Imap::Backup
  class Serializer::MessageEnumerator
    attr_reader :imap
    attr_reader :mbox

    def initialize(imap:, mbox:)
      @imap = imap
      @mbox = mbox
    end

    def run(uids:)
      indexes = uids.each.with_object({}) do |uid_maybe_string, acc|
        uid = uid_maybe_string.to_i
        index = imap.index(uid)
        acc[index] = uid if index
      end
      enumerator = Serializer::MboxEnumerator.new(mbox.pathname)
      enumerator.each.with_index do |raw, i|
        uid = indexes[i]
        next if !uid

        yield uid, Email::Mboxrd::Message.from_serialized(raw)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
imap-backup-6.3.0 lib/imap/backup/serializer/message_enumerator.rb
imap-backup-6.2.1 lib/imap/backup/serializer/message_enumerator.rb
imap-backup-6.1.0 lib/imap/backup/serializer/message_enumerator.rb
imap-backup-6.0.1 lib/imap/backup/serializer/message_enumerator.rb
imap-backup-6.0.0 lib/imap/backup/serializer/message_enumerator.rb