r2mp3 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -63,9 +63,10 @@ module R2mp3
63
63
  def dump_to_wav
64
64
  puts "dumping to wav...."
65
65
  raise ConverterError::InputFileRequired unless File.exists?(@input_file)
66
- %Q{mplayer #{wav_options} #{@input_file}}
66
+ %{#{R2mp3::Tools::MPLAYER} #{wav_options} #{@input_file}}
67
67
  end
68
68
 
69
+ #TODO: More DRY
69
70
  def wav_options
70
71
  # todo:
71
72
  opts = {
@@ -88,11 +89,11 @@ module R2mp3
88
89
  input = @wav_output
89
90
  options = mp3_options
90
91
  @output_path = @output_file
91
- %Q{lame #{input} #{@output_file} #{options}}
92
+ %{#{R2mp3::Tools::LAME} #{input} #{@output_file} #{options}}
92
93
  end
93
94
 
94
95
  #it just works, and shouldn't be here exactly.
95
- #To do: move to lame
96
+ #To do: MORE DRY
96
97
  def mp3_options
97
98
  # (j)oint, (s)imple, (f)orce, (d)dual-mono, (m)ono
98
99
  mode = {
@@ -19,21 +19,18 @@ module R2mp3
19
19
  def info
20
20
  return nil unless @type.eql?(:mp3)
21
21
  Mp3Info.open(@file) do |info|
22
- @header = info.header
23
- @channel_mode = info.channel_mode
24
- @length = info.length
25
- #@tag1 = info.tag1
26
- @tag = info.tag
27
- @vbr = info.vbr
28
- @layer = info.layer
29
- @samplerate = info.samplerate
30
- @mpeg_version = info.mpeg_version
31
- #@tag1_parsed = info.tag1_parsed
32
- @filename = info.filename
33
- @bitrate = info.bitrate
22
+ mp3_data.each { |d| eval("@#{d} = info.#{d}") }
34
23
  end
35
24
  self
36
25
  end
37
26
 
27
+ def mp3_data
28
+ [
29
+ :header, :channel_mode, :length, :tag1,
30
+ :tag, :vbr, :layer, :samplerate, :mpeg_version,
31
+ :filename, :bitrate
32
+ ]
33
+ end
34
+
38
35
  end
39
36
  end
@@ -1,7 +1,7 @@
1
1
  module R2mp3
2
2
  module Tools
3
+ constant :lame => 'lame'
3
4
  class Lame
4
- constant :lame => 'lame'
5
5
  include Loader::InstanceMethods
6
6
  def parse(result)
7
7
  return true unless result[/(\*)+/].nil?
@@ -2,13 +2,13 @@ module R2mp3
2
2
  module Tools
3
3
  class Loader
4
4
 
5
- def self.load(recipe, options = {})
5
+ def self.load(recipe)
6
6
  name = recipe.split.first
7
- tool = "R2mp3::Tools::#{name.classify}".constantize.send(:new, recipe, options)
7
+ tool = "R2mp3::Tools::#{name.classify}".constantize.send(:new, recipe)
8
8
  end
9
9
 
10
10
  module InstanceMethods
11
- def initialize(recipe, options = {})
11
+ def initialize(recipe)
12
12
  @recipe = recipe
13
13
  end
14
14
 
@@ -1,7 +1,7 @@
1
1
  module R2mp3
2
2
  module Tools
3
+ constant :mplayer => 'mplayer'
3
4
  class Mplayer
4
- constant :mplayer => 'mplayer'
5
5
  include Loader::InstanceMethods
6
6
 
7
7
  def parse(result)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r2mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warachet Samtalee
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-11 00:00:00 +07:00
12
+ date: 2008-09-18 00:00:00 +07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -44,7 +44,7 @@ files:
44
44
  - lib/r2mp3/tools/mplayer.rb
45
45
  - lib/r2mp3/version.rb
46
46
  - lib/r2mp3.rb
47
- - lib/README.txt
47
+ - README.txt
48
48
  has_rdoc: false
49
49
  homepage: http://ziddik.blogspot.com
50
50
  post_install_message: