Class: ExcADG::Payload::Wrapper::Bin
- Inherits:
-
Object
- Object
- ExcADG::Payload::Wrapper::Bin
- 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
Defined Under Namespace
Classes: CommandFailed
Instance Attribute Summary
Attributes included from ExcADG::Payload
Instance Method Summary collapse
Methods included from ExcADG::Payload
Instance Method Details
#get ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/excadg/payload/wrapper.rb', line 14 def get lambda { |deps_data| begin f = nil Dir.mktmpdir { |dir| f = File.new File.join(dir, 'data.json'), 'w+' f.write JSON.generate deps_data f.flush stdout, stderr, status = Open3.capture3({ 'DEPS_DATAFILE' => f.path }, args) data = { stdout:, stderr:, exitcode: status.exitstatus } raise CommandFailed, data unless status.exitstatus.zero? data } ensure f&.close end } end |
#sanitize(args) ⇒ Object
34 35 36 37 38 |
# File 'lib/excadg/payload/wrapper.rb', line 34 def sanitize args raise "arguments should be a String, got #{args}" unless args.is_a? String args end |