Skip to content

🔧 Add versioned defaults #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2024
Merged

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Jun 22, 2024

Requires #300.

Copied from the rdoc:

Versioned defaults

The effective default configuration for a specific x.y version of net-imap can be loaded with the config keyword argument to Net::IMAP.new. Requesting default configurations for previous versions enables extra backward compatibility with those versions:

  client = Net::IMAP.new(hostname, config: 0.3)
  client.config.sasl_ir                  # => false
  client.config.responses_without_block  # => :silence_deprecation_warning

  client = Net::IMAP.new(hostname, config: 0.4)
  client.config.sasl_ir                  # => true
  client.config.responses_without_block  # => :silence_deprecation_warning

  client = Net::IMAP.new(hostname, config: 0.5)
  client.config.sasl_ir                  # => true
  client.config.responses_without_block  # => :warn

  client = Net::IMAP.new(hostname, config: :future)
  client.config.sasl_ir                  # => true
  client.config.responses_without_block  # => :raise

The versioned default configs inherit certain specific config options from Config.global, for example #debug:

  client = Net::IMAP.new(hostname, config: 0.4)
  Net::IMAP.debug = false
  client.config.debug?  # => false

  Net::IMAP.debug = true
  client.config.debug?  # => true

Named defaults

In addition to x.y version numbers, the following aliases are supported:

:default
    An alias for :current.

    NOTE: This is not the same as Config.default. It inherits some attributes from Config.global, for example: #debug.
:current
    An alias for the current x.y version's defaults.
:next
    The planned config for the next x.y version.
:future
    The planned eventual config for some future x.y version.

For example, to raise exceptions for all current deprecations:

  client = Net::IMAP.new(hostname, config: :future)
  client.responses  # raises an ArgumentError

@nevans nevans force-pushed the config/add-versioned_defaults branch from d4e472a to be8d5cd Compare June 22, 2024 14:46
@nevans nevans merged commit 394452e into ruby:master Jun 22, 2024
13 checks passed
@nevans nevans deleted the config/add-versioned_defaults branch June 22, 2024 14:53
@nevans nevans added the enhancement New feature or request label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant