Skip to content

Commit 487f110

Browse files
committed
📚 Document connection state more consistently
Because a `#connection_state` attribute will be added, I'd like to consistently name the connection states everywhere they are used.
1 parent f89c8e9 commit 487f110

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

lib/net/imap.rb

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ module Net
4343
# To work on the messages within a mailbox, the client must
4444
# first select that mailbox, using either #select or #examine
4545
# (for read-only access). Once the client has successfully
46-
# selected a mailbox, they enter the "_selected_" state, and that
46+
# selected a mailbox, they enter the +selected+ state, and that
4747
# mailbox becomes the _current_ mailbox, on which mail-item
4848
# related commands implicitly operate.
4949
#
50+
# === Connection state
51+
#
52+
# Once an IMAP connection is established, the connection is in one of four
53+
# states: <tt>not authenticated</tt>, +authenticated+, +selected+, and
54+
# +logout+. Most commands are valid only in certain states.
55+
#
5056
# === Sequence numbers and UIDs
5157
#
5258
# Messages have two sorts of identifiers: message sequence
@@ -260,8 +266,9 @@ module Net
260266
#
261267
# - Net::IMAP.new: Creates a new \IMAP client which connects immediately and
262268
# waits for a successful server greeting before the method returns.
269+
# - #connection_state: Returns the connection state.
263270
# - #starttls: Asks the server to upgrade a clear-text connection to use TLS.
264-
# - #logout: Tells the server to end the session. Enters the "_logout_" state.
271+
# - #logout: Tells the server to end the session. Enters the +logout+ state.
265272
# - #disconnect: Disconnects the connection (without sending #logout first).
266273
# - #disconnected?: True if the connection has been closed.
267274
#
@@ -317,37 +324,36 @@ module Net
317324
# <em>In general, #capable? should be used rather than explicitly sending a
318325
# +CAPABILITY+ command to the server.</em>
319326
# - #noop: Allows the server to send unsolicited untagged #responses.
320-
# - #logout: Tells the server to end the session. Enters the "_logout_" state.
327+
# - #logout: Tells the server to end the session. Enters the +logout+ state.
321328
#
322329
# ==== Not Authenticated state
323330
#
324331
# In addition to the commands for any state, the following commands are valid
325-
# in the "<em>not authenticated</em>" state:
332+
# in the +not_authenticated+ state:
326333
#
327334
# - #starttls: Upgrades a clear-text connection to use TLS.
328335
#
329336
# <em>Requires the +STARTTLS+ capability.</em>
330337
# - #authenticate: Identifies the client to the server using the given
331338
# {SASL mechanism}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
332-
# and credentials. Enters the "_authenticated_" state.
339+
# and credentials. Enters the +authenticated+ state.
333340
#
334341
# <em>The server should list <tt>"AUTH=#{mechanism}"</tt> capabilities for
335342
# supported mechanisms.</em>
336343
# - #login: Identifies the client to the server using a plain text password.
337-
# Using #authenticate is generally preferred. Enters the "_authenticated_"
338-
# state.
344+
# Using #authenticate is preferred. Enters the +authenticated+ state.
339345
#
340346
# <em>The +LOGINDISABLED+ capability</em> <b>must NOT</b> <em>be listed.</em>
341347
#
342348
# ==== Authenticated state
343349
#
344350
# In addition to the commands for any state, the following commands are valid
345-
# in the "_authenticated_" state:
351+
# in the +authenticated+ state:
346352
#
347353
# - #enable: Enables backwards incompatible server extensions.
348354
# <em>Requires the +ENABLE+ or +IMAP4rev2+ capability.</em>
349-
# - #select: Open a mailbox and enter the "_selected_" state.
350-
# - #examine: Open a mailbox read-only, and enter the "_selected_" state.
355+
# - #select: Open a mailbox and enter the +selected+ state.
356+
# - #examine: Open a mailbox read-only, and enter the +selected+ state.
351357
# - #create: Creates a new mailbox.
352358
# - #delete: Permanently remove a mailbox.
353359
# - #rename: Change the name of a mailbox.
@@ -369,12 +375,12 @@ module Net
369375
#
370376
# ==== Selected state
371377
#
372-
# In addition to the commands for any state and the "_authenticated_"
373-
# commands, the following commands are valid in the "_selected_" state:
378+
# In addition to the commands for any state and the +authenticated+
379+
# commands, the following commands are valid in the +selected+ state:
374380
#
375-
# - #close: Closes the mailbox and returns to the "_authenticated_" state,
381+
# - #close: Closes the mailbox and returns to the +authenticated+ state,
376382
# expunging deleted messages, unless the mailbox was opened as read-only.
377-
# - #unselect: Closes the mailbox and returns to the "_authenticated_" state,
383+
# - #unselect: Closes the mailbox and returns to the +authenticated+ state,
378384
# without expunging any messages.
379385
# <em>Requires the +UNSELECT+ or +IMAP4rev2+ capability.</em>
380386
# - #expunge: Permanently removes messages which have the Deleted flag set.
@@ -395,7 +401,7 @@ module Net
395401
#
396402
# ==== Logout state
397403
#
398-
# No \IMAP commands are valid in the "_logout_" state. If the socket is still
404+
# No \IMAP commands are valid in the +logout+ state. If the socket is still
399405
# open, Net::IMAP will close it after receiving server confirmation.
400406
# Exceptions will be raised by \IMAP commands that have already started and
401407
# are waiting for a response, as well as any that are called after logout.
@@ -449,7 +455,7 @@ module Net
449455
# ==== RFC3691: +UNSELECT+
450456
# Folded into IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051] and also included
451457
# above with {Core IMAP commands}[rdoc-ref:Net::IMAP@Core+IMAP+commands].
452-
# - #unselect: Closes the mailbox and returns to the "_authenticated_" state,
458+
# - #unselect: Closes the mailbox and returns to the +authenticated+ state,
453459
# without expunging any messages.
454460
#
455461
# ==== RFC4314: +ACL+

0 commit comments

Comments
 (0)