5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/firefox/profile.rb', line 5
def self.path(profile = nil, inifile = nil)
base_path = File.expand_path('~/.mozilla/firefox')
unless inifile
inifile = File.join(base_path, 'profiles.ini')
end
ini = IniFile.new(inifile)
sections = ini.sections.grep(/Profile/)
subpath = nil
if profile
sections.each do |section|
h = ini[section]
if h["Name"] == profile
subpath = h['Path']
break
end
end
else
if sections.length == 1
subpath = ini[sections.first]['Path']
elsif sections.length > 1
sections.each do |section|
h = ini[section]
if h.include?('Default') && h['Default'] == "1"
subpath = h['Path']
break
end
end
end
end
subpath = (subpath.nil? ? '' : subpath)
File.join(base_path, subpath)
end
|