Class: Released::Goals::Shell

Inherits:
Released::Goal show all
Defined in:
lib/released/goals/shell.rb

Overview

TODO: rename

Instance Method Summary collapse

Methods inherited from Released::Goal

#assessable?

Constructor Details

#initialize(config = {}) ⇒ Shell

Returns a new instance of Shell.



7
8
9
# File 'lib/released/goals/shell.rb', line 7

def initialize(config = {})
  @command = config.fetch('command')
end

Instance Method Details

#achieved?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/released/goals/shell.rb', line 35

def achieved?
  false
end

#assessObject



19
20
21
# File 'lib/released/goals/shell.rb', line 19

def assess
  sleep 1
end

#effectful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/released/goals/shell.rb', line 15

def effectful?
  false
end

#failure_reasonObject



39
40
41
# File 'lib/released/goals/shell.rb', line 39

def failure_reason
  'command not executed'
end

#to_sObject



11
12
13
# File 'lib/released/goals/shell.rb', line 11

def to_s
  "shell (#{@command})"
end

#try_achieveObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/released/goals/shell.rb', line 23

def try_achieve
  stdout = ''
  stderr = ''
  piper = Released::Piper.new(stdout: stdout, stderr: stderr)

  begin
    piper.run(@command, [])
  rescue
    raise "Failed execute command!\n\nstderr:\n#{stderr}\n\nstdout:\n#{stdout}"
  end
end