Skip to content

Commit 908e2a4

Browse files
committed
📚 Document the RFC specification for each command [🚧 missing some]
1 parent ca966f4 commit 908e2a4

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

lib/net/imap.rb

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,10 @@ def disconnected?
425425
return @sock.closed?
426426
end
427427

428-
# Sends a CAPABILITY command, and returns an array of
429-
# capabilities that the server supports. Each capability
430-
# is a string.
428+
# Sends a {CAPABILITY command [IMAP4rev1
429+
# §6.1.1]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.1.1] and returns
430+
# an array of capabilities that the server supports. Each capability is a
431+
# string.
431432
#
432433
# See the {IANA IMAP4 capabilities
433434
# registry}[http://www.iana.org/assignments/imap4-capabilities] for a list
@@ -462,8 +463,9 @@ def capability
462463
end
463464
end
464465

465-
# Sends an ID command, and returns a hash of the server's
466-
# response, or nil if the server does not identify itself.
466+
# Sends an {ID command}[https://tools.ietf.org/html/rfc2971] and returns
467+
# a hash of the server's response, or nil if the server does not identify
468+
# itself.
467469
#
468470
# Note that the user should first check if the server supports the ID
469471
# capability. For example:
@@ -491,19 +493,25 @@ def id(client_id=nil)
491493
end
492494
end
493495

494-
# Sends a NOOP command to the server. It does nothing.
496+
# Sends a {NOOP command [IMAP4rev1
497+
# §6.1.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.1.2] to the
498+
# server.
495499
def noop
496500
send_command("NOOP")
497501
end
498502

499-
# Sends a LOGOUT command to inform the server that the client is
500-
# done with the connection.
503+
# Sends a {LOGOUT command [IMAP4rev1
504+
# §6.1.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.1.3] to inform
505+
# the command to inform the server that the client is done with the
506+
# connection.
501507
def logout
502508
send_command("LOGOUT")
503509
end
504510

505-
# Sends a STARTTLS command to start TLS session.
506-
# Sends a STARTTLS command to start a TLS session.
511+
##
512+
# Sends a {STARTTLS command [IMAP4rev1
513+
# §6.2.1]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.2.1]: to start a
514+
# TLS session.
507515
#
508516
# ===== Capability
509517
#
@@ -525,9 +533,12 @@ def starttls(options = {}, verify = true)
525533
end
526534
end
527535

528-
# Sends an AUTHENTICATE command to authenticate the client.
529-
# The +auth_type+ parameter is a string that represents
530-
# the authentication mechanism to be used. Currently Net::IMAP
536+
# Sends an {AUTHENTICATE command [IMAP4rev1
537+
# §6.2.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.2.2]) to
538+
# authenticate the client.
539+
#
540+
# The +auth_type+ parameter is a string that
541+
# represents the authentication mechanism to be used. Currently Net::IMAP
531542
# supports the following mechanisms:
532543
#
533544
# PLAIN:: Login using cleartext user and password. Secure with TLS.
@@ -583,10 +594,11 @@ def authenticate(auth_type, *args)
583594
end
584595
end
585596

586-
# Sends a LOGIN command to identify the client and carries
587-
# the plaintext +password+ authenticating this +user+. Note
588-
# that, unlike calling #authenticate with an +auth_type+
589-
# of "LOGIN", #login does *not* use the login authenticator.
597+
# Sends a {LOGIN command [IMAP4rev1
598+
# §6.2.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.2.3]: to
599+
# identify the client and carries the plaintext +password+ authenticating
600+
# this +user+. Note that, unlike calling #authenticate with an +auth_type+
601+
# of "LOGIN", #login does *not* use the LoginAuthenticator.
590602
#
591603
# A Net::IMAP::NoResponseError is raised if authentication fails.
592604
#
@@ -601,8 +613,9 @@ def login(user, password)
601613
send_command("LOGIN", user, password)
602614
end
603615

604-
# Sends a SELECT command to select a +mailbox+ so that messages
605-
# in the +mailbox+ can be accessed.
616+
# Sends a {SELECT command [IMAP4rev1
617+
# §6.3.1]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.3.1] to select a
618+
# +mailbox+ so that messages in the +mailbox+ can be accessed.
606619
#
607620
# After you have selected a mailbox, you may retrieve the number of items in
608621
# that mailbox from <tt>imap.responses["EXISTS"][-1]</tt>, and the number of
@@ -628,9 +641,11 @@ def select(mailbox)
628641
end
629642
end
630643

631-
# Sends a EXAMINE command to select a +mailbox+ so that messages
632-
# in the +mailbox+ can be accessed. Behaves the same as #select,
633-
# except that the selected +mailbox+ is identified as read-only.
644+
# Sends a {EXAMINE command [IMAP4rev1
645+
# §6.3.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.3.2] to select a
646+
# +mailbox+ so that messages in the +mailbox+ can be accessed. Behaves the
647+
# same as #select, except that the selected +mailbox+ is identified as
648+
# read-only.
634649
#
635650
# A Net::IMAP::NoResponseError is raised if the mailbox does not
636651
# exist or is for some reason non-examinable.
@@ -641,15 +656,19 @@ def examine(mailbox)
641656
end
642657
end
643658

644-
# Sends a CREATE command to create a new +mailbox+.
659+
# Sends a {CREATE command [IMAP4rev1
660+
# §6.3.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.3.3] to create a
661+
# new +mailbox+.
645662
#
646663
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
647664
# cannot be created.
648665
def create(mailbox)
649666
send_command("CREATE", mailbox)
650667
end
651668

652-
# Sends a DELETE command to remove the +mailbox+.
669+
# Sends a {DELETE command [IMAP4rev1
670+
# §6.3.4]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.3.4] to remove
671+
# the +mailbox+.
653672
#
654673
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
655674
# cannot be deleted, either because it does not exist or because the
@@ -658,8 +677,9 @@ def delete(mailbox)
658677
send_command("DELETE", mailbox)
659678
end
660679

661-
# Sends a RENAME command to change the name of the +mailbox+ to
662-
# +newname+.
680+
# Sends a {RENAME command [IMAP4rev1
681+
# §6.3.5]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.3.5] to change
682+
# the name of the +mailbox+ to +newname+.
663683
#
664684
# A Net::IMAP::NoResponseError is raised if a mailbox with the
665685
# name +mailbox+ cannot be renamed to +newname+ for whatever
@@ -988,9 +1008,10 @@ def check
9881008
send_command("CHECK")
9891009
end
9901010

991-
# Sends a CLOSE command to close the currently selected mailbox.
992-
# The CLOSE command permanently removes from the mailbox all
993-
# messages that have the \Deleted flag set.
1011+
# Sends a {CLOSE command [IMAP4rev1
1012+
# §6.4.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.2] to close
1013+
# the currently selected mailbox. The CLOSE command permanently removes
1014+
# from the mailbox all messages that have the <tt>\\Deleted</tt> flag set.
9941015
def close
9951016
send_command("CLOSE")
9961017
end

0 commit comments

Comments
 (0)