Class: ExcADG::Payload::Wrapper::Bin

Inherits:
Object
  • Object
show all
Includes:
ExcADG::Payload
Defined in:
lib/excadg/payload/wrapper.rb

Overview

runs a binary save its stdout, stderr and exit code to state provides path to temp file with dependencies data JSON in a DEPS_DATAFILE env variable

Direct Known Subclasses

Ruby

Defined Under Namespace

Classes: CommandFailed

Instance Attribute Summary

Attributes included from ExcADG::Payload

#args

Instance Method Summary collapse

Methods included from ExcADG::Payload

#initialize

Instance Method Details

#getObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/excadg/payload/wrapper.rb', line 14

def get
  lambda { |deps_data|
      Dir.mktmpdir { |dir|
        Log.debug "temp dir #{} for data is ready"
        stdout, stderr, status = File.open(File.join(dir, 'data.json'), 'w+') { |f|
          f.write JSON.generate deps_data
          f.flush
          Log.debug "data is in #{f.path}"
          Open3.capture3({ 'DEPS_DATAFILE' => f.path }, args)
        }
        Log.debug "payload process finished"
        data = { stdout:, stderr:, exitcode: status.exitstatus }
        raise CommandFailed, data unless status.exitstatus.zero?
        Log.debug "returning data"
        data
      }
  }
end

#sanitize(args) ⇒ Object



33
34
35
36
37
# File 'lib/excadg/payload/wrapper.rb', line 33

def sanitize args
  raise "arguments should be a String, got #{args}" unless args.is_a? String

  args
end