Class: Firebrew::Firefox::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/firebrew/firefox/command.rb

Defined Under Namespace

Classes: Executer

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, executer = Executer.new) ⇒ Command

Returns a new instance of Command.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/firebrew/firefox/command.rb', line 11

def initialize(config={}, executer = Executer.new)
  @config = config
  @executer = executer
  begin
    result = if ENV['OS'].nil? then
      @executer.exec('%{firefox} --version' % self.escaped_config)
    else
      @executer.exec('"%{firefox}" --version' % @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

Instance Method Details

#versionObject



27
28
29
30
31
32
33
34
35
# File 'lib/firebrew/firefox/command.rb', line 27

def version
  return @version unless @version.nil?
  result = if ENV['OS'].nil? then
    @executer.exec('%{firefox} --version' % self.escaped_config)[0]
  else
    @executer.exec('"%{firefox}" --version' % @config)[0]
  end
  @version = result.match(/[0-9.]+/)[0]
end