Skip to content

Commit 2b473e1

Browse files
committed
📚 Update ResponseText and ResponseCode rdoc
Use the terminology from the specifications ("status responses"), but include a note that these are different from "STATUS" responses.
1 parent cffc0e0 commit 2b473e1

File tree

1 file changed

+41
-24
lines changed

1 file changed

+41
-24
lines changed

lib/net/imap/response_data.rb

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,20 @@ class TaggedResponse < Struct.new(:tag, :name, :data, :raw_data)
160160
# The raw response data.
161161
end
162162

163-
# Net::IMAP::ResponseText represents texts of responses.
163+
# ResponseText represents texts of responses.
164164
#
165165
# The text may be prefixed by a ResponseCode.
166166
#
167-
# ResponseText is returned from TaggedResponse#data, or from
168-
# UntaggedResponse#data when the response type is a "condition" ("OK", "NO",
169-
# "BAD", "PREAUTH", or "BYE").
167+
# ResponseText is returned from TaggedResponse#data or
168+
# UntaggedResponse#data for
169+
# {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
170+
# * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
171+
# "+OK+", "+NO+", or "+BAD+".
172+
# * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
173+
# "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
174+
#
175+
# Note that these "status responses" are confusingly _not_ the same as the
176+
# +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
170177
class ResponseText < Struct.new(:code, :text)
171178
# Used to avoid an allocation when ResponseText is empty
172179
EMPTY = new(nil, "").freeze
@@ -184,32 +191,35 @@ class ResponseText < Struct.new(:code, :text)
184191
# Returns the response text, not including any response code
185192
end
186193

187-
# Net::IMAP::ResponseCode represents response codes. Response codes can be
188-
# retrieved from ResponseText#code and can be included in any "condition"
189-
# response: any TaggedResponse and UntaggedResponse when the response type
190-
# is a "condition" ("OK", "NO", "BAD", "PREAUTH", or "BYE").
194+
# ResponseCode represents an \IMAP response code, which can be retrieved
195+
# from ResponseText#code for
196+
# {"status responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1]:
197+
# * every TaggedResponse, name[rdoc-ref:TaggedResponse#name] is always
198+
# "+OK+", "+NO+", or "+BAD+".
199+
# * any UntaggedResponse when name[rdoc-ref:UntaggedResponse#name] is
200+
# "+OK+", "+NO+", "+BAD+", "+PREAUTH+", or "+BYE+".
201+
#
202+
# Note that these "status responses" are confusingly _not_ the same as the
203+
# +STATUS+ UntaggedResponse (see IMAP#status and StatusData).
191204
#
192205
# Some response codes come with additional data which will be parsed by
193206
# Net::IMAP. Others return +nil+ for #data, but are used as a
194207
# machine-readable annotation for the human-readable ResponseText#text in
195-
# the same response. When Net::IMAP does not know how to parse response
196-
# code text, #data returns the unparsed string.
208+
# the same response.
197209
#
198210
# Untagged response code #data is pushed directly onto Net::IMAP#responses,
199211
# keyed by #name, unless it is removed by the command that generated it.
200212
# Use Net::IMAP#add_response_handler to view tagged response codes for
201213
# command methods that do not return their TaggedResponse.
202214
#
215+
# == Standard response codes
216+
#
203217
# \IMAP extensions may define new codes and the data that comes with them.
204218
# The IANA {IMAP Response
205219
# Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
206220
# registry has links to specifications for all standard response codes.
207-
# Response codes are backwards compatible: Servers are allowed to send new
208-
# response codes even if the client has not enabled the extension that
209-
# defines them. When unknown response code data is encountered, #data
210-
# will return an unparsed string.
211221
#
212-
# ==== +IMAP4rev1+ Response Codes
222+
# === +IMAP4rev1+ response codes
213223
# See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
214224
# Responses - Status
215225
# Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
@@ -240,24 +250,24 @@ class ResponseText < Struct.new(:code, :text)
240250
# the <tt>\Seen</tt> flag set.
241251
# <em>DEPRECATED by IMAP4rev2.</em>
242252
#
243-
# ==== +BINARY+ extension
253+
# === +BINARY+ extension
244254
# See {[RFC3516]}[https://www.rfc-editor.org/rfc/rfc3516].
245255
# * +UNKNOWN-CTE+, with a tagged +NO+ response, when the server does not
246256
# known how to decode a CTE (content-transfer-encoding). #data is +nil+.
247257
# See IMAP#fetch.
248258
#
249-
# ==== +UIDPLUS+ extension
259+
# === +UIDPLUS+ extension
250260
# See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
251261
# * +APPENDUID+, #data is UIDPlusData. See IMAP#append.
252262
# * +COPYUID+, #data is UIDPlusData. See IMAP#copy.
253263
# * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
254264
#
255-
# ==== +SEARCHRES+ extension
265+
# === +SEARCHRES+ extension
256266
# See {[RFC5182]}[https://www.rfc-editor.org/rfc/rfc5182].
257267
# * +NOTSAVED+, with a tagged +NO+ response, when the search result variable
258268
# is not saved. #data is +nil+.
259269
#
260-
# ==== +RFC5530+ Response Codes
270+
# === +RFC5530+ response codes
261271
# See {[RFC5530]}[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
262272
# Codes" for the definition of the following response codes, which are all
263273
# machine-readable annotations for the human-readable ResponseText#text, and
@@ -280,22 +290,22 @@ class ResponseText < Struct.new(:code, :text)
280290
# * +ALREADYEXISTS+
281291
# * +NONEXISTENT+
282292
#
283-
# ==== +QRESYNC+ extension
293+
# === +QRESYNC+ extension
284294
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
285295
# * +CLOSED+, returned when the currently selected mailbox is closed
286296
# implicitly by selecting or examining another mailbox. #data is +nil+.
287297
#
288-
# ==== +IMAP4rev2+ Response Codes
298+
# === +IMAP4rev2+ response codes
289299
# See {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051] {§7.1, "Server
290300
# Responses - Status
291301
# Responses"}[https://www.rfc-editor.org/rfc/rfc9051#section-7.1] for full
292302
# descriptions of IMAP4rev2 response codes. IMAP4rev2 includes all of the
293-
# response codes listed above (except "UNSEEN") and adds the following:
303+
# response codes listed above (except "+UNSEEN+") and adds the following:
294304
# * +HASCHILDREN+, with a tagged +NO+ response, when a mailbox delete failed
295305
# because the server doesn't allow deletion of mailboxes with children.
296306
# #data is +nil+.
297307
#
298-
# ==== +CONDSTORE+ extension
308+
# === +CONDSTORE+ extension
299309
# See {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html].
300310
# * +NOMODSEQ+, when selecting a mailbox that does not support
301311
# mod-sequences. #data is +nil+. See IMAP#select.
@@ -305,10 +315,17 @@ class ResponseText < Struct.new(:code, :text)
305315
# since the +UNCHANGEDSINCE+ mod-sequence given to +STORE+ or <tt>UID
306316
# STORE</tt>.
307317
#
308-
# ==== +OBJECTID+ extension
318+
# === +OBJECTID+ extension
309319
# See {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html].
310320
# * +MAILBOXID+, #data is a string
311321
#
322+
# == Extension compatibility
323+
#
324+
# Response codes are backwards compatible: Servers are allowed to send new
325+
# response codes even if the client has not enabled the extension that
326+
# defines them. When Net::IMAP does not know how to parse response
327+
# code text, #data returns the unparsed string.
328+
#
312329
class ResponseCode < Struct.new(:name, :data)
313330
##
314331
# method: name

0 commit comments

Comments
 (0)