class MBidle::Accounts

Public Class Methods

read() click to toggle source
# File lib/mbidle/accounts.rb, line 3
def self.read
  accounts = Accounts.new

  File.open(File.expand_path('~/.mbsyncrc'), 'r') do |f|
    f.each_line do |line|
      next if line =~ /^#/ || line =~ /^$/

      if (match = /^IMAPAccount (?<name>.*)$/.match(line))
        accounts << Account.new(match[:name])
      else
        accounts.last.read_config_line(line)
      end
    end
  end

  accounts
end

Public Instance Methods

for_path(path) click to toggle source
# File lib/mbidle/accounts.rb, line 21
def for_path(path)
  find { |account| account.matches?(path) }
end
for_paths(*paths) click to toggle source
# File lib/mbidle/accounts.rb, line 25
def for_paths(*paths)
  paths.map { |path| for_path(path) }.compact
end