@@ -73,6 +73,10 @@ class IMAP
7373 # client.config.sasl_ir # => true
7474 # client.config.responses_without_block # => :warn
7575 #
76+ # client = Net::IMAP.new(hostname, config: :future)
77+ # client.config.sasl_ir # => true
78+ # client.config.responses_without_block # => :raise
79+ #
7680 # The versioned default configs inherit certain specific config options from
7781 # Config.global, for example #debug:
7882 #
@@ -83,6 +87,26 @@ class IMAP
8387 # Net::IMAP.debug = true
8488 # client.config.debug? # => true
8589 #
90+ # === Named defaults
91+ # In addition to +x.y+ version numbers, the following aliases are supported:
92+ #
93+ # [+:default+]
94+ # An alias for +:current+.
95+ #
96+ # >>>
97+ # *NOTE*: This is _not_ the same as Config.default. It inherits some
98+ # attributes from Config.global, for example: #debug.
99+ # [+:current+]
100+ # An alias for the current +x.y+ version's defaults.
101+ # [+:next+]
102+ # The _planned_ config for the next +x.y+ version.
103+ # [+:future+]
104+ # The _planned_ eventual config for some future +x.y+ version.
105+ #
106+ # For example, to raise exceptions for all current deprecations:
107+ # client = Net::IMAP.new(hostname, config: :future)
108+ # client.responses # raises an ArgumentError
109+ #
86110 # == Thread Safety
87111 #
88112 # *NOTE:* Updates to config objects are not synchronized for thread-safety.
@@ -128,6 +152,8 @@ def self.[](config)
128152 case config
129153 when Numeric
130154 raise RangeError , "unknown config version: %p" % [ config ]
155+ when Symbol
156+ raise KeyError , "unknown config name: %p" % [ config ]
131157 else
132158 raise TypeError , "no implicit conversion of %s to %s" % [
133159 config . class , Config
@@ -275,6 +301,14 @@ def to_h; data.members.to_h { [_1, send(_1)] } end
275301 responses_without_block : :warn ,
276302 ) . freeze
277303
304+ version_defaults [ :default ] = Config [ 0.4 ]
305+ version_defaults [ :current ] = Config [ 0.4 ]
306+ version_defaults [ :next ] = Config [ 0.5 ]
307+
308+ version_defaults [ :future ] = Config [ 0.5 ] . dup . update (
309+ responses_without_block : :raise ,
310+ ) . freeze
311+
278312 version_defaults . freeze
279313 end
280314 end
0 commit comments