diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-08-25 09:25:07 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-08-25 09:29:46 +0000 |
commit | 68ffa097e187da663fa3f537b430428ea5e8de2e (patch) | |
tree | be7d441b68ab8c77a7ebc062c129b5701bf2a5b1 /lib/dtas/source/cmd.rb | |
parent | 9cd8e2776edc246950d2c7ebdea833489efb1d1f (diff) | |
download | dtas-68ffa097e187da663fa3f537b430428ea5e8de2e.tar.gz |
We should've done this at the start, but we didn't.
Diffstat (limited to 'lib/dtas/source/cmd.rb')
-rw-r--r-- | lib/dtas/source/cmd.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/dtas/source/cmd.rb b/lib/dtas/source/cmd.rb new file mode 100644 index 0000000..2507101 --- /dev/null +++ b/lib/dtas/source/cmd.rb @@ -0,0 +1,40 @@ +# -*- encoding: binary -*- +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative '../../dtas' +require_relative '../source' +require_relative '../command' +require_relative '../serialize' + +class DTAS::Source::Cmd # :nodoc: + require_relative '../source/common' + + include DTAS::Command + include DTAS::Process + include DTAS::Source::Common + include DTAS::Serialize + + SIVS = %w(command env) + + def initialize(command) + command_init(command: command) + end + + def source_dup + rv = self.class.new + SIVS.each { |iv| rv.__send__("#{iv}=", self.__send__(iv)) } + rv + end + + def to_hash + ivars_to_hash(SIVS) + end + + alias to_hsh to_hash + + 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 +end |