flac2mp3 0.2.5 → 0.2.6
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 +6 -1
- data/bin/flac2mp3 +6 -2
- data/lib/flac2mp3.rb +3 -1
- data/lib/flac2mp3/version.rb +1 -1
- data/spec/flac2mp3_command_spec.rb +25 -1
- data/spec/flac2mp3_spec.rb +21 -0
- metadata +5 -3
data/History.txt
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
== 0.2.6 2008-06-25
|
|
2
|
+
|
|
3
|
+
* 1 enhancement:
|
|
4
|
+
* Can now optionally delete the original FLAC file after conversion.
|
|
5
|
+
|
|
1
6
|
== 0.2.5 2008-05-12
|
|
2
7
|
|
|
3
8
|
* 1 bug fix:
|
|
4
|
-
* Composer now actually carried over from FLAC to
|
|
9
|
+
* Composer now actually carried over from FLAC to MP3 tags, not just thought to be.
|
|
5
10
|
|
|
6
11
|
* 3 enhancements:
|
|
7
12
|
* Compilation flag carried over.
|
data/bin/flac2mp3
CHANGED
|
@@ -11,10 +11,11 @@ end
|
|
|
11
11
|
|
|
12
12
|
require 'optparse'
|
|
13
13
|
require 'flac2mp3'
|
|
14
|
+
require 'flac2mp3/version'
|
|
14
15
|
|
|
15
16
|
# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
|
|
16
17
|
|
|
17
|
-
OPTIONS = {}
|
|
18
|
+
OPTIONS = { :delete => false }
|
|
18
19
|
MANDATORY_OPTIONS = %w[]
|
|
19
20
|
|
|
20
21
|
parser = OptionParser.new do |opts|
|
|
@@ -26,6 +27,9 @@ BANNER
|
|
|
26
27
|
opts.separator ''
|
|
27
28
|
opts.on('-v', '--version',
|
|
28
29
|
"Show the #{File.basename($0)} version number and exit") { puts "flac2mp3 #{Flac2mp3::VERSION::STRING}"; exit }
|
|
30
|
+
opts.on('-d', '--[no-]delete',
|
|
31
|
+
"Delete the original file after conversion") { |delete| OPTIONS[:delete] = delete }
|
|
32
|
+
|
|
29
33
|
opts.on('-h', '--help',
|
|
30
34
|
'Show this help message.') { puts opts; exit }
|
|
31
35
|
opts.parse!(ARGV)
|
|
@@ -43,4 +47,4 @@ unless filename
|
|
|
43
47
|
exit
|
|
44
48
|
end
|
|
45
49
|
|
|
46
|
-
Flac2mp3.convert(filename.dup)
|
|
50
|
+
Flac2mp3.convert(filename.dup, OPTIONS[:delete])
|
data/lib/flac2mp3.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'mp3info'
|
|
|
5
5
|
|
|
6
6
|
module Flac2mp3
|
|
7
7
|
class << self
|
|
8
|
-
def convert(filename)
|
|
8
|
+
def convert(filename, delete_flac = false)
|
|
9
9
|
raise TypeError, "'#{filename}' is not a file" unless FileTest.file?(filename)
|
|
10
10
|
filename.extend(Flac2mp3::StringExtensions)
|
|
11
11
|
out_filename = output_filename(filename)
|
|
@@ -14,6 +14,8 @@ module Flac2mp3
|
|
|
14
14
|
system "flac -c -d #{filename.safequote} | lame --preset standard - #{out_filename.safequote}"
|
|
15
15
|
|
|
16
16
|
mp3data(out_filename, flacdata(filename))
|
|
17
|
+
|
|
18
|
+
File.delete(filename) if delete_flac
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def output_filename(filename)
|
data/lib/flac2mp3/version.rb
CHANGED
|
@@ -16,6 +16,10 @@ describe 'flac2mp3 command' do
|
|
|
16
16
|
|
|
17
17
|
before :each do
|
|
18
18
|
Flac2mp3.stubs(:convert)
|
|
19
|
+
|
|
20
|
+
[:ARGV, :OPTIONS, :MANDATORY_OPTIONS].each do |const|
|
|
21
|
+
Object.send(:remove_const, const) if Object.const_defined?(const)
|
|
22
|
+
end
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
it 'should exist' do
|
|
@@ -28,7 +32,7 @@ describe 'flac2mp3 command' do
|
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
it 'should pass the filename to Flac2mp3 for conversion' do
|
|
31
|
-
Flac2mp3.expects(:convert).with('blah')
|
|
35
|
+
Flac2mp3.expects(:convert).with('blah', anything)
|
|
32
36
|
run_command('blah')
|
|
33
37
|
end
|
|
34
38
|
|
|
@@ -37,4 +41,24 @@ describe 'flac2mp3 command' do
|
|
|
37
41
|
filename.expects(:dup).returns(filename)
|
|
38
42
|
run_command(filename)
|
|
39
43
|
end
|
|
44
|
+
|
|
45
|
+
it 'should pass on a true flac-deletion option if specified on the command line (using --delete)' do
|
|
46
|
+
Flac2mp3.expects(:convert).with(anything, true)
|
|
47
|
+
run_command('blah', '--delete')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should pass on a false flac-deletion option if specified on the command line (using --no-delete)' do
|
|
51
|
+
Flac2mp3.expects(:convert).with(anything, false)
|
|
52
|
+
run_command('blah', '--no-delete')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should pass on a true flac-deletion option if specified on the command line (using -d)' do
|
|
56
|
+
Flac2mp3.expects(:convert).with(anything, true)
|
|
57
|
+
run_command('blah', '-d')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should pass on a false flac-deletion option if nothing specified on the command line' do
|
|
61
|
+
Flac2mp3.expects(:convert).with(anything, false)
|
|
62
|
+
run_command('blah')
|
|
63
|
+
end
|
|
40
64
|
end
|
data/spec/flac2mp3_spec.rb
CHANGED
|
@@ -27,6 +27,7 @@ describe Flac2mp3, 'when converting' do
|
|
|
27
27
|
Flac2mp3.stubs(:system)
|
|
28
28
|
Flac2mp3.stubs(:flacdata)
|
|
29
29
|
Flac2mp3.stubs(:mp3data)
|
|
30
|
+
File.stubs(:delete)
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
it 'should require a filename' do
|
|
@@ -48,6 +49,7 @@ describe Flac2mp3, 'when converting and given a filename belonging to a regular
|
|
|
48
49
|
before :each do
|
|
49
50
|
@filename = 'blah.flac'
|
|
50
51
|
FileTest.stubs(:file?).with(@filename).returns(true)
|
|
52
|
+
File.stubs(:delete)
|
|
51
53
|
@output_filename = 'blah.mp3'
|
|
52
54
|
Flac2mp3.stubs(:output_filename).with(@filename).returns(@output_filename)
|
|
53
55
|
Flac2mp3.stubs(:system)
|
|
@@ -90,6 +92,25 @@ describe Flac2mp3, 'when converting and given a filename belonging to a regular
|
|
|
90
92
|
Flac2mp3.expects(:mp3data).with(@output_filename, @flacdata)
|
|
91
93
|
Flac2mp3.convert(@filename)
|
|
92
94
|
end
|
|
95
|
+
|
|
96
|
+
it 'should accept an option to delete the flac' do
|
|
97
|
+
lambda { Flac2mp3.convert('blah.flac', true) }.should_not raise_error(ArgumentError)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'should delete the original file if given a true value for the option' do
|
|
101
|
+
File.expects(:delete).with(@filename)
|
|
102
|
+
Flac2mp3.convert(@filename, true)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should not delete the original file if given a false value for the option' do
|
|
106
|
+
File.expects(:delete).never
|
|
107
|
+
Flac2mp3.convert(@filename, false)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'should not delete the original file by default' do
|
|
111
|
+
File.expects(:delete).never
|
|
112
|
+
Flac2mp3.convert(@filename)
|
|
113
|
+
end
|
|
93
114
|
end
|
|
94
115
|
|
|
95
116
|
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.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yossef Mendelssohn
|
|
@@ -9,11 +9,12 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-
|
|
12
|
+
date: 2008-06-25 00:00:00 -05:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: flacinfo-rb
|
|
17
|
+
type: :runtime
|
|
17
18
|
version_requirement:
|
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
|
19
20
|
requirements:
|
|
@@ -23,6 +24,7 @@ dependencies:
|
|
|
23
24
|
version:
|
|
24
25
|
- !ruby/object:Gem::Dependency
|
|
25
26
|
name: ruby-mp3info
|
|
27
|
+
type: :runtime
|
|
26
28
|
version_requirement:
|
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
|
28
30
|
requirements:
|
|
@@ -89,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
89
91
|
requirements: []
|
|
90
92
|
|
|
91
93
|
rubyforge_project: yomendel
|
|
92
|
-
rubygems_version: 1.
|
|
94
|
+
rubygems_version: 1.2.0
|
|
93
95
|
signing_key:
|
|
94
96
|
specification_version: 2
|
|
95
97
|
summary: description of gem
|