net-imap 0.4.8 → 0.4.9

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: b90ea893e6f831943d2d0412ff068c7a6603ce3bf723900ea7401a9e045f724b
4
- data.tar.gz: '087c861278ce56a7369780aa27d77e56ed6d94907a4116a3a4fd9707f327d57a'
3
+ metadata.gz: 4748c4c7176f5267d0efbb4e6dcf4a1e4ffcbf236ac808d798937485b8b7e509
4
+ data.tar.gz: cdf7efa6adad2ebea59d19f0580d65581b3fc3ae2d23bb2394acf58dd809bd2b
5
5
  SHA512:
6
- metadata.gz: 5fa157a8887d5ca2b97b75756b5414d5973667299ae3dbdb340b432eae05cfdb2994969ea2dab68b595f2eae66bd50d19fb814196fb991af1bfc285dfa5b3d6f
7
- data.tar.gz: 7b173943ff66f97b5b22795752a34f7338228e6ef5a4dca43b293f5e3153f90d34b7039fd24c76399b1f460e77ffe422dd3691466b0952e3631f2406bab70854
6
+ metadata.gz: 241c1c908e0c59253d0a29779a1feeb8709cf25ab21be425d1e169783cad4b1feab7c5c4db79ed1ebdf658e9aab7b46e3ba53b79f381605ed96efe0b9497e9d7
7
+ data.tar.gz: 0d7e42911c110ef1530e94512ae720a9fd992aede9c406fd706fb553f11097cab6ee842aa3d63466effd4fda6255e23647a0dc8a964012738a44448a85d0a47c
@@ -26,6 +26,6 @@ jobs:
26
26
  with:
27
27
  ruby-version: ${{ matrix.ruby }}
28
28
  bundler-cache: true
29
- rubygems: latest
29
+ rubygems: 3.4.22
30
30
  - name: Run test
31
31
  run: bundle exec rake test
@@ -131,8 +131,8 @@ module Net
131
131
  #
132
132
  # A transformation of #attr, with all the keys converted to upper case.
133
133
  #
134
- # Header field names are case-preserved but not not case-sensitive, so
135
- # this is used by #header_fields and #header_fields_not.
134
+ # Header field names are case-preserved but not case-sensitive, so this is
135
+ # used by #header_fields and #header_fields_not.
136
136
  def attr_upcase; attr.transform_keys(&:upcase) end
137
137
 
138
138
  # :call-seq:
@@ -1929,6 +1929,8 @@ module Net
1929
1929
  end
1930
1930
  end
1931
1931
 
1932
+ # This allows illegal "]" in flag names (Gmail),
1933
+ # or "\*" in a FLAGS response (greenmail).
1932
1934
  def quirky__flag_list(name)
1933
1935
  match_re(Patterns::QUIRKY_FLAGS_LIST, "quirks mode #{name}")[1]
1934
1936
  .scan(Patterns::QUIRKY_FLAG)
@@ -60,6 +60,21 @@ module Net
60
60
  # set = Net::IMAP::SequenceSet[1, 2, [3..7, 5], 6..10, 2048, 1024]
61
61
  # set.valid_string #=> "1:10,55,1024:2048"
62
62
  #
63
+ # == Normalized form
64
+ #
65
+ # When a sequence set is created with a single String value, that #string
66
+ # representation is preserved. SequenceSet's internal representation
67
+ # implicitly sorts all entries, de-duplicates numbers, and coalesces
68
+ # adjacent or overlapping ranges. Most enumeration methods and offset-based
69
+ # methods use this normalized representation. Most modification methods
70
+ # will convert #string to its normalized form.
71
+ #
72
+ # In some cases the order of the string representation is significant, such
73
+ # as the +ESORT+, <tt>CONTEXT=SORT</tt>, and +UIDPLUS+ extensions. Use
74
+ # #entries or #each_entry to enumerate the set in its original order. To
75
+ # preserve #string order while modifying a set, use #append, #string=, or
76
+ # #replace.
77
+ #
63
78
  # == Using <tt>*</tt>
64
79
  #
65
80
  # \IMAP sequence sets may contain a special value <tt>"*"</tt>, which
@@ -151,7 +166,7 @@ module Net
151
166
  # +nil+ if the object cannot be converted to a compatible type.
152
167
  # - #cover? (aliased as #===):
153
168
  # Returns whether a given object is fully contained within +self+.
154
- # - #intersect?:
169
+ # - #intersect? (aliased as #overlap?):
155
170
  # Returns whether +self+ and a given object have any common elements.
156
171
  # - #disjoint?:
157
172
  # Returns whether +self+ and a given object have no common elements.
@@ -186,10 +201,14 @@ module Net
186
201
  #
187
202
  # === Methods for Iterating
188
203
  #
189
- # - #each_element: Yields each number and range in the set and returns
190
- # +self+.
191
- # - #elements (aliased as #to_a):
192
- # Returns an Array of every number and range in the set.
204
+ # - #each_element: Yields each number and range in the set, sorted and
205
+ # coalesced, and returns +self+.
206
+ # - #elements (aliased as #to_a): Returns an Array of every number and range
207
+ # in the set, sorted and coalesced.
208
+ # - #each_entry: Yields each number and range in the set, unsorted and
209
+ # without deduplicating numbers or coalescing ranges, and returns +self+.
210
+ # - #entries: Returns an Array of every number and range in the set,
211
+ # unsorted and without deduplicating numbers or coalescing ranges.
193
212
  # - #each_range:
194
213
  # Yields each element in the set as a Range and returns +self+.
195
214
  # - #ranges: Returns an Array of every element in the set, converting
@@ -222,6 +241,8 @@ module Net
222
241
  # - #add?: If the given object is not an element in the set, adds it and
223
242
  # returns +self+; otherwise, returns +nil+.
224
243
  # - #merge: Merges multiple elements into the set; returns +self+.
244
+ # - #append: Adds a given object to the set, appending it to the existing
245
+ # string, and returns +self+.
225
246
  # - #string=: Assigns a new #string value and replaces #elements to match.
226
247
  # - #replace: Replaces the contents of the set with the contents
227
248
  # of a given object.
@@ -502,6 +523,7 @@ module Net
502
523
  def intersect?(other)
503
524
  valid? && input_to_tuples(other).any? { intersect_tuple? _1 }
504
525
  end
526
+ alias overlap? intersect?
505
527
 
506
528
  # Returns +true+ if the set and a given object have no common elements,
507
529
  # +false+ otherwise.
@@ -655,6 +677,18 @@ module Net
655
677
  end
656
678
  alias << add
657
679
 
680
+ # Adds a range or number to the set and returns +self+.
681
+ #
682
+ # Unlike #add, #merge, or #union, the new value is appended to #string.
683
+ # This may result in a #string which has duplicates or is out-of-order.
684
+ def append(object)
685
+ tuple = input_to_tuple object
686
+ entry = tuple_to_str tuple
687
+ tuple_add tuple
688
+ @string = -(string ? "#{@string},#{entry}" : entry)
689
+ self
690
+ end
691
+
658
692
  # :call-seq: add?(object) -> self or nil
659
693
  #
660
694
  # Adds a range or number to the set and returns +self+. Returns +nil+
@@ -787,7 +821,18 @@ module Net
787
821
  normalize!
788
822
  end
789
823
 
790
- # Returns an array of ranges and integers.
824
+ # Returns an array of ranges and integers and <tt>:*</tt>.
825
+ #
826
+ # The entries are in the same order they appear in #string, with no
827
+ # sorting, deduplication, or coalescing. When #string is in its
828
+ # normalized form, this will return the same result as #elements.
829
+ # This is useful when the given order is significant, for example in a
830
+ # ESEARCH response to IMAP#sort.
831
+ #
832
+ # Related: #each_entry, #elements
833
+ def entries; each_entry.to_a end
834
+
835
+ # Returns an array of ranges and integers and <tt>:*</tt>.
791
836
  #
792
837
  # The returned elements are sorted and coalesced, even when the input
793
838
  # #string is not. <tt>*</tt> will sort last. See #normalize.
@@ -854,22 +899,42 @@ module Net
854
899
  # Related: #elements, #ranges, #to_set
855
900
  def numbers; each_number.to_a end
856
901
 
857
- # Yields each number or range in #elements to the block and returns self.
902
+ # Yields each number or range in #string to the block and returns +self+.
858
903
  # Returns an enumerator when called without a block.
859
904
  #
860
- # Related: #elements
905
+ # The entries are yielded in the same order they appear in #tring, with no
906
+ # sorting, deduplication, or coalescing. When #string is in its
907
+ # normalized form, this will yield the same values as #each_element.
908
+ #
909
+ # Related: #entries, #each_element
910
+ def each_entry(&block)
911
+ return to_enum(__method__) unless block_given?
912
+ return each_element(&block) unless @string
913
+ @string.split(",").each do yield tuple_to_entry str_to_tuple _1 end
914
+ self
915
+ end
916
+
917
+ # Yields each number or range (or <tt>:*</tt>) in #elements to the block
918
+ # and returns self. Returns an enumerator when called without a block.
919
+ #
920
+ # The returned numbers are sorted and de-duplicated, even when the input
921
+ # #string is not. See #normalize.
922
+ #
923
+ # Related: #elements, #each_entry
861
924
  def each_element # :yields: integer or range or :*
862
925
  return to_enum(__method__) unless block_given?
863
- @tuples.each do |min, max|
864
- if min == STAR_INT then yield :*
865
- elsif max == STAR_INT then yield min..
866
- elsif min == max then yield min
867
- else yield min..max
868
- end
869
- end
926
+ @tuples.each do yield tuple_to_entry _1 end
870
927
  self
871
928
  end
872
929
 
930
+ private def tuple_to_entry((min, max))
931
+ if min == STAR_INT then :*
932
+ elsif max == STAR_INT then min..
933
+ elsif min == max then min
934
+ else min..max
935
+ end
936
+ end
937
+
873
938
  # Yields each range in #ranges to the block and returns self.
874
939
  # Returns an enumerator when called without a block.
875
940
  #
data/lib/net/imap.rb CHANGED
@@ -717,7 +717,7 @@ module Net
717
717
  # * {IMAP URLAUTH Authorization Mechanism Registry}[https://www.iana.org/assignments/urlauth-authorization-mechanism-registry/urlauth-authorization-mechanism-registry.xhtml]
718
718
  #
719
719
  class IMAP < Protocol
720
- VERSION = "0.4.8"
720
+ VERSION = "0.4.9"
721
721
 
722
722
  # Aliases for supported capabilities, to be used with the #enable command.
723
723
  ENABLE_ALIASES = {
@@ -2883,7 +2883,6 @@ module Net
2883
2883
  else
2884
2884
  normalize_searching_criteria(search_keys)
2885
2885
  end
2886
- normalize_searching_criteria(search_keys)
2887
2886
  synchronize do
2888
2887
  send_command(cmd, sort_keys, charset, *search_keys)
2889
2888
  clear_responses("SORT").last || []
@@ -2896,7 +2895,6 @@ module Net
2896
2895
  else
2897
2896
  normalize_searching_criteria(search_keys)
2898
2897
  end
2899
- normalize_searching_criteria(search_keys)
2900
2898
  synchronize do
2901
2899
  send_command(cmd, algorithm, charset, *search_keys)
2902
2900
  clear_responses("THREAD").last || []
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.4.8
4
+ version: 0.4.9
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: 2023-12-12 00:00:00.000000000 Z
12
+ date: 2023-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-protocol