net-imap 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90ea9e3ff227103752eda7658da755be8f4aabda8fdf60f33379f95c27a1a69c
4
- data.tar.gz: b7878cec3bdd9216ee1eda01fe8276c1753f01de6bd875988415665150b5fb00
3
+ metadata.gz: e933100b505623a478f75c60fa9daab5da7a67c0e68a5b0cf83db20e4a362f65
4
+ data.tar.gz: 79e288f7011385db37f53be45d801cc4fc96b2ba5a08db9c3b7b0bed462989d1
5
5
  SHA512:
6
- metadata.gz: df018d07e090469ff814af057d94ee4c8b9327071bc173f6f10aa106385071bd39076c334e195f163a670c756b3379a38ffcb00b46248a06b80b3d4aa3ed04c1
7
- data.tar.gz: b6215f30153f034d04bfe6d0006da68cb0beee20ec15c2664283d2c766b5a37b9fddfaec82a0fa94a36233e175e81a492829a7094fda4581dc847573e572f0e9
6
+ metadata.gz: c4d1fa03ef8db7e5311437c04ee11d4f22017d1a289e63eb8c9c0a64b0816722cb68793c92313ace4b738675eb7bad091007e914c9b381e1e61df35a5dd12ccd
7
+ data.tar.gz: 6532ed39b47bc4fa70be3430d64f385c19a07087ee5c223a066ce42b00c77d5c99661d78a32347e32475175b8431fbabfcb1b8c351b9fb9b931ff5d859e25f87
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /Gemfile.lock
11
+ benchmarks/Gemfile*
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gem "rake"
8
8
  gem "rdoc"
9
9
  gem "test-unit"
10
10
  gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
11
+
12
+ gem "benchmark-driver"
@@ -47,7 +47,27 @@ module Net
47
47
  class ByeResponseError < ResponseError
48
48
  end
49
49
 
50
+ # Error raised when the server sends an invalid response.
51
+ #
52
+ # This is different from UnknownResponseError: the response has been
53
+ # rejected. Although it may be parsable, the server is forbidden from
54
+ # sending it in the current context. The client should automatically
55
+ # disconnect, abruptly (without logout).
56
+ #
57
+ # Note that InvalidResponseError does not inherit from ResponseError: it
58
+ # can be raised before the response is fully parsed. A related
59
+ # ResponseParseError or ResponseError may be the #cause.
60
+ class InvalidResponseError < Error
61
+ end
62
+
50
63
  # Error raised upon an unknown response from the server.
64
+ #
65
+ # This is different from InvalidResponseError: the response may be a
66
+ # valid extension response and the server may be allowed to send it in
67
+ # this context, but Net::IMAP either does not know how to parse it or
68
+ # how to handle it. This could result from enabling unknown or
69
+ # unhandled extensions. The connection may still be usable,
70
+ # but—depending on context—it may be prudent to disconnect.
51
71
  class UnknownResponseError < ResponseError
52
72
  end
53
73
 
@@ -55,17 +55,54 @@ module Net
55
55
 
56
56
  # Net::IMAP::IgnoredResponse represents intentionally ignored responses.
57
57
  #
58
- # This includes untagged response "NOOP" sent by eg. Zimbra to avoid some
59
- # clients to close the connection.
58
+ # This includes untagged response "NOOP" sent by eg. Zimbra to avoid
59
+ # some clients to close the connection.
60
60
  #
61
61
  # It matches no IMAP standard.
62
+ class IgnoredResponse < UntaggedResponse
63
+ end
64
+
65
+ # **Note:** This represents an intentionally _unstable_ API. Where
66
+ # instances of this class are returned, future releases may return a
67
+ # different (incompatible) object <em>without deprecation or warning</em>.
68
+ #
69
+ # Net::IMAP::UnparsedData represents data for unknown response types or
70
+ # unknown extensions to response types without a well-defined extension
71
+ # grammar.
62
72
  #
63
- class IgnoredResponse < Struct.new(:raw_data)
73
+ # See also: UnparsedNumericResponseData
74
+ class UnparsedData < Struct.new(:unparsed_data)
64
75
  ##
65
- # method: raw_data
66
- # :call-seq: raw_data -> string
76
+ # method: unparsed_data
77
+ # :call-seq: unparsed_data -> string
67
78
  #
68
- # The raw response data.
79
+ # The unparsed data
80
+ end
81
+
82
+ # **Note:** This represents an intentionally _unstable_ API. Where
83
+ # instances of this class are returned, future releases may return a
84
+ # different (incompatible) object <em>without deprecation or warning</em>.
85
+ #
86
+ # Net::IMAP::UnparsedNumericResponseData represents data for unhandled
87
+ # response types with a numeric prefix. See the documentation for #number.
88
+ #
89
+ # See also: UnparsedData
90
+ class UnparsedNumericResponseData < Struct.new(:number, :unparsed_data)
91
+ ##
92
+ # method: number
93
+ # :call-seq: number -> integer
94
+ #
95
+ # Returns a numeric response data prefix, when available.
96
+ #
97
+ # Many response types are prefixed with a non-negative #number. For
98
+ # message data, #number may represent a sequence number or a UID. For
99
+ # mailbox data, #number may represent a message count.
100
+
101
+ ##
102
+ # method: unparsed_data
103
+ # :call-seq: unparsed_data -> string
104
+ #
105
+ # The unparsed data, not including #number or UntaggedResponse#name.
69
106
  end
70
107
 
71
108
  # Net::IMAP::TaggedResponse represents tagged responses.
@@ -108,6 +145,9 @@ module Net
108
145
  # UntaggedResponse#data when the response type is a "condition" ("OK", "NO",
109
146
  # "BAD", "PREAUTH", or "BYE").
110
147
  class ResponseText < Struct.new(:code, :text)
148
+ # Used to avoid an allocation when ResponseText is empty
149
+ EMPTY = new(nil, "").freeze
150
+
111
151
  ##
112
152
  # method: code
113
153
  # :call-seq: code -> ResponseCode or nil
@@ -170,6 +170,16 @@ module Net
170
170
  @token ||= next_token
171
171
  end
172
172
 
173
+ # like match, without consuming the token
174
+ def lookahead!(*args)
175
+ if args.include?((@token ||= next_token)&.symbol)
176
+ @token
177
+ else
178
+ parse_error('unexpected token %s (expected %s)',
179
+ @token&.symbol, args.join(" or "))
180
+ end
181
+ end
182
+
173
183
  def peek_str?(str)
174
184
  assert_no_lookahead if Net::IMAP.debug
175
185
  @str[@pos, str.length] == str