class Firebrew::Firefox::Profile::Manager
Public Class Methods
new(params={})
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 10 def initialize(params={}) @base_dir = params[:base_dir] @data_file = params[:data_file] || 'profiles.ini' raise Firebrew::ProfilesFileNotFoundError, %["profiles.ini" not found: #{self.data_path}] unless File.exists? self.data_path end
Public Instance Methods
all()
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 16 def all sections = IniFile.load(self.data_path).to_h profiles = sections.find_all{|(name,prop)| name.match(/^Profile\d+$/)} profiles.map do |(name,prop)| Profile.new( name: prop['Name'], path: self.profile_path(prop['Path'], prop['IsRelative'] == '1'), is_default: prop['Default'] == '1', ) end end
find(name)
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 28 def find(name) self.all.find{|p| p.name == name } end
find!(name)
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 32 def find!(name) result = self.find(name) raise Firebrew::ProfileNotFoundError, "Profile not found: #{name}" if result.nil? result end
Protected Instance Methods
data_path()
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 40 def data_path File.expand_path File.join(@base_dir, @data_file) end
profile_path(path, is_relative)
click to toggle source
# File lib/firebrew/firefox/profile.rb, line 44 def profile_path(path, is_relative) path = is_relative ? File.join(@base_dir, path) : path File.expand_path path end