class RenuoBinCheck::ServantThread

Attributes

script_config[R]

Public Class Methods

new(script_config) click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 7
def initialize(script_config)
  @script_config = script_config
  script_files = @script_config.script_files
  @cacher = Cacher.new(@script_config.script_name, script_files) if script_files
end

Public Instance Methods

run() click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 13
def run
  @script_config.script_files ? run_with_cache : run_command
end

Private Instance Methods

override_output() click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 31
def override_output
  standard_output = @script_config.script_standard_output ||= @result.standard_output
  error_output = @script_config.script_error_output ||= @result.error_output
  @result = Result.new(standard_output + @script_config.appended_standard_output,
                       error_output + @script_config.appended_error_output,
                       @result.exit_code)
end
reverse_result() click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 39
def reverse_result
  Result.new(@result.error_output, @result.standard_output, @result.exit_code == 0 ? 1 : 0)
end
run_command() click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 24
def run_command
  standard_output, error_output, process = Open3.capture3(@script_config.script_command)
  @result = Result.new(standard_output, error_output, process.exitstatus)
  override_output
  @script_config.reversed_exit? ? reverse_result : @result
end
run_with_cache() click to toggle source
# File lib/renuo_bin_check/servant_thread.rb, line 19
def run_with_cache
  @cacher.cache(run_command) unless @cacher.exists?
  @cacher.result
end