net-imap 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of net-imap might be problematic. Click here for more details.

@@ -2,6 +2,8 @@
2
2
 
3
3
  module Net
4
4
  class IMAP < Protocol
5
+ autoload :FetchData, "#{__dir__}/fetch_data"
6
+ autoload :SequenceSet, "#{__dir__}/sequence_set"
5
7
 
6
8
  # Net::IMAP::ContinuationRequest represents command continuation requests.
7
9
  #
@@ -70,7 +72,7 @@ module Net
70
72
  # unknown extensions to response types without a well-defined extension
71
73
  # grammar.
72
74
  #
73
- # See also: UnparsedNumericResponseData
75
+ # See also: UnparsedNumericResponseData, ExtensionData, IgnoredResponse
74
76
  class UnparsedData < Struct.new(:unparsed_data)
75
77
  ##
76
78
  # method: unparsed_data
@@ -86,7 +88,7 @@ module Net
86
88
  # Net::IMAP::UnparsedNumericResponseData represents data for unhandled
87
89
  # response types with a numeric prefix. See the documentation for #number.
88
90
  #
89
- # See also: UnparsedData
91
+ # See also: UnparsedData, ExtensionData, IgnoredResponse
90
92
  class UnparsedNumericResponseData < Struct.new(:number, :unparsed_data)
91
93
  ##
92
94
  # method: number
@@ -105,6 +107,23 @@ module Net
105
107
  # The unparsed data, not including #number or UntaggedResponse#name.
106
108
  end
107
109
 
110
+ # **Note:** This represents an intentionally _unstable_ API. Where
111
+ # instances of this class are returned, future releases may return a
112
+ # different (incompatible) object <em>without deprecation or warning</em>.
113
+ #
114
+ # Net::IMAP::ExtensionData represents data that is parsable according to the
115
+ # forward-compatible extension syntax in RFC3501, RFC4466, or RFC9051, but
116
+ # isn't directly known or understood by Net::IMAP yet.
117
+ #
118
+ # See also: UnparsedData, UnparsedNumericResponseData, IgnoredResponse
119
+ class ExtensionData < Struct.new(:data)
120
+ ##
121
+ # method: data
122
+ # :call-seq: data -> string
123
+ #
124
+ # The parsed extension data.
125
+ end
126
+
108
127
  # Net::IMAP::TaggedResponse represents tagged responses.
109
128
  #
110
129
  # The server completion result response indicates the success or
@@ -237,6 +256,10 @@ module Net
237
256
  # * +ALREADYEXISTS+
238
257
  # * +NONEXISTENT+
239
258
  #
259
+ # Other supported \IMAP extension response codes:
260
+ # * +OBJECTID+ {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html#section-7]
261
+ # * +MAILBOXID+, #data will be a string
262
+ #
240
263
  class ResponseCode < Struct.new(:name, :data)
241
264
  ##
242
265
  # method: name
@@ -488,210 +511,6 @@ module Net
488
511
  # "UIDVALIDITY", "UNSEEN". Each value is a number.
489
512
  end
490
513
 
