Skip to content

Commit 3c90cec

Browse files
committed
📚 Add "Related:" rdoc for most Net::IMAP methods
There are a lot of IMAP commands! This makes it easier to navigate between them. Hopefully this makes it easier to learn the IMAP4rev1 protocol and its extensions, as well.
1 parent c2b3528 commit 3c90cec

File tree

1 file changed

+92
-4
lines changed

1 file changed

+92
-4
lines changed

lib/net/imap.rb

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ class << self
407407
end
408408

409409
# Disconnects from the server.
410+
#
411+
# Related: #logout
410412
def disconnect
411413
return if disconnected?
412414
begin
@@ -430,6 +432,8 @@ def disconnect
430432
end
431433

432434
# Returns true if disconnected from the server.
435+
#
436+
# Related: #logout, #disconnect
433437
def disconnected?
434438
return @sock.closed?
435439
end
@@ -525,20 +529,26 @@ def id(client_id=nil)
525529

526530
# Sends a {NOOP command [IMAP4rev1 §6.1.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.1.2]
527531
# to the server.
532+
#
533+
# Related: #idle, #check
528534
def noop
529535
send_command("NOOP")
530536
end
531537

532538
# Sends a {LOGOUT command [IMAP4rev1 §6.1.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.1.3]
533539
# to inform the command to inform the server that the client is done with
534540
# the connection.
541+
#
542+
# Related: #disconnect
535543
def logout
536544
send_command("LOGOUT")
537545
end
538546

539547
# Sends a {STARTTLS command [IMAP4rev1 §6.2.1]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.2.1]
540548
# to start a TLS session.
541549
#
550+
# Related: Net::IMAP.new, #login, #authenticate
551+
#
542552
# ===== Capability
543553
#
544554
# The server's capabilities must include +STARTTLS+.
@@ -602,6 +612,8 @@ def starttls(options = {}, verify = true)
602612
# See Net::IMAP::Authenticators for more information on plugging in your
603613
# own authenticator.
604614
#
615+
# Related: #login, #starttls
616+
#
605617
# ==== Capabilities
606618
#
607619
# Clients MUST NOT attempt to #authenticate or #login when +LOGINDISABLED+
@@ -634,6 +646,8 @@ def authenticate(auth_type, *args)
634646
#
635647
# A Net::IMAP::NoResponseError is raised if authentication fails.
636648
#
649+
# Related: #authenticate, #starttls
650+
#
637651
# ==== Capabilities
638652
# Clients MUST NOT attempt to #authenticate or #login when +LOGINDISABLED+
639653
# is listed with the capabilities.
@@ -660,6 +674,8 @@ def login(user, password)
660674
# A Net::IMAP::NoResponseError is raised if the mailbox does not
661675
# exist or is for some reason non-selectable.
662676
#
677+
# Related: #examine
678+
#
663679
# ===== Capabilities
664680
#
665681
# If [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]] is supported,
@@ -681,6 +697,8 @@ def select(mailbox)
681697
#
682698
# A Net::IMAP::NoResponseError is raised if the mailbox does not
683699
# exist or is for some reason non-examinable.
700+
#
701+
# Related: #select
684702
def examine(mailbox)
685703
synchronize do
686704
@responses.clear
@@ -693,6 +711,8 @@ def examine(mailbox)
693711
#
694712
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
695713
# cannot be created.
714+
#
715+
# Related: #rename, #delete
696716
def create(mailbox)
697717
send_command("CREATE", mailbox)
698718
end
@@ -703,6 +723,8 @@ def create(mailbox)
703723
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
704724
# cannot be deleted, either because it does not exist or because the
705725
# client does not have permission to delete it.
726+
#
727+
# Related: #create, #rename
706728
def delete(mailbox)
707729
send_command("DELETE", mailbox)
708730
end
@@ -714,6 +736,8 @@ def delete(mailbox)
714736
# name +mailbox+ cannot be renamed to +newname+ for whatever
715737
# reason; for instance, because +mailbox+ does not exist, or
716738
# because there is already a mailbox with the name +newname+.
739+
#
740+
# Related: #create, #delete
717741
def rename(mailbox, newname)
718742
send_command("RENAME", mailbox, newname)
719743
end
@@ -724,6 +748,8 @@ def rename(mailbox, newname)
724748
#
725749
# A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
726750
# subscribed to; for instance, because it does not exist.
751+
#
752+
# Related: #unsubscribe, #lsub, #list
727753
def subscribe(mailbox)
728754
send_command("SUBSCRIBE", mailbox)
729755
end
@@ -735,6 +761,8 @@ def subscribe(mailbox)
735761
# A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
736762
# unsubscribed from; for instance, because the client is not currently
737763
# subscribed to it.
764+
#
765+
# Related: #subscribe, #lsub, #list
738766
def unsubscribe(mailbox)
739767
send_command("UNSUBSCRIBE", mailbox)
740768
end
@@ -753,7 +781,11 @@ def unsubscribe(mailbox)
753781
# which mailboxes to match. If +mailbox+ is empty, the root
754782
# name of +refname+ and the hierarchy delimiter are returned.
755783
#
756-
# The return value is an array of MailboxList. For example:
784+
# The return value is an array of MailboxList.
785+
#
786+
# Related: #lsub, MailboxList
787+
#
788+
# ===== For example:
757789
#
758790
# imap.create("foo/bar")
759791
# imap.create("foo/baz")
@@ -806,7 +838,9 @@ def list(refname, mailbox)
806838
# of Namespace objects. These arrays will be empty when the
807839
# server responds with nil.
808840
#
809-
# For example:
841+
# Related: #list, Namespaces, Namespace
842+
#
843+
# ===== For example:
810844
#
811845
# capabilities = imap.capability
812846
# if capabilities.include?("NAMESPACE")
@@ -858,6 +892,8 @@ def namespace
858892
# #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
859893
# #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
860894
#
895+
# Related: #list, MailboxList
896+
#
861897
# ===== Capabilities
862898
#
863899
# The server's capabilities must include +XLIST+,
@@ -879,6 +915,8 @@ def xlist(refname, mailbox)
879915
# to both admin and user. If this mailbox exists, it returns an array
880916
# containing objects of type MailboxQuotaRoot and MailboxQuota.
881917
#
918+
# Related: #getquota, #setquota, MailboxQuotaRoot, MailboxQuota
919+
#
882920
# ===== Capabilities
883921
#
884922
# The server's capabilities must include +QUOTA+
@@ -898,6 +936,8 @@ def getquotaroot(mailbox)
898936
# containing a MailboxQuota object is returned. This command is generally
899937
# only available to server admin.
900938
#
939+
# Related: #getquotaroot, #setquota, MailboxQuota
940+
#
901941
# ===== Capabilities
902942
#
903943
# The server's capabilities must include +QUOTA+
@@ -914,6 +954,8 @@ def getquota(mailbox)
914954
# +quota+ will be unset for that mailbox. Typically one needs to be logged
915955
# in as a server admin for this to work.
916956
#
957+
# Related: #getquota, #getquotaroot
958+
#
917959
# ===== Capabilities
918960
#
919961
# The server's capabilities must include +QUOTA+
@@ -932,6 +974,8 @@ def setquota(mailbox, quota)
932974
# mailbox. If +rights+ is nil, then that user will be stripped of any
933975
# rights to that mailbox.
934976
#
977+
# Related: #getacl
978+
#
935979
# ===== Capabilities
936980
#
937981
# The server's capabilities must include +ACL+
@@ -948,6 +992,8 @@ def setacl(mailbox, user, rights)
948992
# along with a specified +mailbox+. If this mailbox exists, an array
949993
# containing objects of MailboxACLItem will be returned.
950994
#
995+
# Related: #setacl, MailboxACLItem
996+
#
951997
# ===== Capabilities
952998
#
953999
# The server's capabilities must include +ACL+
@@ -965,6 +1011,8 @@ def getacl(mailbox)
9651011
# interpreted as for #list.
9661012
#
9671013
# The return value is an array of MailboxList objects.
1014+
#
1015+
# Related: #subscribe, #unsubscribe, #list, MailboxList
9681016
def lsub(refname, mailbox)
9691017
synchronize do
9701018
send_command("LSUB", refname, mailbox)
@@ -1040,6 +1088,8 @@ def append(mailbox, message, flags = nil, date_time = nil)
10401088
# to request a checkpoint of the currently selected mailbox. This performs
10411089
# implementation-specific housekeeping; for instance, reconciling the
10421090
# mailbox's in-memory and on-disk state.
1091+
#
1092+
# Related: #idle, #noop
10431093
def check
10441094
send_command("CHECK")
10451095
end
@@ -1048,6 +1098,8 @@ def check
10481098
# to close the currently selected mailbox. The CLOSE command permanently
10491099
# removes from the mailbox all messages that have the <tt>\\Deleted</tt>
10501100
# flag set.
1101+
#
1102+
# Related: #unselect
10511103
def close
10521104
send_command("CLOSE")
10531105
end
@@ -1058,6 +1110,8 @@ def close
10581110
# "_authenticated_" state. This is the same as #close, except that
10591111
# <tt>\\Deleted</tt> messages are not removed from the mailbox.
10601112
#
1113+
# Related: #close
1114+
#
10611115
# ===== Capabilities
10621116
#
10631117
# The server's capabilities must include +UNSELECT+
@@ -1069,6 +1123,8 @@ def unselect
10691123
# Sends an {EXPUNGE command [IMAP4rev1 §6.4.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.3]
10701124
# Sends a EXPUNGE command to permanently remove from the currently
10711125
# selected mailbox all messages that have the \Deleted flag set.
1126+
#
1127+
# Related: #uid_expunge
10721128
def expunge
10731129
synchronize do
10741130
send_command("EXPUNGE")
@@ -1095,6 +1151,8 @@ def expunge
10951151
# #responses and this method returns them as an array of
10961152
# <em>sequence number</em> integers.
10971153
#
1154+
# Related: #expunge
1155+
#
10981156
# ===== Capabilities
10991157
#
11001158
# The server's capabilities must include +UIDPLUS+
@@ -1112,6 +1170,8 @@ def uid_expunge(uid_set)
11121170
# string holding the entire search string, or a single-dimension array of
11131171
# search keywords and arguments.
11141172
#
1173+
# Related: #uid_search
1174+
#
11151175
# ===== Search criteria
11161176
#
11171177
# The following are some common search criteria;
@@ -1183,7 +1243,9 @@ def uid_search(keys, charset = nil)
11831243
# The return value is an array of FetchData or nil
11841244
# (instead of an empty array) if there is no matching message.
11851245
#
1186-
# For example:
1246+
# Related: #uid_search, FetchData
1247+
#
1248+
# ===== For example:
11871249
#
11881250
# p imap.fetch(6..8, "UID")
11891251
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
@@ -1209,6 +1271,8 @@ def fetch(set, attr, mod = nil)
12091271
#
12101272
# Similar to #fetch, but the +set+ parameter contains unique identifiers
12111273
# instead of message sequence numbers.
1274+
#
1275+
# Related: #fetch, FetchData
12121276
def uid_fetch(set, attr, mod = nil)
12131277
return fetch_internal("UID FETCH", set, attr, mod)
12141278
end
@@ -1221,7 +1285,11 @@ def uid_fetch(set, attr, mod = nil)
12211285
# provided one, '+FLAGS' will add the provided flags, and '-FLAGS' will
12221286
# remove them. +flags+ is a list of flags.
12231287
#
1224-
# The return value is an array of FetchData. For example:
1288+
# The return value is an array of FetchData
1289+
#
1290+
# Related: #uid_store
1291+
#
1292+
# ===== For example:
12251293
#
12261294
# p imap.store(6..8, "+FLAGS", [:Deleted])
12271295
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
@@ -1237,6 +1305,8 @@ def store(set, attr, flags)
12371305
#
12381306
# Similar to #store, but +set+ contains unique identifiers instead of
12391307
# message sequence numbers.
1308+
#
1309+
# Related: #store
12401310
def uid_store(set, attr, flags)
12411311
return store_internal("UID STORE", set, attr, flags)
12421312
end
@@ -1246,6 +1316,8 @@ def uid_store(set, attr, flags)
12461316
# +mailbox+. The +set+ parameter is a number, an array of numbers, or a
12471317
# Range object. The number is a message sequence number.
12481318
#
1319+
# Related: #uid_copy
1320+
#
12491321
# ===== Capabilities
12501322
#
12511323
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
@@ -1275,6 +1347,8 @@ def uid_copy(set, mailbox)
12751347
# +mailbox+. The +set+ parameter is a number, an array of numbers, or a
12761348
# Range object. The number is a message sequence number.
12771349
#
1350+
# Related: #uid_move
1351+
#
12781352
# ===== Capabilities
12791353
#
12801354
# The server's capabilities must include +MOVE+
@@ -1296,6 +1370,8 @@ def move(set, mailbox)
12961370
#
12971371
# Similar to #move, but +set+ contains unique identifiers.
12981372
#
1373+
# Related: #move
1374+
#
12991375
# ===== Capabilities
13001376
#
13011377
# Same as #move: The server's capabilities must include +MOVE+
@@ -1309,6 +1385,8 @@ def uid_move(set, mailbox)
13091385
# to sort messages in the mailbox. Returns an array of message sequence
13101386
# numbers.
13111387
#
1388+
# Related: #uid_sort, #search, #uid_search, #thread, #uid_thread
1389+
#
13121390
# ===== For example:
13131391
#
13141392
# p imap.sort(["FROM"], ["ALL"], "US-ASCII")
@@ -1327,6 +1405,8 @@ def sort(sort_keys, search_keys, charset)
13271405
# Sends a {UID SORT command [RFC5256 §3]}[https://www.rfc-editor.org/rfc/rfc5256#section-3]
13281406
# to sort messages in the mailbox. Returns an array of unique identifiers.
13291407
#
1408+
# Related: #sort, #search, #uid_search, #thread, #uid_thread
1409+
#
13301410
# ===== Capabilities
13311411
#
13321412
# The server's capabilities must include +SORT+
@@ -1369,6 +1449,8 @@ def remove_response_handler(handler)
13691449
# Unlike #search, +charset+ is a required argument. US-ASCII
13701450
# and UTF-8 are sample values.
13711451
#
1452+
# Related: #uid_thread, #search, #uid_search, #sort, #uid_sort
1453+
#
13721454
# ===== Capabilities
13731455
#
13741456
# The server's capabilities must include +THREAD+
@@ -1381,6 +1463,8 @@ def thread(algorithm, search_keys, charset)
13811463
# Similar to #thread, but returns unique identifiers instead of
13821464
# message sequence numbers.
13831465
#
1466+
# Related: #thread, #search, #uid_search, #sort, #uid_sort
1467+
#
13841468
# ===== Capabilities
13851469
#
13861470
# The server's capabilities must include +THREAD+
@@ -1406,6 +1490,8 @@ def uid_thread(algorithm, search_keys, charset)
14061490
# end
14071491
# end
14081492
#
1493+
# Related: #idle_done, #noop, #check
1494+
#
14091495
# ===== Capabilities
14101496
#
14111497
# The server's capabilities must include +IDLE+
@@ -1440,6 +1526,8 @@ def idle(timeout = nil, &response_handler)
14401526
end
14411527

14421528
# Leaves IDLE.
1529+
#
1530+
# Related: #idle
14431531
def idle_done
14441532
synchronize do
14451533
if @idle_done_cond.nil?

0 commit comments

Comments
 (0)