Class: DTAS::Source::Cmd

Inherits:
Object
  • Object
show all
Includes:
Command, Process, DTAS::Serialize, Common
Defined in:
lib/dtas/source/cmd.rb

Overview

:nodoc:

Constant Summary collapse

SIVS =
%w(command env)

Constants included from Process

Process::PIDS

Constants included from Command

Command::COMMAND_DEFAULTS

Instance Attribute Summary

Attributes included from Common

#dst, #dst_zero_byte, #requeued

Attributes included from Command

#command, #env, #pid, #spawn_at, #to_io

Instance Method Summary collapse

Methods included from DTAS::Serialize

#ivars_to_hash

Methods included from Common

#dst_assoc

Methods included from Process

#dtas_spawn, #env_expand, #env_expand_ary, #env_expand_i, #qx, reaper

Methods included from DTAS::SpawnFix

#spawn

Methods included from XS

#xs

Methods included from Command

#command_init, #command_string, #on_death

Constructor Details

#initialize(command) ⇒ Cmd

Returns a new instance of Cmd.



19
20
21
# File 'lib/dtas/source/cmd.rb', line 19

def initialize(command)
  command_init(command: command)
end

Instance Method Details

#source_dupObject



23
24
25
26
27
# File 'lib/dtas/source/cmd.rb', line 23

def source_dup
  rv = self.class.new
  SIVS.each { |iv| rv.__send__("#{iv}=", self.__send__(iv)) }
  rv
end

#src_spawn(format, rg_state, opts) ⇒ Object



35
36
37
38
39
# File 'lib/dtas/source/cmd.rb', line 35

def src_spawn(format, rg_state, opts)
  raise "BUG: #{self.inspect}#src_spawn called twice" if @to_io
  e = format.to_env
  @pid = dtas_spawn(e.merge!(@env), command_string, opts)
end

#to_hashObject Also known as: to_hsh



29
30
31
# File 'lib/dtas/source/cmd.rb', line 29

def to_hash
  ivars_to_hash(SIVS)
end