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, #qx, reaper

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.



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

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

Instance Method Details

#source_dupObject



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

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

#spawn(format, rg_state, opts) ⇒ Object



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

def spawn(format, rg_state, opts)
  raise "BUG: #{self.inspect}#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



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

def to_hash
  ivars_to_hash(SIVS)
end