flac2mp3 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.8 2008-07-21
2
+
3
+ * 1 enhancement:
4
+ * Can now take encoding options for lame (defaults to --preset standard)
5
+
1
6
  == 0.2.7 2008-06-27
2
7
 
3
8
  * 1 enhancement:
data/bin/flac2mp3 CHANGED
@@ -31,6 +31,8 @@ BANNER
31
31
  "Delete the original file after conversion") { |delete| OPTIONS[:delete] = delete }
32
32
  opts.on('-s', '--silent',
33
33
  "Don't show progress") { |silent| OPTIONS[:silent] = silent }
34
+ opts.on('-e', '--encoding=ENCODING', String,
35
+ "Set lame encoding options", "Default: --preset standard") { |encoding| OPTIONS[:encoding] = encoding }
34
36
  opts.on('-h', '--help',
35
37
  'Show this help message.') { puts opts; exit }
36
38
  opts.parse!(ARGV)
data/lib/flac2mp3.rb CHANGED
@@ -13,8 +13,10 @@ module Flac2mp3
13
13
 
14
14
  commands = { :flac => 'flac', :mp3 => 'lame' }
15
15
  commands.each { |k, v| v << ' --silent' } if options[:silent]
16
+ encoding = options[:encoding]
17
+ encoding = default_encoding if encoding.to_s.strip.empty?
16
18
 
17
- system "#{commands[:flac]} --stdout --decode #{filename.safequote} | #{commands[:mp3]} --preset standard - #{out_filename.safequote}"
19
+ system "#{commands[:flac]} --stdout --decode #{filename.safequote} | #{commands[:mp3]} #{encoding} - #{out_filename.safequote}"
18
20
 
19
21
  mp3data(out_filename, flacdata(filename))
20
22
 
@@ -100,5 +102,12 @@ module Flac2mp3
100
102
  end
101
103
  mp3_tags
102
104
  end
105
+
106
+
107
+ private
108
+
109
+ def default_encoding
110
+ '--preset standard'
111
+ end
103
112
  end
104
113
  end
@@ -2,7 +2,7 @@ module Flac2mp3 #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -76,4 +76,19 @@ describe 'flac2mp3 command' do
76
76
  Flac2mp3.expects(:convert).with(anything, has_entry(:silent => false))
77
77
  run_command('blah')
78
78
  end
79
+
80
+ it 'should pass on the encoding option specified on the command line' do
81
+ Flac2mp3.expects(:convert).with(anything, has_entry(:encoding => '--preset fast standard'))
82
+ run_command('blah', '--encoding', '--preset fast standard')
83
+ end
84
+
85
+ it 'should pass on the encoding option specified in shorthand on the command line' do
86
+ Flac2mp3.expects(:convert).with(anything, has_entry(:encoding => '--preset fast standard'))
87
+ run_command('blah', '-e', '--preset fast standard')
88
+ end
89
+
90
+ it 'should pass on no encoding option if none specified on the command line' do
91
+ Flac2mp3.expects(:convert).with(anything, Not(has_key(:encoding)))
92
+ run_command('blah')
93
+ end
79
94
  end
@@ -91,7 +91,7 @@ describe Flac2mp3, 'when converting and given a filename belonging to a regular
91
91
  end
92
92
 
93
93
  it 'should accept an option to delete the flac' do
94
- lambda { Flac2mp3.convert('blah.flac', :delete => true) }.should_not raise_error(ArgumentError)
94
+ lambda { Flac2mp3.convert(@filename, :delete => true) }.should_not raise_error(ArgumentError)
95
95
  end
96
96
 
97
97
  it 'should delete the original file if given a true value for the option' do
@@ -110,7 +110,7 @@ describe Flac2mp3, 'when converting and given a filename belonging to a regular
110
110
  end
111
111
 
112
112
  it 'should accept an option to run silently' do
113
- lambda { Flac2mp3.convert('blah.flac', :silent => true) }.should_not raise_error(ArgumentError)
113
+ lambda { Flac2mp3.convert(@filename, :silent => true) }.should_not raise_error(ArgumentError)
114
114
  end
115
115
 
116
116
  it 'should tell the system commands to be silent if given a true value for the option' do
@@ -127,6 +127,30 @@ describe Flac2mp3, 'when converting and given a filename belonging to a regular
127
127
  Flac2mp3.expects(:system).with("flac --stdout --decode #{@filename.safequote} | lame --preset standard - #{@output_filename.safequote}")
128
128
  Flac2mp3.convert(@filename)
129
129
  end
130
+
131
+ it 'should accept an option for encoding options' do
132
+ lambda { Flac2mp3.convert(@filename, :encoding => '--preset fast standard') }.should_not raise_error(ArgumentError)
133
+ end
134
+
135
+ it 'should use the encoding options if given' do
136
+ Flac2mp3.expects(:system).with("flac --stdout --decode #{@filename.safequote} | lame --vbr-new -V2 -h - #{@output_filename.safequote}")
137
+ Flac2mp3.convert(@filename, :encoding => '--vbr-new -V2 -h')
138
+ end
139
+
140
+ it 'should default the encoding to --preset standard if no encoding options given' do
141
+ Flac2mp3.expects(:system).with("flac --stdout --decode #{@filename.safequote} | lame --preset standard - #{@output_filename.safequote}")
142
+ Flac2mp3.convert(@filename)
143
+ end
144
+
145
+ it 'should default the encoding to --preset standard if nil encoding options given' do
146
+ Flac2mp3.expects(:system).with("flac --stdout --decode #{@filename.safequote} | lame --preset standard - #{@output_filename.safequote}")
147
+ Flac2mp3.convert(@filename, :encoding => nil)
148
+ end
149
+
150
+ it 'should default the encoding to --preset standard if blank encoding options given' do
151
+ Flac2mp3.expects(:system).with("flac --stdout --decode #{@filename.safequote} | lame --preset standard - #{@output_filename.safequote}")
152
+ Flac2mp3.convert(@filename, :encoding => ' ')
153
+ end
130
154
  end
131
155
 
132
156
  describe Flac2mp3, 'when converting and given a filename not belonging to a regular file' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flac2mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yossef Mendelssohn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-27 00:00:00 -05:00
12
+ date: 2008-07-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.5.1
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.7.0
44
+ version:
35
45
  description: description of gem
36
46
  email: ymendel@pobox.com
37
47
  executables: