net-imap 0.4.13 → 0.4.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/net/imap/command_data.rb +2 -2
- data/lib/net/imap/config/attr_accessors.rb +5 -0
- data/lib/net/imap/config.rb +185 -8
- data/lib/net/imap.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f327f21581ac36f2565a93a78535e8d1028b7f8ce25da9aa56dffc5d3aba5949
|
4
|
+
data.tar.gz: 929a41b8ca42858c585080df30313d6c000fa4e8386be480ad0a650a86dca789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686a14fc1451a1b8d56c4533b1fd7229f1bb29707bb18b0771ea3294411349d1505ced863406caca189304211e556df207d710589e1917a532c7b381100f103d
|
7
|
+
data.tar.gz: dda1b58f73197c1233a22d60d74940265862f0d8cad3afb86b84bad2993f591a233c47f81aacd1260f5d85ab30ac581312723854eeea982aae88f3eae74c57e0
|
@@ -40,10 +40,10 @@ module Net
|
|
40
40
|
send_number_data(data)
|
41
41
|
when Array
|
42
42
|
send_list_data(data, tag)
|
43
|
-
when Date
|
44
|
-
send_date_data(data)
|
45
43
|
when Time, DateTime
|
46
44
|
send_time_data(data)
|
45
|
+
when Date
|
46
|
+
send_date_data(data)
|
47
47
|
when Symbol
|
48
48
|
send_symbol_data(data)
|
49
49
|
else
|
data/lib/net/imap/config.rb
CHANGED
@@ -54,25 +54,117 @@ module Net
|
|
54
54
|
# plain_client.config.inherited?(:debug) # => true
|
55
55
|
# plain_client.config.debug? # => false
|
56
56
|
#
|
57
|
+
# == Versioned defaults
|
58
|
+
#
|
59
|
+
# The effective default configuration for a specific +x.y+ version of
|
60
|
+
# +net-imap+ can be loaded with the +config+ keyword argument to
|
61
|
+
# Net::IMAP.new. Requesting default configurations for previous versions
|
62
|
+
# enables extra backward compatibility with those versions:
|
63
|
+
#
|
64
|
+
# client = Net::IMAP.new(hostname, config: 0.3)
|
65
|
+
# client.config.sasl_ir # => false
|
66
|
+
# client.config.responses_without_block # => :silence_deprecation_warning
|
67
|
+
#
|
68
|
+
# client = Net::IMAP.new(hostname, config: 0.4)
|
69
|
+
# client.config.sasl_ir # => true
|
70
|
+
# client.config.responses_without_block # => :silence_deprecation_warning
|
71
|
+
#
|
72
|
+
# client = Net::IMAP.new(hostname, config: 0.5)
|
73
|
+
# client.config.sasl_ir # => true
|
74
|
+
# client.config.responses_without_block # => :warn
|
75
|
+
#
|
76
|
+
# client = Net::IMAP.new(hostname, config: :future)
|
77
|
+
# client.config.sasl_ir # => true
|
78
|
+
# client.config.responses_without_block # => :raise
|
79
|
+
#
|
80
|
+
# The versioned default configs inherit certain specific config options from
|
81
|
+
# Config.global, for example #debug:
|
82
|
+
#
|
83
|
+
# client = Net::IMAP.new(hostname, config: 0.4)
|
84
|
+
# Net::IMAP.debug = false
|
85
|
+
# client.config.debug? # => false
|
86
|
+
#
|
87
|
+
# Net::IMAP.debug = true
|
88
|
+
# client.config.debug? # => true
|
89
|
+
#
|
90
|
+
# Use #load_defaults to globally behave like a specific version:
|
91
|
+
# client = Net::IMAP.new(hostname)
|
92
|
+
# client.config.sasl_ir # => true
|
93
|
+
# Net::IMAP.config.load_defaults 0.3
|
94
|
+
# client.config.sasl_ir # => false
|
95
|
+
#
|
96
|
+
# === Named defaults
|
97
|
+
# In addition to +x.y+ version numbers, the following aliases are supported:
|
98
|
+
#
|
99
|
+
# [+:default+]
|
100
|
+
# An alias for +:current+.
|
101
|
+
#
|
102
|
+
# >>>
|
103
|
+
# *NOTE*: This is _not_ the same as Config.default. It inherits some
|
104
|
+
# attributes from Config.global, for example: #debug.
|
105
|
+
# [+:current+]
|
106
|
+
# An alias for the current +x.y+ version's defaults.
|
107
|
+
# [+:next+]
|
108
|
+
# The _planned_ config for the next +x.y+ version.
|
109
|
+
# [+:future+]
|
110
|
+
# The _planned_ eventual config for some future +x.y+ version.
|
111
|
+
#
|
112
|
+
# For example, to raise exceptions for all current deprecations:
|
113
|
+
# client = Net::IMAP.new(hostname, config: :future)
|
114
|
+
# client.responses # raises an ArgumentError
|
57
115
|
#
|
58
116
|
# == Thread Safety
|
59
117
|
#
|
60
118
|
# *NOTE:* Updates to config objects are not synchronized for thread-safety.
|
61
119
|
#
|
62
120
|
class Config
|
121
|
+
# Array of attribute names that are _not_ loaded by #load_defaults.
|
122
|
+
DEFAULT_TO_INHERIT = %i[debug].freeze
|
123
|
+
private_constant :DEFAULT_TO_INHERIT
|
124
|
+
|
63
125
|
# The default config, which is hardcoded and frozen.
|
64
126
|
def self.default; @default end
|
65
127
|
|
66
128
|
# The global config object. Also available from Net::IMAP.config.
|
67
|
-
def self.global; @global end
|
129
|
+
def self.global; @global if defined?(@global) end
|
130
|
+
|
131
|
+
# A hash of hard-coded configurations, indexed by version number.
|
132
|
+
def self.version_defaults; @version_defaults end
|
133
|
+
@version_defaults = {}
|
68
134
|
|
69
|
-
|
70
|
-
|
71
|
-
|
135
|
+
# :call-seq:
|
136
|
+
# Net::IMAP::Config[number] -> versioned config
|
137
|
+
# Net::IMAP::Config[symbol] -> named config
|
138
|
+
# Net::IMAP::Config[hash] -> new frozen config
|
139
|
+
# Net::IMAP::Config[config] -> same config
|
140
|
+
#
|
141
|
+
# Given a version number, returns the default configuration for the target
|
142
|
+
# version. See Config@Versioned+defaults.
|
143
|
+
#
|
144
|
+
# Given a version name, returns the default configuration for the target
|
145
|
+
# version. See Config@Named+defaults.
|
146
|
+
#
|
147
|
+
# Given a Hash, creates a new _frozen_ config which inherits from
|
148
|
+
# Config.global. Use Config.new for an unfrozen config.
|
149
|
+
#
|
150
|
+
# Given a config, returns that same config.
|
151
|
+
def self.[](config)
|
152
|
+
if config.is_a?(Config) then config
|
153
|
+
elsif config.nil? && global.nil? then nil
|
154
|
+
elsif config.respond_to?(:to_hash) then new(global, **config).freeze
|
72
155
|
else
|
73
|
-
|
74
|
-
config
|
75
|
-
|
156
|
+
version_defaults.fetch(config) do
|
157
|
+
case config
|
158
|
+
when Numeric
|
159
|
+
raise RangeError, "unknown config version: %p" % [config]
|
160
|
+
when Symbol
|
161
|
+
raise KeyError, "unknown config name: %p" % [config]
|
162
|
+
else
|
163
|
+
raise TypeError, "no implicit conversion of %s to %s" % [
|
164
|
+
config.class, Config
|
165
|
+
]
|
166
|
+
end
|
167
|
+
end
|
76
168
|
end
|
77
169
|
end
|
78
170
|
|
@@ -143,10 +235,72 @@ module Net
|
|
143
235
|
# If a block is given, the new config object is yielded to it.
|
144
236
|
def initialize(parent = Config.global, **attrs)
|
145
237
|
super(parent)
|
146
|
-
attrs
|
238
|
+
update(**attrs)
|
147
239
|
yield self if block_given?
|
148
240
|
end
|
149
241
|
|
242
|
+
# :call-seq: update(**attrs) -> self
|
243
|
+
#
|
244
|
+
# Assigns all of the provided +attrs+ to this config, and returns +self+.
|
245
|
+
#
|
246
|
+
# An ArgumentError is raised unless every key in +attrs+ matches an
|
247
|
+
# assignment method on Config.
|
248
|
+
#
|
249
|
+
# >>>
|
250
|
+
# *NOTE:* #update is not atomic. If an exception is raised due to an
|
251
|
+
# invalid attribute value, +attrs+ may be partially applied.
|
252
|
+
def update(**attrs)
|
253
|
+
unless (bad = attrs.keys.reject { respond_to?(:"#{_1}=") }).empty?
|
254
|
+
raise ArgumentError, "invalid config options: #{bad.join(", ")}"
|
255
|
+
end
|
256
|
+
attrs.each do send(:"#{_1}=", _2) end
|
257
|
+
self
|
258
|
+
end
|
259
|
+
|
260
|
+
# :call-seq:
|
261
|
+
# with(**attrs) -> config
|
262
|
+
# with(**attrs) {|config| } -> result
|
263
|
+
#
|
264
|
+
# Without a block, returns a new config which inherits from self. With a
|
265
|
+
# block, yields the new config and returns the block's result.
|
266
|
+
#
|
267
|
+
# If no keyword arguments are given, an ArgumentError will be raised.
|
268
|
+
#
|
269
|
+
# If +self+ is frozen, the copy will also be frozen.
|
270
|
+
def with(**attrs)
|
271
|
+
attrs.empty? and
|
272
|
+
raise ArgumentError, "expected keyword arguments, none given"
|
273
|
+
copy = new(**attrs)
|
274
|
+
copy.freeze if frozen?
|
275
|
+
block_given? ? yield(copy) : copy
|
276
|
+
end
|
277
|
+
|
278
|
+
# :call-seq: load_defaults(version) -> self
|
279
|
+
#
|
280
|
+
# Resets the current config to behave like the versioned default
|
281
|
+
# configuration for +version+. #parent will not be changed.
|
282
|
+
#
|
283
|
+
# Some config attributes default to inheriting from their #parent (which
|
284
|
+
# is usually Config.global) and are left unchanged, for example: #debug.
|
285
|
+
#
|
286
|
+
# See Config@Versioned+defaults and Config@Named+defaults.
|
287
|
+
def load_defaults(version)
|
288
|
+
[Numeric, Symbol, String].any? { _1 === version } or
|
289
|
+
raise ArgumentError, "expected number or symbol, got %p" % [version]
|
290
|
+
update(**Config[version].defaults_hash)
|
291
|
+
end
|
292
|
+
|
293
|
+
# :call-seq: to_h -> hash
|
294
|
+
#
|
295
|
+
# Returns all config attributes in a hash.
|
296
|
+
def to_h; data.members.to_h { [_1, send(_1)] } end
|
297
|
+
|
298
|
+
protected
|
299
|
+
|
300
|
+
def defaults_hash
|
301
|
+
to_h.reject {|k,v| DEFAULT_TO_INHERIT.include?(k) }
|
302
|
+
end
|
303
|
+
|
150
304
|
@default = new(
|
151
305
|
debug: false,
|
152
306
|
open_timeout: 30,
|
@@ -157,6 +311,29 @@ module Net
|
|
157
311
|
|
158
312
|
@global = default.new
|
159
313
|
|
314
|
+
version_defaults[0.4] = Config[default.send(:defaults_hash)]
|
315
|
+
|
316
|
+
version_defaults[0] = Config[0.4].dup.update(
|
317
|
+
sasl_ir: false,
|
318
|
+
).freeze
|
319
|
+
version_defaults[0.0] = Config[0]
|
320
|
+
version_defaults[0.1] = Config[0]
|
321
|
+
version_defaults[0.2] = Config[0]
|
322
|
+
version_defaults[0.3] = Config[0]
|
323
|
+
|
324
|
+
version_defaults[0.5] = Config[0.4].dup.update(
|
325
|
+
responses_without_block: :warn,
|
326
|
+
).freeze
|
327
|
+
|
328
|
+
version_defaults[:default] = Config[0.4]
|
329
|
+
version_defaults[:current] = Config[0.4]
|
330
|
+
version_defaults[:next] = Config[0.5]
|
331
|
+
|
332
|
+
version_defaults[:future] = Config[0.5].dup.update(
|
333
|
+
responses_without_block: :raise,
|
334
|
+
).freeze
|
335
|
+
|
336
|
+
version_defaults.freeze
|
160
337
|
end
|
161
338
|
end
|
162
339
|
end
|
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.
|
720
|
+
VERSION = "0.4.15"
|
721
721
|
|
722
722
|
# Aliases for supported capabilities, to be used with the #enable command.
|
723
723
|
ENABLE_ALIASES = {
|
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.
|
4
|
+
version: 0.4.15
|
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
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-protocol
|