Class: Firefox::Profile
- Inherits:
-
Object
- Object
- Firefox::Profile
- Defined in:
- lib/firefox/profile.rb
Overview
A Firefox profile. Allows basic creation and management of a profile. Supports preference setting and addon installation
Instance Attribute Summary collapse
-
#addons ⇒ Object
Returns the value of attribute addons.
-
#prefs ⇒ Object
Returns the value of attribute prefs.
Class Method Summary collapse
- .call_ff_create(path) ⇒ Object
-
.create(path) ⇒ Object
Register a new profile with firefox.
Instance Method Summary collapse
-
#initialize(path) ⇒ Profile
constructor
A new instance of Profile.
- #save! ⇒ Object
Constructor Details
Instance Attribute Details
#addons ⇒ Object
Returns the value of attribute addons.
10 11 12 |
# File 'lib/firefox/profile.rb', line 10 def addons @addons end |
#prefs ⇒ Object
Returns the value of attribute prefs.
10 11 12 |
# File 'lib/firefox/profile.rb', line 10 def prefs @prefs end |
Class Method Details
.call_ff_create(path) ⇒ Object
36 37 38 39 |
# File 'lib/firefox/profile.rb', line 36 def call_ff_create path name = File.split(path).last %x[#{Base.bin_path} -CreateProfile \"#{name} #{File.realpath(path)}\" 2>&1] end |
.create(path) ⇒ Object
Register a new profile with firefox. This is the right way to initialize a new profile. It checks if the given directory exists, creates it if not
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/firefox/profile.rb', line 25 def create path FileUtils.mkdir_p(path) unless File.directory?(path) FileUtils.touch(%W[prefs user].map { |f| File.join(path,"#{f}.js") }) response = call_ff_create(path) if response =~ /Error/ raise ProfileInitializationError, response else self.new(path) end end |
Instance Method Details
#save! ⇒ Object
17 18 19 |
# File 'lib/firefox/profile.rb', line 17 def save! self.prefs.write! end |