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)/
- 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, :lame, :mp3val, :sox, :soxi, :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
143 144 145 |
# File 'lib/audio_monster/configuration.rb', line 143 def self.extended(base) base.reset! end |
.included(base) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/audio_monster/configuration.rb', line 47 def self.included(base) def ||= {} end def (opts) = 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
81 82 83 84 85 86 87 |
# File 'lib/audio_monster/configuration.rb', line 81 def apply_configuration(opts={}) = AudioMonster..merge(opts) self. = VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
#bin(name) ⇒ Object
124 125 126 |
# File 'lib/audio_monster/configuration.rb', line 124 def bin(name) "#{bin_dir}#{name}" end |
#check_binaries ⇒ Object
94 95 96 |
# File 'lib/audio_monster/configuration.rb', line 94 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
90 91 92 |
# File 'lib/audio_monster/configuration.rb', line 90 def configure yield self end |
#current_options ⇒ Object
49 50 51 |
# File 'lib/audio_monster/configuration.rb', line 49 def ||= {} end |
#current_options=(opts) ⇒ Object
53 54 55 |
# File 'lib/audio_monster/configuration.rb', line 53 def (opts) = opts end |
#find_executable(bin) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/audio_monster/configuration.rb', line 98 def find_executable(bin) which = File.which(bin) if which puts " #{bin}: #{which}" else puts "X #{bin}: MISSING" end end |
#options ⇒ Object
75 76 77 78 79 |
# File 'lib/audio_monster/configuration.rb', line 75 def = {} VALID_OPTIONS_KEYS.each { |k| [k] = send(k) } end |
#reset! ⇒ Object
Reset configuration options to their defaults
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/audio_monster/configuration.rb', line 108 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 |