class Selenium::WebDriver::Firefox::ProfilesIni

@api private

def [](name)

def [](name)
  path = @profile_paths[name]
  path && Profile.new(path)
end

def initialize

def initialize
  @ini_path = File.join(Util.app_data_path, 'profiles.ini')
  @profile_paths = {}
  parse if File.exist?(@ini_path)
end

def parse

def parse
  string      = File.read @ini_path
  name        = nil
  is_relative = nil
  path        = nil
  string.split("\n").each do |line|
    case line
    when /^\[Profile/
      name, path = nil if path_for(name, is_relative, path)
    when /^Name=(.+)$/
      name = Regexp.last_match(1).strip
    when /^IsRelative=(.+)$/
      is_relative = Regexp.last_match(1).strip == '1'
    when /^Path=(.+)$/
      path = Regexp.last_match(1).strip
      p = path_for(name, is_relative, path)
      @profile_paths[name] = p if p
    end
  end
end

def path_for(name, is_relative, path)

def path_for(name, is_relative, path)
  return unless [name, path].any?
  is_relative ? File.join(Util.app_data_path, path) : path
end

def refresh

def refresh
  @profile_paths.clear
  parse
end