Module: AudioMonster::Configuration
- Included in:
- AudioMonster, Monster
- Defined in:
- lib/audio_monster/configuration.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- FILE_SUCCESS =
constants
/\S+: (MP2|MPEG ADTS, layer II, v1), \S+ kBits, \S+ kHz, (JStereo|Stereo|Mono|2x Monaural|Dual-Ch|Monaural|JntStereo)/
- MP3VAL_WARNING_RE =
/WARNING/
- MP3VAL_ERROR_RE =
/ERROR/
- MP3VAL_IGNORE_RE =
/(^Done!|Non-layer-III frame encountered. See related INFO message for details.|No supported tags in the file|It seems that file is truncated or there is garbage at the end of the file|MPEG stream error, resynchronized successfully)/
- MPCK_ERROR_RE =
/(mpck:|errors)/
- MPCK_IGNORE_RE =
/errors(\s*)(CRC error|none)/
- LAME_SUCCESS_RE =
/0/
- LAME_ERROR_RE =
/fatal error/
- SOX_ERROR_RE =
/error:/
- TWOLAME_SUCCESS_RE =
/0/
- MP2_BITRATES =
Allowable values for mp2 (MPEG1 layer II)
[32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
- MP2_SAMPLE_RATES =
['32000', '44100', '48000']
- TWOLAME_MODES =
(s)tereo, (j)oint, (d)ual, (m)ono or (a)uto
['s', 'j', 'd', 'm', 'a']
- MP3_SAMPLE_RATES =
Allowable values for mp3 (MPEG1 layer III)
['32000', '44100', '48000']
- MP3_BITRATES =
[32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
- LAME_MODES =
(j)oint, (s)imple stereo, (f)orce, (d)dual-mono, (m)ono
['j', 's', 'f', 'd', 'm']
- AES46_2002_DATE_FORMAT =
by default, using the PRSS date format, but this is not the actual cart chunk (AES46-2002) standard
'%Y-%m-%d'
- PRSS_DATE_FORMAT =
'%Y/%m/%d'
- AES46_2002_TIME_FORMAT =
'%H:%M:%S'
- BINARIES_KEYS =
[:file, :ffmpeg, :ffprobe, :flac, :lame, :mpck, :mp3val, :sox, :soxi, :madplay, :twolame].freeze
- VALID_OPTIONS_KEYS =
([ :logger, :bin_dir, :tmp_dir, :debug ] + BINARIES_KEYS).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #apply_configuration(opts = {}) ⇒ Object
- #bin(name) ⇒ Object
- #check_binaries ⇒ Object
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow for global setting of configuration options.
- #current_options ⇒ Object
- #current_options=(opts) ⇒ Object
- #find_executable(bin) ⇒ Object
- #options ⇒ Object
-
#reset! ⇒ Object
Reset configuration options to their defaults.
Class Method Details
.extended(base) ⇒ Object
148 149 150 |
# File 'lib/audio_monster/configuration.rb', line 148 def self.extended(base) base.reset! end |
.included(base) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/audio_monster/configuration.rb', line 49 def self.included(base) def @current_options ||= {} end def (opts) @current_options = opts end VALID_OPTIONS_KEYS.each do |key| define_method "#{key}=" do |arg| self.instance_variable_set("@#{key}", arg) self..merge!({:"#{key}" => arg}) end end base.extend(ClassMethods) end |
Instance Method Details
#apply_configuration(opts = {}) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/audio_monster/configuration.rb', line 83 def apply_configuration(opts={}) = AudioMonster..merge(opts) self. = VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
#bin(name) ⇒ Object
129 130 131 |
# File 'lib/audio_monster/configuration.rb', line 129 def bin(name) "#{bin_dir}#{name}" end |
#check_binaries ⇒ Object
96 97 98 |
# File 'lib/audio_monster/configuration.rb', line 96 def check_binaries BINARIES_KEYS.each { |bin| find_executable(bin.to_s) } end |
#configure {|_self| ... } ⇒ Object
Convenience method to allow for global setting of configuration options
92 93 94 |
# File 'lib/audio_monster/configuration.rb', line 92 def configure yield self end |
#current_options ⇒ Object
51 52 53 |
# File 'lib/audio_monster/configuration.rb', line 51 def @current_options ||= {} end |
#current_options=(opts) ⇒ Object
55 56 57 |
# File 'lib/audio_monster/configuration.rb', line 55 def (opts) @current_options = opts end |
#find_executable(bin) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/audio_monster/configuration.rb', line 100 def find_executable(bin) which = File.which(bin) if which puts " #{bin}: #{which}" else puts "X #{bin}: MISSING" end end |
#options ⇒ Object
77 78 79 80 81 |
# File 'lib/audio_monster/configuration.rb', line 77 def = {} VALID_OPTIONS_KEYS.each { |k| [k] = send(k) } end |
#reset! ⇒ Object
Reset configuration options to their defaults
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/audio_monster/configuration.rb', line 110 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.flac = 'flac' self.lame = 'lame' self.mpck = 'mpck' self.mp3val = 'mp3val' self.sox = 'sox' self.soxi = 'soxi' self.madplay = 'madplay' self.twolame = 'twolame' self end |