From bc374a76530826e7f701c6643a59423a2c912be1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 21 Dec 2015 05:05:09 +0000 Subject: enable "frozen_string_literal: true" While we're in the area, make a wording change from "GPLv3 or later" to "GPL-3.0+", as the latter is favored by SPDX.org --- lib/dtas/source/av.rb | 3 ++- lib/dtas/source/av_ff_common.rb | 9 +++++---- lib/dtas/source/cmd.rb | 3 ++- lib/dtas/source/common.rb | 2 +- lib/dtas/source/ff.rb | 3 ++- lib/dtas/source/file.rb | 5 +++-- lib/dtas/source/mp3gain.rb | 3 ++- lib/dtas/source/sox.rb | 10 ++++++---- lib/dtas/source/splitfx.rb | 5 +++-- 9 files changed, 26 insertions(+), 17 deletions(-) (limited to 'lib/dtas/source') diff --git a/lib/dtas/source/av.rb b/lib/dtas/source/av.rb index c86b5d2..baeaee4 100644 --- a/lib/dtas/source/av.rb +++ b/lib/dtas/source/av.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../../dtas' require_relative 'av_ff_common' diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb index 9f29b02..e1f221b 100644 --- a/lib/dtas/source/av_ff_common.rb +++ b/lib/dtas/source/av_ff_common.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../../dtas' require_relative '../source' require_relative '../replaygain' @@ -75,7 +76,7 @@ module DTAS::Source::AvFfCommon # :nodoc: cmd.concat(%W(-show_streams -show_format #@infile)) break if cmd == prev_cmd - err = "" + err = "".b s = qx(@env, cmd, err_str: err, no_raise: true) return false unless probe_ok?(s, err) s.scan(%r{^\[STREAM\]\n(.*?)\n\[/STREAM\]\n}mn) do |_| @@ -93,10 +94,10 @@ module DTAS::Source::AvFfCommon # :nodoc: end while incomplete.compact[0] s.scan(%r{^\[FORMAT\]\n(.*?)\n\[/FORMAT\]\n}m) do |_| - f = $1 + f = $1.dup f =~ /^duration=([\d\.]+)\s*$/nm and @duration = $1.to_f # TODO: multi-line/multi-value/repeated tags - f.gsub!(/^TAG:([^=]+)=(.*)$/ni) { |_| @comments[$1.upcase] = $2 } + f.gsub!(/^TAG:([^=]+)=(.*)$/ni) { |_| @comments[$1.upcase.freeze] = $2 } end ! @astreams.compact.empty? end diff --git a/lib/dtas/source/cmd.rb b/lib/dtas/source/cmd.rb index 4e730ea..46cf1b4 100644 --- a/lib/dtas/source/cmd.rb +++ b/lib/dtas/source/cmd.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../../dtas' require_relative '../source' require_relative '../command' diff --git a/lib/dtas/source/common.rb b/lib/dtas/source/common.rb index 94cea7d..bb4a40e 100644 --- a/lib/dtas/source/common.rb +++ b/lib/dtas/source/common.rb @@ -1,5 +1,5 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) module DTAS::Source::Common # :nodoc: attr_reader :dst_zero_byte # first byte this source object saw attr_reader :dst diff --git a/lib/dtas/source/ff.rb b/lib/dtas/source/ff.rb index d5e744c..33b46e9 100644 --- a/lib/dtas/source/ff.rb +++ b/lib/dtas/source/ff.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../../dtas' require_relative 'av_ff_common' diff --git a/lib/dtas/source/file.rb b/lib/dtas/source/file.rb index 75b4a43..7f99ad0 100644 --- a/lib/dtas/source/file.rb +++ b/lib/dtas/source/file.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../../dtas' require_relative '../source' require_relative '../command' @@ -67,7 +68,7 @@ module DTAS::Source::File # :nodoc: # creates the effect to fill the TRIMFX env def trimfx return unless @offset || @trim - fx = "trim #{offset_samples}s" + fx = "trim #{offset_samples}s".dup if @trim && @trim[1] fx << sprintf(' =%0.9gs', (@trim[0] + @trim[1]) * format.rate) end diff --git a/lib/dtas/source/mp3gain.rb b/lib/dtas/source/mp3gain.rb index 6637768..0b3d481 100644 --- a/lib/dtas/source/mp3gain.rb +++ b/lib/dtas/source/mp3gain.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require_relative '../process' module DTAS::Source::Mp3gain # :nodoc: diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index 6f02f99..701a36a 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -1,5 +1,7 @@ # Copyright (C) 2013-2015 all contributors -# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true +# encoding: binary require_relative '../../dtas' require_relative '../source' require_relative '../replaygain' @@ -39,7 +41,7 @@ class DTAS::Source::Sox # :nodoc: end def try(infile, offset = nil, trim = nil) - err = "" + err = "".b cmd = %W(soxi -s #{infile}) s = qx(@env.dup, cmd, err_str: err, no_raise: true) return if err =~ /soxi FAIL formats:/ @@ -65,8 +67,8 @@ class DTAS::Source::Sox # :nodoc: tmp = {} case @infile when String - qx(@env, %W(soxi -a #@infile)).split(/\n/n).each do |line| - key, value = line.split(/=/n, 2) + qx(@env, %W(soxi -a #@infile)).split("\n").each do |line| + key, value = line.split('=', 2) key && value or next # TODO: multi-line/multi-value/repeated tags tmp[key.upcase] = value diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb index 02c3a9d..fad165f 100644 --- a/lib/dtas/source/splitfx.rb +++ b/lib/dtas/source/splitfx.rb @@ -1,5 +1,6 @@ # Copyright (C) 2014-2015 all contributors -# License: GPLv3 or later +# License: GPL-3.0+ +# frozen_string_literal: true require 'yaml' require_relative 'sox' require_relative '../splitfx' @@ -27,7 +28,7 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: return false if !st.file? || st.size > MAX_YAML_SIZE # read 4 bytes first to ensure we have a YAML file with a hash: - buf = "" + buf = "".dup File.open(ymlfile, "rb") do |fp| return false if fp.read(4, buf) != "---\n" buf << fp.read -- cgit v1.2.3-24-ge0c7