Class: Battlestation::Operations::Runner

Inherits:
Base
  • Object
show all
Defined in:
lib/battlestation/operations/runner.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #opts, #type

Instance Method Summary collapse

Methods inherited from Base

#execute

Constructor Details

#initialize(cmd, opts = {}) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
10
11
# File 'lib/battlestation/operations/runner.rb', line 6

def initialize(cmd, opts = {})
  @cmd  = cmd
  @type = :runner
  @name = "runner-#{cmd.split(" ").first}"
  @opts = opts
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



4
5
6
# File 'lib/battlestation/operations/runner.rb', line 4

def cmd
  @cmd
end

Instance Method Details

#statusObject



13
14
15
16
17
18
19
20
21
# File 'lib/battlestation/operations/runner.rb', line 13

def status
  Battlestation.ui.notice "Executing `#{cmd}`"

  if system("#{cmd} &> /dev/null")
    { status: :okay, msg: "`#{cmd}` executed successfully", name: name }
  else
    { status: :fail, msg: "`#{cmd}` failed to execute", name: name }
  end
end