dtas.git  about / heads / tags
duct tape audio suite for *nix
blob 5ac1eb73d1a53b9b432fcf960c911809b865dcde 825 bytes (raw)
$ git show v0.16.1:lib/dtas/command.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
# Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# frozen_string_literal: true
require_relative 'serialize'
require 'shellwords'

# common code for wrapping SoX/ecasound/... commands
module DTAS::Command # :nodoc:
  include DTAS::Serialize
  attr_reader :pid
  attr_reader :to_io
  attr_accessor :command
  attr_accessor :env
  attr_accessor :spawn_at

  COMMAND_DEFAULTS = {
    "env" => {},
    "command" => nil,
  }

  def command_init(defaults = {})
    @pid = nil
    @to_io = nil
    @spawn_at = nil
    COMMAND_DEFAULTS.merge(defaults).each do |k,v|
      v = v.dup if Hash === v || Array === v
      instance_variable_set("@#{k}", v)
    end
  end

  def on_death(status)
    @pid = nil
  end

  def command_string
    @command
  end
end

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git