class Firebrew::Firefox::Command

Public Class Methods

new(config={}, executer = Executer.new) click to toggle source
# File lib/firebrew/firefox/command.rb, line 12
def initialize(config={}, executer = Executer.new)
  @config = config
  @executer = executer
  begin
    result = if OS.windows? then
      @executer.exec('"%{firefox}" --version' % @config)
    else
      @executer.exec('%{firefox} --version' % self.escaped_config)
    end
    raise Firebrew::FirefoxCommandError, 'Command is not Firefox: %{firefox}' % @config unless result[0] =~ /Mozilla Firefox/
    raise Firebrew::FirefoxCommandError, 'Command is not Firefox: %{firefox}' % @config unless result[1] == 0
  rescue SystemCallError
    raise Firebrew::FirefoxCommandError, 'Firefox command not found: %{firefox}' % @config
  end
end

Public Instance Methods

version() click to toggle source
# File lib/firebrew/firefox/command.rb, line 28
def version
  return @version unless @version.nil?
  result = if OS.windows? then
    @executer.exec('"%{firefox}" --version' % @config)[0]
  else
    @executer.exec('%{firefox} --version' % self.escaped_config)[0]
  end
  @version = result.match(/[0-9.]+/)[0]
end

Protected Instance Methods

escaped_config() click to toggle source
# File lib/firebrew/firefox/command.rb, line 40
def escaped_config
  result = @config.clone
  result[:firefox] = Shellwords.escape result[:firefox]
  result
end