Class: Mailmate::Config Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mailmate/config.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The Config class is the storage and loader; consumers should reach it through ‘Mailmate.config` rather than constructing instances directly.

Mailmate.config — process-wide configuration with three-layer loading:

1. Built-in defaults (macOS-standard paths, no identities)
2. YAML at ~/.config/mailmate/config.yml (silently ignored if missing)
3. Environment variables (override YAML)

Personal data — identity addresses, custom paths — lives in the YAML or env vars, never in the gem source. ‘mmdiscover` populates the YAML on first run from MailMate’s own Sources.plist + Identities.plist.

Constant Summary collapse

DEFAULT_APP_SUPPORT_DIR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

File.expand_path("~/Library/Application Support/MailMate")
DEFAULT_CONFIG_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

File.expand_path("~/.config/mailmate/config.yml")
KNOWN_KEYS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[app_support_dir identities display_timezone].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml_path: DEFAULT_CONFIG_PATH, env: ENV) ⇒ Config

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Config.



39
40
41
42
43
44
45
46
# File 'lib/mailmate/config.rb', line 39

def initialize(yaml_path: DEFAULT_CONFIG_PATH, env: ENV)
  @app_support_dir  = DEFAULT_APP_SUPPORT_DIR
  @identities       = []
  @display_timezone = nil

  load_yaml!(yaml_path)
  apply_env!(env)
end

Instance Attribute Details

#app_support_dirObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/mailmate/config.rb', line 25

def app_support_dir
  @app_support_dir
end

#display_timezoneObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/mailmate/config.rb', line 25

def display_timezone
  @display_timezone
end

#identitiesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/mailmate/config.rb', line 25

def identities
  @identities
end

Class Method Details

.instanceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/mailmate/config.rb', line 27

def self.instance
  @instance ||= new
end

.reload!(yaml_path: DEFAULT_CONFIG_PATH, env: ENV) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Replace the singleton with a freshly-loaded config. Accepts the same kwargs as ‘.new`, so tests can scope a config block without poking ivars. Passing no args reloads from defaults (YAML at the default path, real ENV).



35
36
37
# File 'lib/mailmate/config.rb', line 35

def self.reload!(yaml_path: DEFAULT_CONFIG_PATH, env: ENV)
  @instance = new(yaml_path: yaml_path, env: env)
end

Instance Method Details

#db_headersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



54
55
56
# File 'lib/mailmate/config.rb', line 54

def db_headers
  File.join(app_support_dir, "Database.noindex", "Headers")
end

#identities_plistObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



66
67
68
# File 'lib/mailmate/config.rb', line 66

def identities_plist
  File.join(app_support_dir, "Identities.plist")
end

#imap_rootObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Derived paths. Each follows from app_support_dir; if a user has a non-default MailMate install, overriding app_support_dir flows through.



50
51
52
# File 'lib/mailmate/config.rb', line 50

def imap_root
  File.join(app_support_dir, "Messages.noindex", "IMAP")
end

#mailboxes_plistObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
# File 'lib/mailmate/config.rb', line 58

def mailboxes_plist
  File.join(app_support_dir, "Mailboxes.plist")
end

#sources_plistObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
# File 'lib/mailmate/config.rb', line 62

def sources_plist
  File.join(app_support_dir, "Sources.plist")
end