net-imap 0.5.10 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/net/imap/config/attr_type_coercion.rb +19 -6
- data/lib/net/imap/esearch_result.rb +42 -3
- data/lib/net/imap/search_result.rb +2 -3
- data/lib/net/imap/sequence_set.rb +3 -3
- data/lib/net/imap/vanished_data.rb +10 -1
- data/lib/net/imap.rb +18 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7f77489a5f69bb5cf159039328259e7a0e52d18453b8777ab312b7051ec0542
|
4
|
+
data.tar.gz: d2417b81c84dd93424983354ed42995bfc5af9ac30c8c115c75595a7746e5fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20e857ab3284f3c2748da9b7324909d99f87cf8bfe52f44f2e77ba49154a34d39f3008106388e8c2cc644b83a72a1c71ef042617b780173a8dbb49e2c11bc6f
|
7
|
+
data.tar.gz: a60ec27b5db745e3b77d7e9aa2fb75091941a84b4a6b39bf27bfd640361ca082b1861f3828efdfc31fa54090b3f851b68ba8cf5f11def050a4c49b319ce0b42d
|
@@ -28,10 +28,22 @@ module Net
|
|
28
28
|
end
|
29
29
|
private_class_method :included
|
30
30
|
|
31
|
-
if defined?(Ractor.
|
32
|
-
def self.safe(
|
31
|
+
if defined?(Ractor.shareable_proc)
|
32
|
+
def self.safe(&b)
|
33
|
+
case obj = b.call
|
34
|
+
when Proc
|
35
|
+
Ractor.shareable_proc(&obj)
|
36
|
+
else
|
37
|
+
Ractor.make_shareable obj
|
38
|
+
end
|
39
|
+
end
|
40
|
+
elsif defined?(Ractor.make_shareable)
|
41
|
+
def self.safe(&b)
|
42
|
+
obj = nil.instance_eval(&b).freeze
|
43
|
+
Ractor.make_shareable obj
|
44
|
+
end
|
33
45
|
else
|
34
|
-
def self.safe(
|
46
|
+
def self.safe(&b) nil.instance_eval(&b).freeze end
|
35
47
|
end
|
36
48
|
private_class_method :safe
|
37
49
|
|
@@ -48,10 +60,11 @@ module Net
|
|
48
60
|
NilOrInteger = safe{->val { Integer val unless val.nil? }}
|
49
61
|
|
50
62
|
Enum = ->(*enum) {
|
51
|
-
|
52
|
-
|
63
|
+
sh_enum = Ractor.make_shareable(enum)
|
64
|
+
safe_enum = safe{sh_enum}
|
65
|
+
expected = -"one of #{safe_enum.map(&:inspect).join(", ")}"
|
53
66
|
safe{->val {
|
54
|
-
return val if
|
67
|
+
return val if safe_enum.include?(val)
|
55
68
|
raise ArgumentError, "expected %s, got %p" % [expected, val]
|
56
69
|
}}
|
57
70
|
}
|
@@ -39,12 +39,49 @@ module Net
|
|
39
39
|
# numbers or UIDs, +to_a+ returns that set as an array of integers.
|
40
40
|
#
|
41
41
|
# When both #all and #partial are +nil+, either because the server
|
42
|
-
# returned no results or because +ALL+
|
43
|
-
# the IMAP#search +RETURN+ options, #to_a returns an empty array.
|
42
|
+
# returned no results or because neither +ALL+ or +PARTIAL+ were included
|
43
|
+
# in the IMAP#search +RETURN+ options, #to_a returns an empty array.
|
44
44
|
#
|
45
45
|
# Note that SearchResult also implements +to_a+, so it can be used without
|
46
46
|
# checking if the server returned +SEARCH+ or +ESEARCH+ data.
|
47
|
-
|
47
|
+
#
|
48
|
+
# Related: #each, #to_sequence_set, #all, #partial
|
49
|
+
def to_a; to_sequence_set.numbers end
|
50
|
+
|
51
|
+
# :call-seq: to_sequence_set -> SequenceSet or nil
|
52
|
+
#
|
53
|
+
# When either #all or #partial contains a SequenceSet of message sequence
|
54
|
+
# numbers or UIDs, +to_sequence_set+ returns that sequence set.
|
55
|
+
#
|
56
|
+
# When both #all and #partial are +nil+, either because the server
|
57
|
+
# returned no results or because neither +ALL+ or +PARTIAL+ were included
|
58
|
+
# in the IMAP#search +RETURN+ options, #to_sequence_set returns
|
59
|
+
# SequenceSet.empty.
|
60
|
+
#
|
61
|
+
# Note that SearchResult also implements +to_sequence_set+, so it can be
|
62
|
+
# used without checking if the server returned +SEARCH+ or +ESEARCH+ data.
|
63
|
+
#
|
64
|
+
# Related: #each, #to_a, #all, #partial
|
65
|
+
def to_sequence_set
|
66
|
+
all || partial&.to_sequence_set || SequenceSet.empty
|
67
|
+
end
|
68
|
+
|
69
|
+
# When either #all or #partial contains a SequenceSet of message sequence
|
70
|
+
# numbers or UIDs, +each+ yields each integer in the set.
|
71
|
+
#
|
72
|
+
# When both #all and #partial are +nil+, either because the server
|
73
|
+
# returned no results or because +ALL+ and +PARTIAL+ were not included in
|
74
|
+
# the IMAP#search +RETURN+ options, #each does not yield.
|
75
|
+
#
|
76
|
+
# Note that SearchResult also implements +#each+, so it can be used
|
77
|
+
# without checking if the server returned +SEARCH+ or +ESEARCH+ data.
|
78
|
+
#
|
79
|
+
# Related: #to_sequence_set, #to_a, #all, #partial
|
80
|
+
def each(&)
|
81
|
+
return to_enum(__callee__) unless block_given?
|
82
|
+
to_sequence_set.each_number(&)
|
83
|
+
self
|
84
|
+
end
|
48
85
|
|
49
86
|
##
|
50
87
|
# attr_reader: tag
|
@@ -161,6 +198,8 @@ module Net
|
|
161
198
|
#
|
162
199
|
# See also: ESearchResult#to_a.
|
163
200
|
def to_a; results&.numbers || [] end
|
201
|
+
|
202
|
+
alias to_sequence_set results
|
164
203
|
end
|
165
204
|
|
166
205
|
# :call-seq: partial -> PartialResult or nil
|
@@ -60,9 +60,8 @@ module Net
|
|
60
60
|
# [3, 5, 7] == Net::IMAP::SearchResult[3, 5, 7, modseq: 99] # => true
|
61
61
|
#
|
62
62
|
def ==(other)
|
63
|
-
(
|
64
|
-
|
65
|
-
other.is_a?(Array)) &&
|
63
|
+
other.is_a?(Array) &&
|
64
|
+
modseq == (other.modseq if other.respond_to?(:modseq)) &&
|
66
65
|
size == other.size &&
|
67
66
|
sort == other.sort
|
68
67
|
end
|
@@ -444,14 +444,14 @@ module Net
|
|
444
444
|
# +to_sequence_set+, calls +obj.to_sequence_set+ and returns the result.
|
445
445
|
# Otherwise returns +nil+.
|
446
446
|
#
|
447
|
-
# If +obj.to_sequence_set+ doesn't return a SequenceSet
|
448
|
-
# raised.
|
447
|
+
# If +obj.to_sequence_set+ doesn't return a SequenceSet or +nil+, an
|
448
|
+
# exception is raised.
|
449
449
|
#
|
450
450
|
# Related: Net::IMAP::SequenceSet(), ::new, ::[]
|
451
451
|
def try_convert(obj)
|
452
452
|
return obj if obj.is_a?(SequenceSet)
|
453
453
|
return nil unless obj.respond_to?(:to_sequence_set)
|
454
|
-
obj = obj.to_sequence_set
|
454
|
+
return nil unless obj = obj.to_sequence_set
|
455
455
|
return obj if obj.is_a?(SequenceSet)
|
456
456
|
raise DataFormatError, "invalid object returned from to_sequence_set"
|
457
457
|
end
|
@@ -19,7 +19,7 @@ module Net
|
|
19
19
|
# * +uids+ will be converted by SequenceSet.[].
|
20
20
|
# * +earlier+ will be converted to +true+ or +false+
|
21
21
|
def initialize(uids:, earlier:)
|
22
|
-
uids = SequenceSet[uids]
|
22
|
+
uids = SequenceSet[uids] unless uids.equal? SequenceSet.empty
|
23
23
|
earlier = !!earlier
|
24
24
|
super
|
25
25
|
end
|
@@ -51,6 +51,15 @@ module Net
|
|
51
51
|
# See SequenceSet#numbers.
|
52
52
|
def to_a; uids.numbers end
|
53
53
|
|
54
|
+
# Yields each UID in #uids and returns +self+. Returns an Enumerator when
|
55
|
+
# no block is given.
|
56
|
+
#
|
57
|
+
# See SequenceSet#each_number.
|
58
|
+
def each(&)
|
59
|
+
return to_enum unless block_given?
|
60
|
+
uids.each_number(&)
|
61
|
+
self
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
56
65
|
end
|
data/lib/net/imap.rb
CHANGED
@@ -788,7 +788,7 @@ module Net
|
|
788
788
|
# * {IMAP URLAUTH Authorization Mechanism Registry}[https://www.iana.org/assignments/urlauth-authorization-mechanism-registry/urlauth-authorization-mechanism-registry.xhtml]
|
789
789
|
#
|
790
790
|
class IMAP < Protocol
|
791
|
-
VERSION = "0.5.
|
791
|
+
VERSION = "0.5.11"
|
792
792
|
|
793
793
|
# Aliases for supported capabilities, to be used with the #enable command.
|
794
794
|
ENABLE_ALIASES = {
|
@@ -2110,8 +2110,8 @@ module Net
|
|
2110
2110
|
end
|
2111
2111
|
|
2112
2112
|
# call-seq:
|
2113
|
-
# uid_expunge
|
2114
|
-
# uid_expunge
|
2113
|
+
# uid_expunge(uid_set) -> array of message sequence numbers
|
2114
|
+
# uid_expunge(uid_set) -> VanishedData of UIDs
|
2115
2115
|
#
|
2116
2116
|
# Sends a {UID EXPUNGE command [RFC4315 §2.1]}[https://www.rfc-editor.org/rfc/rfc4315#section-2.1]
|
2117
2117
|
# {[IMAP4rev2 §6.4.9]}[https://www.rfc-editor.org/rfc/rfc9051#section-6.4.9]
|
@@ -2961,6 +2961,18 @@ module Net
|
|
2961
2961
|
# command parameters defined by the extension will implicitly enable it.
|
2962
2962
|
# See {[RFC7162 §3.1]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1].
|
2963
2963
|
#
|
2964
|
+
# [+QRESYNC+ {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html]]
|
2965
|
+
# *NOTE:* Enabling QRESYNC will replace +EXPUNGE+ with +VANISHED+, but
|
2966
|
+
# the extension arguments to #select, #examine, and #uid_fetch are not
|
2967
|
+
# supported yet.
|
2968
|
+
#
|
2969
|
+
# Adds quick resynchronization options to #select, #examine, and
|
2970
|
+
# #uid_fetch. +QRESYNC+ _must_ be explicitly enabled before using any of
|
2971
|
+
# the extension's command parameters. All +EXPUNGE+ responses will be
|
2972
|
+
# replaced with +VANISHED+ responses. Enabling +QRESYNC+ implicitly
|
2973
|
+
# enables +CONDSTORE+ as well.
|
2974
|
+
# See {[RFC7162 §3.2]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.2].
|
2975
|
+
#
|
2964
2976
|
# [+:utf8+ --- an alias for <tt>"UTF8=ACCEPT"</tt>]
|
2965
2977
|
#
|
2966
2978
|
# In a future release, <tt>enable(:utf8)</tt> will enable either
|
@@ -3672,6 +3684,9 @@ module Net
|
|
3672
3684
|
end
|
3673
3685
|
|
3674
3686
|
def fetch_internal(cmd, set, attr, mod = nil, partial: nil, changedsince: nil)
|
3687
|
+
if partial && !cmd.start_with?("UID ")
|
3688
|
+
raise ArgumentError, "partial can only be used with uid_fetch"
|
3689
|
+
end
|
3675
3690
|
set = SequenceSet[set]
|
3676
3691
|
if partial
|
3677
3692
|
mod ||= []
|