491
- # Net::IMAP::FetchData represents the contents of a FETCH response.
492
- #
493
- # Net::IMAP#fetch and Net::IMAP#uid_fetch both return an array of
494
- # FetchData objects.
495
- #
496
- # === Fetch attributes
497
- #
498
- #--
499
- # TODO: merge branch with accessor methods for each type of attr. Then
500
- # move nearly all of the +attr+ documentation onto the appropriate
501
- # accessor methods.
502
- #++
503
- #
504
- # Each key of the #attr hash is the data item name for the fetched value.
505
- # Each data item represents a message attribute, part of one, or an
506
- # interpretation of one. #seqno is not a message attribute. Most message
507
- # attributes are static and must never change for a given <tt>[server,
508
- # account, mailbox, UIDVALIDITY, UID]</tt> tuple. A few message attributes
509
- # can be dynamically changed, e.g. using the {STORE
510
- # command}[rdoc-ref:Net::IMAP#store].
511
- #
512
- # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
513
- # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2]
514
- # for full description of the standard fetch response data items, and
515
- # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
516
- #
517
- # ==== Static fetch data items
518
- #
519
- # The static data items
520
- # defined by [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501.html]] are:
521
- #
522
- # [<tt>"UID"</tt>]
523
- # A number expressing the unique identifier of the message.
524
- #
525
- # [<tt>"BODY[]"</tt>, <tt>"BODY[]<#{offset}>"</tt>]
526
- # The [RFC5322[https://tools.ietf.org/html/rfc5322]] expression of the
527
- # entire message, as a string.
528
- #
529
- # If +offset+ is specified, this returned string is a substring of the
530
- # entire contents, starting at that origin octet. This means that
531
- # <tt>BODY[]<0></tt> MAY be truncated, but <tt>BODY[]</tt> is NEVER
532
- # truncated.
533
- #
534
- # <em>Messages can be parsed using the "mail" gem.</em>
535
- #
536
- # [Note]
537
- # When fetching <tt>BODY.PEEK[#{specifier}]</tt>, the data will be
538
- # returned in <tt>BODY[#{specifier}]</tt>, without the +PEEK+. This is
539
- # true for all of the <tt>BODY[...]</tt> attribute forms.
540
- #
541
- # [<tt>"BODY[HEADER]"</tt>, <tt>"BODY[HEADER]<#{offset}>"</tt>]
542
- # The [RFC5322[https://tools.ietf.org/html/rfc5322]] header of the
543
- # message.
544
- #
545
- # <em>Message headers can be parsed using the "mail" gem.</em>
546
- #
547
- # [<tt>"BODY[HEADER.FIELDS (#{fields.join(" ")})]"</tt>,]
548
- # [<tt>"BODY[HEADER.FIELDS (#{fields.join(" ")})]<#{offset}>"</tt>]
549
- # When field names are given, the subset contains only the header fields
550
- # that matches one of the names in the list. The field names are based
551
- # on what was requested, not on what was returned.
552
- #
553
- # [<tt>"BODY[HEADER.FIELDS.NOT (#{fields.join(" ")})]"</tt>,]
554
- # [<tt>"BODY[HEADER.FIELDS.NOT (#{fields.join(" ")})]<#{offset}>"</tt>]
555
- # When the <tt>HEADER.FIELDS.NOT</tt> is used, the subset is all of the
556
- # fields that <em>do not</em> match any names in the list.
557
- #
558
- # [<tt>"BODY[TEXT]"</tt>, <tt>"BODY[TEXT]<#{offset}>"</tt>]
559
- # The text body of the message, omitting
560
- # the [RFC5322[https://tools.ietf.org/html/rfc5322]] header.
561
- #
562
- # [<tt>"BODY[#{part}]"</tt>, <tt>"BODY[#{part}]<#{offset}>"</tt>]
563
- # The text of a particular body section, if it was fetched.
564
- #
565
- # Multiple part specifiers will be joined with <tt>"."</tt>. Numeric
566
- # part specifiers refer to the MIME part number, counting up from +1+.
567
- # Messages that don't use MIME, or MIME messages that are not multipart
568
- # and don't hold an encapsulated message, only have a part +1+.
569
- #
570
- # 8-bit textual data is permitted if
571
- # a [CHARSET[https://tools.ietf.org/html/rfc2978]] identifier is part of
572
- # the body parameter parenthesized list for this section. See
573
- # BodyTypeBasic.
574
- #
575
- # MESSAGE/RFC822 or MESSAGE/GLOBAL message, or a subset of the header, if
576
- # it was fetched.
577
- #
578
- # [<tt>"BODY[#{part}.HEADER]"</tt>,]
579
- # [<tt>"BODY[#{part}.HEADER]<#{offset}>"</tt>,]
580
- # [<tt>"BODY[#{part}.HEADER.FIELDS.NOT (#{fields.join(" ")})]"</tt>,]
581
- # [<tt>"BODY[#{part}.HEADER.FIELDS.NOT (#{fields.join(" ")})]<#{offset}>"</tt>,]
582
- # [<tt>"BODY[#{part}.TEXT]"</tt>,]
583
- # [<tt>"BODY[#{part}.TEXT]<#{offset}>"</tt>,]
584
- # [<tt>"BODY[#{part}.MIME]"</tt>,]
585
- # [<tt>"BODY[#{part}.MIME]<#{offset}>"</tt>]
586
- # +HEADER+, <tt>HEADER.FIELDS</tt>, <tt>HEADER.FIELDS.NOT</tt>, and
587
- # <tt>TEXT</tt> can be prefixed by numeric part specifiers, if it refers
588
- # to a part of type <tt>message/rfc822</tt> or <tt>message/global</tt>.
589
- #
590
- # +MIME+ refers to the [MIME-IMB[https://tools.ietf.org/html/rfc2045]]
591
- # header for this part.
592
- #
593
- # [<tt>"BODY"</tt>]
594
- # A form of +BODYSTRUCTURE+, without any extension data.
595
- #
596
- # [<tt>"BODYSTRUCTURE"</tt>]
597
- # Returns a BodyStructure object that describes
598
- # the [MIME-IMB[https://tools.ietf.org/html/rfc2045]] body structure of
599
- # a message, if it was fetched.
600
- #
601
- # [<tt>"ENVELOPE"</tt>]
602
- # An Envelope object that describes the envelope structure of a message.
603
- # See the documentation for Envelope for a description of the envelope
604
- # structure attributes.
605
- #
606
- # [<tt>"INTERNALDATE"</tt>]
607
- # The internal date and time of the message on the server. This is not
608
- # the date and time in
609
- # the [RFC5322[https://tools.ietf.org/html/rfc5322]] header, but rather
610
- # a date and time which reflects when the message was received.
611
- #
612
- # [<tt>"RFC822.SIZE"</tt>]
613
- # A number expressing the [RFC5322[https://tools.ietf.org/html/rfc5322]]
614
- # size of the message.
615
- #
616
- # [Note]
617
- # \IMAP was originally developed for the older RFC-822 standard, and
618
- # as a consequence several fetch items in \IMAP incorporate "RFC822"
619
- # in their name. With the exception of +RFC822.SIZE+, there are more
620
- # modern replacements; for example, the modern version of
621
- # +RFC822.HEADER+ is <tt>BODY.PEEK[HEADER]</tt>. In all cases,
622
- # "RFC822" should be interpreted as a reference to the
623
- # updated [RFC5322[https://tools.ietf.org/html/rfc5322]] standard.
624
- #
625
- # [<tt>"RFC822"</tt>]
626
- # Semantically equivalent to <tt>BODY[]</tt>.
627
- # [<tt>"RFC822.HEADER"</tt>]
628
- # Semantically equivalent to <tt>BODY[HEADER]</tt>.
629
- # [<tt>"RFC822.TEXT"</tt>]
630
- # Semantically equivalent to <tt>BODY[TEXT]</tt>.
631
- #
632
- # [Note:]
633
- # >>>
634
- # Additional static fields are defined in \IMAP extensions and
635
- # [IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051.html]], but
636
- # Net::IMAP can't parse them yet.
637
- #
638
- #--
639
- # <tt>"BINARY[#{section_binary}]<#{offset}>"</tt>:: TODO...
640
- # <tt>"BINARY.SIZE[#{sectionbinary}]"</tt>:: TODO...
641
- # <tt>"EMAILID"</tt>:: TODO...
642
- # <tt>"THREADID"</tt>:: TODO...
643
- # <tt>"SAVEDATE"</tt>:: TODO...
644
- #++
645
- #
646
- # ==== Dynamic message attributes
647
- # The only dynamic item defined
648
- # by [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501.html]] is:
649
- # [<tt>"FLAGS"</tt>]
650
- # An array of flags that are set for this message. System flags are
651
- # symbols that have been capitalized by String#capitalize. Keyword
652
- # flags are strings and their case is not changed.
653
- #
654
- # \IMAP extensions define new dynamic fields, e.g.:
655
- #
656
- # [<tt>"MODSEQ"</tt>]
657
- # The modification sequence number associated with this IMAP message.
658
- #
659
- # Requires the [CONDSTORE[https://tools.ietf.org/html/rfc7162]]
660
- # server {capability}[rdoc-ref:Net::IMAP#capability].
661
- #
662
- # [Note:]
663
- # >>>
664
- # Additional dynamic fields are defined in \IMAP extensions, but
665
- # Net::IMAP can't parse them yet.
666
- #
667
- #--
668
- # <tt>"ANNOTATE"</tt>:: TODO...
669
- # <tt>"PREVIEW"</tt>:: TODO...
670
- #++
671
- #
672
- class FetchData < Struct.new(:seqno, :attr)
673
- ##
674
- # method: seqno
675
- # :call-seq: seqno -> Integer
676
- #
677
- # The message sequence number.
678
- #
679
- # [Note]
680
- # This is never the unique identifier (UID), not even for the
681
- # Net::IMAP#uid_fetch result. If it was returned, the UID is available
682
- # from <tt>attr["UID"]</tt>.
683
-
684
- ##
685
- # method: attr
686
- # :call-seq: attr -> hash
687
- #
688
- # A hash. Each key is specifies a message attribute, and the value is the
689
- # corresponding data item.
690
- #
691
- # See rdoc-ref:FetchData@Fetch+attributes for descriptions of possible
692
- # values.
693
- end
694
-
695
514
  # Net::IMAP::Envelope represents envelope structures of messages.
696
515
  #
697
516
  # [Note]
@@ -705,6 +524,7 @@ module Net
705
524
  # for full description of the envelope fields, and
706
525
  # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
707
526
  #
527
+ # Returned by FetchData#envelope
708
528
  class Envelope < Struct.new(:date, :subject, :from, :sender, :reply_to,
709
529
  :to, :cc, :bcc, :in_reply_to, :message_id)
710
530
  ##
@@ -1123,7 +943,6 @@ module Net
1123
943
  # * description[rdoc-ref:BodyTypeBasic#description]
1124
944
  # * encoding[rdoc-ref:BodyTypeBasic#encoding]
1125
945
  # * size[rdoc-ref:BodyTypeBasic#size]
1126
- #
1127
946
  class BodyTypeMessage < Struct.new(:media_type, :subtype,
1128
947
  :param, :content_id,
1129
948
  :description, :encoding, :size,
@@ -8,7 +8,7 @@ module Net
8
8
  # (internal API, subject to change)
9
9
  module ParserUtils # :nodoc:
10
10
 
11
- module Generator
11
+ module Generator # :nodoc:
12
12
 
13
13
  LOOKAHEAD = "(@token ||= next_token)"
14
14
  SHIFT_TOKEN = "(@token = nil)"