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.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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

Instance Method Details

#versionObject



28
29
30
31
32
33
34
35
36
# 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