net-imap 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d271261a2609a31b8c84ae74913bf57d5046e95318db7660b3230940bdbff447
4
- data.tar.gz: 771baa4b8a6c3f83f6ef4f320dda8dc5ea9f2fa2ace15fd9b0c1c1b3a594363a
3
+ metadata.gz: 49dc46f2744a04f6b151bc033176f2d59dabf04fb1996bba36a87b4b9f0f99b4
4
+ data.tar.gz: 411eac8fd696e619f0255d37a83b74b19b3290c68533fded627cd689d1afc57a
5
5
  SHA512:
6
- metadata.gz: 230d40d8d183b1c69f63050990df140b49aa5731d0868713e44d2da68c2713ede4fd8d4b1aff60103c25ac6586076e220973b774a43cd5a7b3eaad4e49e7bf3b
7
- data.tar.gz: 156e6c86f6fe39a76de89275bfcd3c57b5adcd375de6add45cd00a30bf92bbf04a2b475702db33cae0509fc0b7b3e015518d4991cd5c467f833cacb0f75d3ca6
6
+ metadata.gz: 3049e6a03f6660c6e7c67c82a9fdb8994a2a0ec3777ca66a6e4941b1a08486e452eb17007e5c666e41a52e34c2c54d057e33aecd6a4b5bac9c522d5f20acfb43
7
+ data.tar.gz: 9c7f8e858614748c65a434900f8b6ddba04b9e31578aa9669987803153c31269888abe6baca8ae42c5ecc00287dab2f494de73ac89cf1fb81d44ebfa65d42c5d
data/docs/styles.css CHANGED
@@ -6,9 +6,7 @@
6
6
 
7
7
  main .method-detail {
8
8
  display: grid;
9
- grid-template-areas: "header controls"
10
- "description description";
11
- grid-template-columns: 1fr min-content;
9
+ grid-template-columns: 1fr auto;
12
10
  justify-content: space-between;
13
11
  }
14
12
 
@@ -20,19 +18,16 @@ main .method-header, main .method-controls {
20
18
  }
21
19
 
22
20
  main .method-header {
23
- grid-area: "header";
24
21
  border-right: none;
25
22
  border-radius: 4px 0 0 4px;
26
23
  }
27
24
 
28
25
  main .method-controls {
29
- grid-area: "controls";
30
26
  border-left: none;
31
27
  border-radius: 0 4px 4px 0;
32
28
  }
33
29
 
34
30
  main .method-description, main .aliases {
35
- grid-area: "description";
36
31
  grid-column: 1 / span 2;
37
32
  padding-left: 1em;
38
33
  }
@@ -6,6 +6,7 @@ module Net
6
6
  autoload :FetchData, "#{__dir__}/fetch_data"
7
7
  autoload :SearchResult, "#{__dir__}/search_result"
8
8
  autoload :SequenceSet, "#{__dir__}/sequence_set"
9
+ autoload :VanishedData, "#{__dir__}/vanished_data"
9
10
 
10
11
  # Net::IMAP::ContinuationRequest represents command continuation requests.
11
12
  #
@@ -769,7 +769,6 @@ module Net
769
769
  def response_data__ignored; response_data__unhandled(IgnoredResponse) end
770
770
  alias response_data__noop response_data__ignored
771
771
 
772
- alias expunged_resp response_data__unhandled
773
772
  alias uidfetch_resp response_data__unhandled
774
773
  alias listrights_data response_data__unhandled
775
774
  alias myrights_data response_data__unhandled
@@ -841,6 +840,20 @@ module Net
841
840
  alias mailbox_data__exists response_data__simple_numeric
842
841
  alias mailbox_data__recent response_data__simple_numeric
843
842
 
843
+ # The name for this is confusing, because it *replaces* EXPUNGE
844
+ # >>>
845
+ # expunged-resp = "VANISHED" [SP "(EARLIER)"] SP known-uids
846
+ def expunged_resp
847
+ name = label "VANISHED"; SP!
848
+ earlier = if lpar? then label("EARLIER"); rpar; SP!; true else false end
849
+ uids = known_uids
850
+ data = VanishedData[uids, earlier]
851
+ UntaggedResponse.new name, data, @str
852
+ end
853
+
854
+ # TODO: replace with uid_set
855
+ alias known_uids sequence_set
856
+
844
857
  # RFC3501 & RFC9051:
845
858
  # msg-att = "(" (msg-att-dynamic / msg-att-static)
846
859
  # *(SP (msg-att-dynamic / msg-att-static)) ")"
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Net
4
+ class IMAP < Protocol
5
+
6
+ # Net::IMAP::VanishedData represents the contents of a +VANISHED+ response,
7
+ # which is described by the
8
+ # {QRESYNC}[https://www.rfc-editor.org/rfc/rfc7162.html] extension.
9
+ # [{RFC7162 §3.2.10}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.2.10]].
10
+ #
11
+ # +VANISHED+ responses replace +EXPUNGE+ responses when either the
12
+ # {QRESYNC}[https://www.rfc-editor.org/rfc/rfc7162.html] or the
13
+ # {UIDONLY}[https://www.rfc-editor.org/rfc/rfc9586.html] extension has been
14
+ # enabled.
15
+ class VanishedData < Data.define(:uids, :earlier)
16
+
17
+ # Returns a new VanishedData object.
18
+ #
19
+ # * +uids+ will be converted by SequenceSet.[].
20
+ # * +earlier+ will be converted to +true+ or +false+
21
+ def initialize(uids:, earlier:)
22
+ uids = SequenceSet[uids]
23
+ earlier = !!earlier
24
+ super
25
+ end
26
+
27
+ ##
28
+ # :attr_reader: uids
29
+ #
30
+ # SequenceSet of UIDs that have been permanently removed from the mailbox.
31
+
32
+ ##
33
+ # :attr_reader: earlier
34
+ #
35
+ # +true+ when the response was caused by Net::IMAP#uid_fetch with
36
+ # <tt>vanished: true</tt> or Net::IMAP#select/Net::IMAP#examine with
37
+ # <tt>qresync: true</tt>.
38
+ #
39
+ # +false+ when the response is used to announce message removals within an
40
+ # already selected mailbox.
41
+
42
+ # rdoc doesn't handle attr aliases nicely. :(
43
+ alias earlier? earlier # :nodoc:
44
+ ##
45
+ # :attr_reader: earlier?
46
+ #
47
+ # Alias for #earlier.
48
+
49
+ # Returns an Array of all of the UIDs in #uids.
50
+ #
51
+ # See SequenceSet#numbers.
52
+ def to_a; uids.numbers end
53
+
54
+ end
55
+ end
56
+ end
data/lib/net/imap.rb CHANGED
@@ -723,7 +723,7 @@ module Net
723
723
  # * {IMAP URLAUTH Authorization Mechanism Registry}[https://www.iana.org/assignments/urlauth-authorization-mechanism-registry/urlauth-authorization-mechanism-registry.xhtml]
724
724
  #
725
725
  class IMAP < Protocol
726
- VERSION = "0.5.2"
726
+ VERSION = "0.5.3"
727
727
 
728
728
  # Aliases for supported capabilities, to be used with the #enable command.
729
729
  ENABLE_ALIASES = {
@@ -1889,48 +1889,64 @@ module Net
1889
1889
  send_command("UNSELECT")
1890
1890
  end
1891
1891
 
1892
+ # call-seq:
1893
+ # expunge -> array of message sequence numbers
1894
+ # expunge -> VanishedData of UIDs
1895
+ #
1892
1896
  # Sends an {EXPUNGE command [IMAP4rev1 §6.4.3]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.3]
1893
- # Sends a EXPUNGE command to permanently remove from the currently
1894
- # selected mailbox all messages that have the \Deleted flag set.
1897
+ # to permanently remove all messages with the +\Deleted+ flag from the
1898
+ # currently selected mailbox.
1899
+ #
1900
+ # Returns either an array of expunged message <em>sequence numbers</em> or
1901
+ # (when the appropriate capability is enabled) VanishedData of expunged
1902
+ # UIDs. Previously unhandled +EXPUNGE+ or +VANISHED+ responses are merged
1903
+ # with the direct response to this command. <tt>VANISHED (EARLIER)</tt>
1904
+ # responses will _not_ be merged.
1905
+ #
1906
+ # When no messages have been expunged, an empty array is returned,
1907
+ # regardless of which extensions are enabled. In a future release, an empty
1908
+ # VanishedData may be returned, based on the currently enabled extensions.
1895
1909
  #
1896
1910
  # Related: #uid_expunge
1911
+ #
1912
+ # ==== Capabilities
1913
+ #
1914
+ # When either QRESYNC[https://tools.ietf.org/html/rfc7162] or
1915
+ # UIDONLY[https://tools.ietf.org/html/rfc9586] are enabled, #expunge
1916
+ # returns VanishedData, which contains UIDs---<em>not message sequence
1917
+ # numbers</em>.
1897
1918
  def expunge
1898
- synchronize do
1899
- send_command("EXPUNGE")
1900
- clear_responses("EXPUNGE")
1901
- end
1919
+ expunge_internal("EXPUNGE")
1902
1920
  end
1903
1921
 
1922
+ # call-seq:
1923
+ # uid_expunge{uid_set) -> array of message sequence numbers
1924
+ # uid_expunge{uid_set) -> VanishedData of UIDs
1925
+ #
1904
1926
  # Sends a {UID EXPUNGE command [RFC4315 §2.1]}[https://www.rfc-editor.org/rfc/rfc4315#section-2.1]
1905
1927
  # {[IMAP4rev2 §6.4.9]}[https://www.rfc-editor.org/rfc/rfc9051#section-6.4.9]
1906
1928
  # to permanently remove all messages that have both the <tt>\\Deleted</tt>
1907
1929
  # flag set and a UID that is included in +uid_set+.
1908
1930
  #
1931
+ # Returns the same result type as #expunge.
1932
+ #
1909
1933
  # By using #uid_expunge instead of #expunge when resynchronizing with
1910
1934
  # the server, the client can ensure that it does not inadvertantly
1911
1935
  # remove any messages that have been marked as <tt>\\Deleted</tt> by other
1912
1936
  # clients between the time that the client was last connected and
1913
1937
  # the time the client resynchronizes.
1914
1938
  #
1915
- # *Note:*
1916
- # >>>
1917
- # Although the command takes a set of UIDs for its argument, the
1918
- # server still returns regular EXPUNGE responses, which contain
1919
- # a <em>sequence number</em>. These will be deleted from
1920
- # #responses and this method returns them as an array of
1921
- # <em>sequence number</em> integers.
1922
- #
1923
1939
  # Related: #expunge
1924
1940
  #
1925
1941
  # ==== Capabilities
1926
1942
  #
1927
- # The server's capabilities must include +UIDPLUS+
1943
+ # The server's capabilities must include either +IMAP4rev2+ or +UIDPLUS+
1928
1944
  # [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]].
1945
+ #
1946
+ # Otherwise, #uid_expunge is updated by extensions in the same way as
1947
+ # #expunge.
1929
1948
  def uid_expunge(uid_set)
1930
- synchronize do
1931
- send_command("UID EXPUNGE", SequenceSet.new(uid_set))
1932
- clear_responses("EXPUNGE")
1933
- end
1949
+ expunge_internal("UID EXPUNGE", SequenceSet.new(uid_set))
1934
1950
  end
1935
1951
 
1936
1952
  # :call-seq:
@@ -1942,7 +1958,7 @@ module Net
1942
1958
  # and returns either a SearchResult or an ESearchResult. SearchResult
1943
1959
  # inherits from Array (for backward compatibility) but adds
1944
1960
  # SearchResult#modseq when the +CONDSTORE+ capability has been enabled.
1945
- # ESearchResult also implements to_a{rdoc-ref:ESearchResult#to_a}, for
1961
+ # ESearchResult also implements {#to_a}[rdoc-ref:ESearchResult#to_a], for
1946
1962
  # compatibility with SearchResult.
1947
1963
  #
1948
1964
  # +criteria+ is one or more search keys and their arguments, which may be
@@ -3261,6 +3277,22 @@ module Net
3261
3277
  end
3262
3278
  end
3263
3279
 
3280
+ def expunge_internal(...)
3281
+ synchronize do
3282
+ send_command(...)
3283
+ expunged_array = clear_responses("EXPUNGE")
3284
+ vanished_array = extract_responses("VANISHED") { !_1.earlier? }
3285
+ if vanished_array.empty?
3286
+ expunged_array
3287
+ elsif vanished_array.length == 1
3288
+ vanished_array.first
3289
+ else
3290
+ merged_uids = SequenceSet[*vanished_array.map(&:uids)]
3291
+ VanishedData[uids: merged_uids, earlier: false]
3292
+ end
3293
+ end
3294
+ end
3295
+
3264
3296
  RETURN_WHOLE = /\ARETURN\z/i
3265
3297
  RETURN_START = /\ARETURN\b/i
3266
3298
  private_constant :RETURN_WHOLE, :RETURN_START
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-12-16 00:00:00.000000000 Z
12
+ date: 2024-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-protocol
@@ -97,6 +97,7 @@ files:
97
97
  - lib/net/imap/stringprep/saslprep_tables.rb
98
98
  - lib/net/imap/stringprep/tables.rb
99
99
  - lib/net/imap/stringprep/trace.rb
100
+ - lib/net/imap/vanished_data.rb
100
101
  - net-imap.gemspec
101
102
  - rakelib/benchmarks.rake
102
103
  - rakelib/rdoc.rake