From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-2.2 required=3.0 tests=AWL,BAYES_00,URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B06BF63381D for ; Mon, 26 Jan 2015 21:52:51 +0000 (UTC) Received: from localhost ([::1]:44248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFraV-00015y-5E for dtas-all@80x24.org; Mon, 26 Jan 2015 16:52:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFraT-00013K-9h for dtas-all@nongnu.org; Mon, 26 Jan 2015 16:52:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFraO-0005rp-AM for dtas-all@nongnu.org; Mon, 26 Jan 2015 16:52:49 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:45547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFraO-0005nW-4r for dtas-all@nongnu.org; Mon, 26 Jan 2015 16:52:44 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5F0C663381C; Mon, 26 Jan 2015 21:52:41 +0000 (UTC) From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH] use omap (ordered map) for env hashes Date: Mon, 26 Jan 2015 21:52:38 +0000 Message-Id: <1422309158-13329-1-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.3.0.rc0.45.ga7910d6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 Cc: Eric Wong X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org While the Ruby Hash class is ordered in 1.9+, the YAML specifications do not specify hashes as ordered by default. Thus we must explicitly declare ordering via !omap for interopability with non-Ruby tools. This makes the YAML output of dtas-sourcedit and dtas-sinkedit slightly more verbose Users of dtas-splitfx are also encouraged to declare !omap when creating their YAML files for interoperability. Ordering env is important because any implementation of built-in variable expansion is dependent on it. --- Documentation/dtas-splitfx.txt | 4 ++-- examples/splitfx.sample.yml | 2 +- examples/tfx.sample.yml | 2 +- lib/dtas/player.rb | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt index 3c421a4..8e37523 100644 --- a/Documentation/dtas-splitfx.txt +++ b/Documentation/dtas-splitfx.txt @@ -38,8 +38,8 @@ to use ecasound(1), too. # FILE FORMAT * infile - string, the pathname of the original audio file -* env - hash of environment variables to set for all commands - env: +* env - ordered hash of environment variables to set for all commands + env: !omap FX: vol +3dB stats * comments - hash of common tags for all audio (e.g. ARTIST, ALBUM, YEAR) comments: diff --git a/examples/splitfx.sample.yml b/examples/splitfx.sample.yml index d7ee06b..bbd224b 100644 --- a/examples/splitfx.sample.yml +++ b/examples/splitfx.sample.yml @@ -11,7 +11,7 @@ comments: # the sox command for dtas-player playback, there is no need to # specify this as it is the default: # command: exec sox "$INFILE" $SOXFMT - $TRIMFX $RGFX $FX -env: +env: !omap PATH: $PATH # these effects may be used in any command in this file, including targets SOX_OPTS: $SOX_OPTS -R diff --git a/examples/tfx.sample.yml b/examples/tfx.sample.yml index 2cbfbbc..205a0a1 100644 --- a/examples/tfx.sample.yml +++ b/examples/tfx.sample.yml @@ -4,7 +4,7 @@ # test_trimfx.rb relies on this. --- infile: foo.flac -env: +env: !omap PATH: $PATH SOX_OPTS: $SOX_OPTS -R I2: second.flac diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index d63bc8a..d6707c3 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -120,6 +120,10 @@ class DTAS::Player # :nodoc: rv end + def to_omap(hash) + YAML::Omap === hash ? hash : YAML::Omap.new.merge!(hash) + end + def self.load(hash) rv = new rv.instance_eval do @@ -150,6 +154,7 @@ class DTAS::Player # :nodoc: @source_map.each do |name, src| src_hsh = v[name] or next src.load!(src_hsh) + src.env = to_omap(src.env) end source_map_reload end @@ -161,6 +166,7 @@ class DTAS::Player # :nodoc: if sinks = hash["sinks"] sinks.each do |sink_hsh| sink = DTAS::Sink.load(sink_hsh) + sink.env = to_omap(sink.env) @sinks[sink.name] = sink end end -- EW