Sha256: 7e7b84dc4a96f0b55645894ca57f15197c1cbe6e01127581e02437749c0e6bad

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 Bytes

Contents

module MBidle
  class Accounts < Array
    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

    def for_path(path)
      find { |account| account.matches?(path) }
    end

    def for_paths(*paths)
      paths.map { |path| for_path(path) }.compact
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mbidle-1.1.1 lib/mbidle/accounts.rb
mbidle-1.1.0 lib/mbidle/accounts.rb
mbidle-1.0.1 lib/mbidle/accounts.rb