class Selenium::WebDriver::Firefox::ProfilesIni
@api private
Public Class Methods
new()
click to toggle source
# File lib/selenium/webdriver/firefox/profiles_ini.rb, line 8 def initialize @ini_path = File.join(Util.app_data_path, "profiles.ini") @profile_paths = {} parse if File.exist?(@ini_path) end
Public Instance Methods
[](name)
click to toggle source
# File lib/selenium/webdriver/firefox/profiles_ini.rb, line 15 def [](name) path = @profile_paths[name] path && Profile.new(path) end
refresh()
click to toggle source
# File lib/selenium/webdriver/firefox/profiles_ini.rb, line 20 def refresh @profile_paths.clear parse end
Private Instance Methods
parse()
click to toggle source
# File lib/selenium/webdriver/firefox/profiles_ini.rb, line 27 def parse string = File.read @ini_path name = nil is_relative = nil path = nil string.split("\n").each do |line| case line when /^\[Profile/ if p = path_for(name, is_relative, path) @profile_paths[name] = p name, path = nil end when /^Name=(.+)$/ name = $1.strip when /^IsRelative=(.+)$/ is_relative = $1.strip == "1" when /^Path=(.+)$/ path = $1.strip end end if p = path_for(name, is_relative, path) @profile_paths[name] = p end end
path_for(name, is_relative, path)
click to toggle source
# File lib/selenium/webdriver/firefox/profiles_ini.rb, line 54 def path_for(name, is_relative, path) return unless [name, path].any? path = is_relative ? File.join(Util.app_data_path, path) : path end