module AudioMonster::Configuration

Constants

AES46_2002_DATE_FORMAT

by default, using the PRSS date format, but this is not the actual cart chunk (AES46-2002) standard

AES46_2002_TIME_FORMAT
BINARIES_KEYS
FILE_SUCCESS

constants

LAME_ERROR_RE
LAME_MODES
LAME_SUCCESS_RE
MP2_BITRATES

Allowable values for mp2 (MPEG1 layer II)

MP2_SAMPLE_RATES
MP3VAL_ERROR_RE
MP3VAL_IGNORE_RE
MP3VAL_WARNING_RE
MP3_BITRATES
MP3_SAMPLE_RATES

Allowable values for mp3 (MPEG1 layer III)

PRSS_DATE_FORMAT
SOX_ERROR_RE
TWOLAME_MODES
TWOLAME_SUCCESS_RE
VALID_OPTIONS_KEYS

Public Class Methods

extended(base) click to toggle source
if (version.size > 0) && (version[1].to_i < 14) || ((version[1].to_i == 14) && (version[2].to_i < 1))
  self.sox_16_bits = '-w'
  self.sox_8_bits = '-b'
else
  self.sox_16_bits = '-b 16'
  self.sox_8_bits = '-b 8'
end

end

# File lib/audio_monster/configuration.rb, line 142
def self.extended(base)
  base.reset!
end
included(base) click to toggle source
# File lib/audio_monster/configuration.rb, line 46
def self.included(base)

  def current_options
    @current_options ||= {}
  end

  def current_options=(opts)
    @current_options = opts
  end

  VALID_OPTIONS_KEYS.each do |key|
    define_method "#{key}=" do |arg|
      self.instance_variable_set("@#{key}", arg)
      self.current_options.merge!({:"#{key}" => arg})
    end
  end

  base.extend(ClassMethods)
end

Public Instance Methods

apply_configuration(opts={}) click to toggle source
# File lib/audio_monster/configuration.rb, line 80
def apply_configuration(opts={})
  options = AudioMonster.options.merge(opts)
  self.current_options = options
  VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end
bin(name) click to toggle source
# File lib/audio_monster/configuration.rb, line 123
def bin(name)
  "#{bin_dir}#{name}"
end
check_binaries() click to toggle source
# File lib/audio_monster/configuration.rb, line 93
def check_binaries
  BINARIES_KEYS.each { |bin| find_executable(bin.to_s) }
end
configure() { |self| ... } click to toggle source

Convenience method to allow for global setting of configuration options

# File lib/audio_monster/configuration.rb, line 89
def configure
  yield self
end
current_options() click to toggle source
# File lib/audio_monster/configuration.rb, line 48
def current_options
  @current_options ||= {}
end
current_options=(opts) click to toggle source
# File lib/audio_monster/configuration.rb, line 52
def current_options=(opts)
  @current_options = opts
end
find_executable(bin) click to toggle source
# File lib/audio_monster/configuration.rb, line 97
def find_executable(bin)
  which = File.which(bin)
  if which
    puts "  #{bin}:    #{which}"
  else
    puts "X #{bin}:    MISSING"
  end
end
options() click to toggle source
# File lib/audio_monster/configuration.rb, line 74
def options
  options = {}
  VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
  options
end
reset!() click to toggle source

Reset configuration options to their defaults

# File lib/audio_monster/configuration.rb, line 107
def reset!
  self.debug   = ENV['DEBUG']
  self.logger  = Logger.new(STDOUT)
  self.bin_dir = nil
  self.tmp_dir = '/tmp/audio_monster'
  self.file    = 'file'
  self.ffmpeg  = 'ffmpeg'
  self.ffprobe = 'ffprobe'
  self.lame    = 'lame'
  self.mp3val  = 'mp3val'
  self.sox     = 'sox'
  self.soxi    = 'soxi'
  self.twolame = 'twolame'
  self
end