alacit 0.0.1 → 0.0.2
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/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +64 -0
- data/Rakefile +11 -0
- data/alacit.gemspec +21 -0
- data/bin/alacit +2 -157
- data/lib/alacit.rb +106 -0
- data/lib/application.rb +90 -0
- data/lib/version.rb +3 -0
- data/test/converter_test.rb +117 -0
- data/test/fixtures/test.flac +0 -0
- data/test/fixtures/test.m4a +0 -0
- data/test/fixtures/test2.wav +0 -0
- metadata +22 -6
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Russell Brooks
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
## AlacIt
|
2
|
+
|
3
|
+
Apple Lossless conversion utility. Converts FLAC and WAV audio files to Apple Lossless (ALAC) files in M4A format for importation into iTunes, iPhones, iPads, and iPods.
|
4
|
+
|
5
|
+
* Very Fast. An entire album in 10 to 15 seconds.
|
6
|
+
* No quality loss
|
7
|
+
* Basic metadata survives: Song, Artist, etc.
|
8
|
+
* Converts entire directories, single files, or any combination thereof.
|
9
|
+
* Puts converted files in same dir as source.
|
10
|
+
|
11
|
+
### Install
|
12
|
+
|
13
|
+
Ensure you have Ruby 1.9.2 installed, and [FFmpeg](http://ffmpeg.org/), then type:
|
14
|
+
|
15
|
+
gem install alacit
|
16
|
+
|
17
|
+
### Usage
|
18
|
+
|
19
|
+
#### Single Files
|
20
|
+
|
21
|
+
Convert a single file. This outputs a file called `song.m4v` in same directory.
|
22
|
+
|
23
|
+
alacit song.flac
|
24
|
+
|
25
|
+
Convert several individual files:
|
26
|
+
|
27
|
+
alacit song.flac song2.flac
|
28
|
+
|
29
|
+
#### Entire Directories
|
30
|
+
|
31
|
+
Convert a single directory. This finds and converts all `.flac` and `.wav` files in that directory:
|
32
|
+
|
33
|
+
alacit ~/Music/Artist/Album
|
34
|
+
|
35
|
+
Convert everything in current directory:
|
36
|
+
|
37
|
+
alacit .
|
38
|
+
|
39
|
+
Convert many different directories in batch:
|
40
|
+
|
41
|
+
alacit ~/Music/Artist/Album ~/Music/Artist/Album2 ~/Music/Artist2/Album
|
42
|
+
|
43
|
+
#### Combinations of Files and Directories
|
44
|
+
|
45
|
+
alacit ~/Music/Artist/Album song3.flac ~/Downloads/Bjork
|
46
|
+
|
47
|
+
#### Force Overwrites
|
48
|
+
|
49
|
+
AlacIt won't overwrite existing files by default. If you need to, just force overwrites with the `--force` option:
|
50
|
+
|
51
|
+
alacit --force song.flac
|
52
|
+
alacit -f song.flac
|
53
|
+
|
54
|
+
### Dependencies
|
55
|
+
|
56
|
+
* **Ruby 1.9.2**
|
57
|
+
* **FFmpeg 0.8.0+** - As far back as 0.5.0 should work too.
|
58
|
+
* **On OS X:** Get [Homebrew](http://mxcl.github.com/homebrew/) and type `brew install ffmpeg`.
|
59
|
+
* **On Linux:** `sudo apt-get install flac ffmpeg`
|
60
|
+
* **Windows:** [untested]
|
61
|
+
|
62
|
+
### Copyright
|
63
|
+
|
64
|
+
Copyright (c) 2012 [Russell Brooks](http://russbrooks.com). See LICENSE.txt for further details.
|
data/Rakefile
ADDED
data/alacit.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'version'
|
4
|
+
|
5
|
+
spec = Gem::Specification.new do |s|
|
6
|
+
s.name = 'alacit'
|
7
|
+
s.version = AlacIt::VERSION
|
8
|
+
s.author = 'Russell H. Brooks'
|
9
|
+
s.email = 'me@russbrooks.com'
|
10
|
+
s.homepage = 'http://russbrooks.com'
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.summary = 'FLAC and WAV to Apple Lossless (ALAC) batch conversion utility.'
|
13
|
+
s.description = 'Quickly convert entire directories of FLAC and WAV files to Apple Lossless (ALAC) for importation into iTunes, iPhones, iPads, and iPods.'
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
s.has_rdoc = false
|
19
|
+
s.bindir = 'bin'
|
20
|
+
s.add_development_dependency('rake')
|
21
|
+
end
|
data/bin/alacit
CHANGED
@@ -1,160 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
# by: Russell Brooks (russbrooks.com)
|
5
|
-
#
|
6
|
-
# Converts FLAC and WAV files to ALAC (Apple Lossless Audio Codec) files in
|
7
|
-
# an M4A container for importation into iTunes. Fast. No loss in quality.
|
8
|
-
# Basic metadata ports as well. Puts converted files in same dir as source.
|
9
|
-
#
|
10
|
-
# Dependency: FFmpeg 0.8.0+. But as far back as 0.5.0 should work too.
|
11
|
-
# On OS X : Get Homebrew and type `brew install ffmpeg`.
|
12
|
-
# On Linux: `sudo apt-get install flac ffmpeg`
|
13
|
-
# Windows : [untested]
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
14
4
|
|
15
|
-
require '
|
16
|
-
require 'optparse'
|
17
|
-
require 'version'
|
18
|
-
|
19
|
-
module AlacIt
|
20
|
-
class Converter
|
21
|
-
def initialize
|
22
|
-
@options = {}
|
23
|
-
@executable_name = File.split($0)[1]
|
24
|
-
@usage = "Usage: #{@executable_name} [options] dir [dir ...] [file ...]\n"
|
25
|
-
@usage += " #{@executable_name} [options] file [file ...] [dir ...]\n"
|
26
|
-
|
27
|
-
parse_args
|
28
|
-
ffmpeg_exists
|
29
|
-
|
30
|
-
convert!
|
31
|
-
end
|
32
|
-
|
33
|
-
def convert!
|
34
|
-
ARGV.each do |source|
|
35
|
-
if File.directory? source
|
36
|
-
convert_dir source
|
37
|
-
elsif File.file? source
|
38
|
-
convert_file source
|
39
|
-
else
|
40
|
-
abort "Error: #{source}: Not a file or directory."
|
41
|
-
end
|
42
|
-
end
|
43
|
-
exit $?.exitstatus
|
44
|
-
end
|
45
|
-
|
46
|
-
def convert_dir(source_dir)
|
47
|
-
source_glob = File.join(source_dir, '*.{flac,wav}')
|
48
|
-
|
49
|
-
unless Dir.glob(source_glob).empty?
|
50
|
-
Dir.glob(source_glob) do |file|
|
51
|
-
m4a_file = file.chomp(File.extname(file)) + '.m4a'
|
52
|
-
|
53
|
-
if !File.exists?(m4a_file) || @options[:force]
|
54
|
-
command = 'ffmpeg -y -i "' + file + '" -acodec alac "' + m4a_file + '"'
|
55
|
-
stdout_str, stderr_str, status = Open3.capture3(command)
|
56
|
-
|
57
|
-
if status.success?
|
58
|
-
puts "#{file}: Converted."
|
59
|
-
else
|
60
|
-
STDERR.puts "Error: #{file}: File could not be converted."
|
61
|
-
STDERR.puts stderr_str.split("\n").last
|
62
|
-
next
|
63
|
-
end
|
64
|
-
else
|
65
|
-
STDERR.puts "Error: #{m4a_file} exists."
|
66
|
-
next
|
67
|
-
end
|
68
|
-
end
|
69
|
-
else
|
70
|
-
STDERR.puts 'Error: No FLAC or WAV files found.'
|
71
|
-
return
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def convert_file(file)
|
76
|
-
if File.extname(file) =~ /(\.flac|\.wav)/i
|
77
|
-
if File.exists? file
|
78
|
-
m4a_file = file.chomp(File.extname(file)) + '.m4a'
|
79
|
-
|
80
|
-
if !File.exists?(m4a_file) || @options[:force]
|
81
|
-
command = 'ffmpeg -y -i "' + file + '" -acodec alac "' + m4a_file + '"'
|
82
|
-
stdout_str, stderr_str, status = Open3.capture3(command)
|
83
|
-
|
84
|
-
if status.success?
|
85
|
-
puts "#{file}: Converted."
|
86
|
-
else
|
87
|
-
STDERR.puts "Error: #{file}: File could not be converted."
|
88
|
-
STDERR.puts stderr_str.split("\n").last
|
89
|
-
return
|
90
|
-
end
|
91
|
-
else
|
92
|
-
STDERR.puts "Error: #{m4a_file} exists."
|
93
|
-
return
|
94
|
-
end
|
95
|
-
else
|
96
|
-
STDERR.puts "Error: #{file}: No such file."
|
97
|
-
return
|
98
|
-
end
|
99
|
-
else
|
100
|
-
STDERR.puts "Error: #{file}: Not a FLAC or WAV file."
|
101
|
-
return
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
|
107
|
-
def parse_args
|
108
|
-
@opts_parser = OptionParser.new do |opts|
|
109
|
-
opts.banner = "Converts ALAC and WAV files to Apple Lossless.\n\n"
|
110
|
-
opts.banner += @usage + "\n"
|
111
|
-
|
112
|
-
opts.on('-f', '--force', 'Overwrite output files') do |f|
|
113
|
-
@options[:force] = true
|
114
|
-
end
|
115
|
-
|
116
|
-
opts.on('-v', '--version', 'AlacIt version') do
|
117
|
-
puts 'AlacIt 0.0.1' # Can't seem to read this from lib/version
|
118
|
-
exit
|
119
|
-
end
|
120
|
-
end
|
121
|
-
@opts_parser.parse!
|
122
|
-
|
123
|
-
args_exist
|
124
|
-
end
|
125
|
-
|
126
|
-
def args_exist
|
127
|
-
if ARGV.empty?
|
128
|
-
STDERR.puts 'Error: You must supply one or more file or directory names.'
|
129
|
-
STDERR.puts
|
130
|
-
STDERR.puts @usage
|
131
|
-
exit -1
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def ffmpeg_exists
|
136
|
-
unless command? 'ffmpeg'
|
137
|
-
error = 'Error: FFmpeg executable not found.'
|
138
|
-
error += ' Install Homebrew and type `brew install ffmpeg`.' if os_is_mac?
|
139
|
-
error += ' To install, type `sudo apt-get install flac ffmpeg`.' if os_is_linux?
|
140
|
-
STDERR.puts error
|
141
|
-
exit 2
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def command?(name)
|
146
|
-
`which #{name}`
|
147
|
-
$?.success?
|
148
|
-
end
|
149
|
-
|
150
|
-
def os_is_mac?
|
151
|
-
RUBY_PLATFORM.downcase.include? 'darwin'
|
152
|
-
end
|
153
|
-
|
154
|
-
def os_is_linux?
|
155
|
-
RUBY_PLATFORM.downcase.include? 'linux'
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
c = AlacIt::Converter.new
|
5
|
+
require 'alacit'
|
data/lib/alacit.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# AlacIt
|
4
|
+
# by: Russell Brooks (russbrooks.com)
|
5
|
+
#
|
6
|
+
# Converts FLAC and WAV files to ALAC (Apple Lossless Audio Codec) files in
|
7
|
+
# an M4A container for importation into iTunes. Fast. No loss in quality.
|
8
|
+
# Basic metadata ports as well. Puts converted files in same dir as source.
|
9
|
+
#
|
10
|
+
# Dependency: FFmpeg 0.8.0+. But as far back as 0.5.0 should work too.
|
11
|
+
# On OS X : Get Homebrew and type `brew install ffmpeg`.
|
12
|
+
# On Linux: `sudo apt-get install flac ffmpeg`
|
13
|
+
# Windows : [untested]
|
14
|
+
|
15
|
+
require 'open3'
|
16
|
+
require 'version'
|
17
|
+
require 'application'
|
18
|
+
|
19
|
+
module AlacIt
|
20
|
+
class Converter < Application
|
21
|
+
@was_error = false
|
22
|
+
|
23
|
+
def convert
|
24
|
+
standard_exception_handling do
|
25
|
+
parse_args
|
26
|
+
|
27
|
+
ARGV.each do |source|
|
28
|
+
if File.directory? source
|
29
|
+
convert_dir source
|
30
|
+
elsif File.file? source
|
31
|
+
convert_file source
|
32
|
+
else
|
33
|
+
$stderr.puts "Error: #{source}: Not a file or directory."
|
34
|
+
@was_error = true
|
35
|
+
next
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
exit false if @was_error
|
40
|
+
end
|
41
|
+
|
42
|
+
def convert_dir(source_dir)
|
43
|
+
source_glob = File.join(source_dir, '*.{flac,wav}')
|
44
|
+
|
45
|
+
unless Dir.glob(source_glob).empty?
|
46
|
+
Dir.glob(source_glob) do |file|
|
47
|
+
m4a_file = file.chomp(File.extname(file)) + '.m4a'
|
48
|
+
|
49
|
+
if !File.exists?(m4a_file) || @options[:force]
|
50
|
+
command = 'ffmpeg -y -i "' + file + '" -acodec alac "' + m4a_file + '"'
|
51
|
+
stdout_str, stderr_str, status = Open3.capture3(command)
|
52
|
+
|
53
|
+
if status.success?
|
54
|
+
puts "#{file} converted."
|
55
|
+
else
|
56
|
+
$stderr.puts "Error: #{file}: File could not be converted."
|
57
|
+
$stderr.puts stderr_str.split("\n").last
|
58
|
+
next
|
59
|
+
end
|
60
|
+
else
|
61
|
+
$stderr.puts "Error: #{m4a_file} exists. Use --force option to overwrite."
|
62
|
+
next
|
63
|
+
end
|
64
|
+
end
|
65
|
+
else
|
66
|
+
$stderr.puts 'Error: No FLAC or WAV files found.'
|
67
|
+
return
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def convert_file(file)
|
72
|
+
if File.extname(file) =~ /(\.flac|\.wav)/i
|
73
|
+
if File.exists? file
|
74
|
+
m4a_file = file.chomp(File.extname(file)) + '.m4a'
|
75
|
+
|
76
|
+
if !File.exists?(m4a_file) || @options[:force]
|
77
|
+
command = 'ffmpeg -y -i "' + file + '" -acodec alac "' + m4a_file + '"'
|
78
|
+
stdout_str, stderr_str, status = Open3.capture3(command)
|
79
|
+
|
80
|
+
if status.success?
|
81
|
+
puts "#{file} converted."
|
82
|
+
else
|
83
|
+
$stderr.puts "Error: #{file}: File could not be converted."
|
84
|
+
$stderr.puts stderr_str.split("\n").last
|
85
|
+
return
|
86
|
+
end
|
87
|
+
else
|
88
|
+
$stderr.puts "Error: #{m4a_file} exists."
|
89
|
+
return
|
90
|
+
end
|
91
|
+
else
|
92
|
+
$stderr.puts "Error: #{file}: No such file."
|
93
|
+
return
|
94
|
+
end
|
95
|
+
else
|
96
|
+
$stderr.puts "Error: #{file}: Not a FLAC or WAV file."
|
97
|
+
return
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if File.basename($PROGRAM_NAME) == 'alacit'
|
104
|
+
# If statement prevents this from running when running the test suite.
|
105
|
+
AlacIt::Converter.new.convert
|
106
|
+
end
|
data/lib/application.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module AlacIt
|
4
|
+
class Application
|
5
|
+
attr_reader :name # Name of this app.
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@options = {}
|
9
|
+
standard_exception_handling do
|
10
|
+
@name = File.split($0)[1]
|
11
|
+
ffmpeg_exists
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def standard_exception_handling
|
16
|
+
begin
|
17
|
+
yield
|
18
|
+
rescue SystemExit => ex
|
19
|
+
# Exit silently with current status
|
20
|
+
raise
|
21
|
+
rescue OptionParser::InvalidOption => ex
|
22
|
+
$stderr.puts ex.message
|
23
|
+
exit(false)
|
24
|
+
rescue Exception => ex
|
25
|
+
# Exit with error message
|
26
|
+
display_error_message(ex)
|
27
|
+
exit(false)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Display the error message that caused the exception.
|
32
|
+
def display_error_message(ex)
|
33
|
+
$stderr.puts "#{name} aborted!"
|
34
|
+
$stderr.puts ex.message
|
35
|
+
$stderr.puts ex.backtrace.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_args
|
39
|
+
OptionParser.new do |opts|
|
40
|
+
opts.banner = "Converts ALAC and WAV files to Apple Lossless.\n\n"
|
41
|
+
@usage = "Usage: #{@name} [options] dir [dir ...] [file ...]\n"
|
42
|
+
@usage += " #{@name} [options] file [file ...] [dir ...]\n"
|
43
|
+
opts.banner += "#{@usage}\n"
|
44
|
+
|
45
|
+
opts.on('-f', '--force', 'Overwrite output files') do |f|
|
46
|
+
@options[:force] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-v', '--version', 'AlacIt version') do
|
50
|
+
puts 'AlacIt ' + AlacIt::VERSION
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
end.parse!
|
54
|
+
|
55
|
+
args_exist
|
56
|
+
end
|
57
|
+
|
58
|
+
def args_exist
|
59
|
+
if ARGV.empty?
|
60
|
+
$stderr.puts 'Error: You must supply one or more file or directory names.'
|
61
|
+
$stderr.puts
|
62
|
+
$stderr.puts @usage
|
63
|
+
exit -1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def ffmpeg_exists
|
68
|
+
unless command? 'ffmpeg'
|
69
|
+
error = 'Error: FFmpeg executable not found.'
|
70
|
+
error += ' Install Homebrew and type `brew install ffmpeg`.' if os_is_mac?
|
71
|
+
error += ' To install, type `sudo apt-get install flac ffmpeg`.' if os_is_linux?
|
72
|
+
$stderr.puts error
|
73
|
+
exit 2
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def command?(name)
|
78
|
+
`which #{name}`
|
79
|
+
$?.success?
|
80
|
+
end
|
81
|
+
|
82
|
+
def os_is_mac?
|
83
|
+
RUBY_PLATFORM.downcase.include? 'darwin'
|
84
|
+
end
|
85
|
+
|
86
|
+
def os_is_linux?
|
87
|
+
RUBY_PLATFORM.downcase.include? 'linux'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/version.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'alacit'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class AlacItTest < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
# Before each test.
|
9
|
+
@temp_dir = Pathname.new Dir.mktmpdir('alacit')
|
10
|
+
@app = AlacIt::Converter.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
# After each test.
|
15
|
+
@temp_dir.rmtree
|
16
|
+
@app = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_no_args
|
20
|
+
ARGV.clear
|
21
|
+
_, err = capture_io do
|
22
|
+
assert_raises(SystemExit) { @app.convert }
|
23
|
+
end
|
24
|
+
assert_match /You must supply one or more file or directory names/, err
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_nonexistant_directory
|
28
|
+
ARGV.clear
|
29
|
+
ARGV << '/bogus/dir'
|
30
|
+
_, err = capture_io do
|
31
|
+
assert_raises(SystemExit) { @app.convert }
|
32
|
+
end
|
33
|
+
assert_match /Not a file or directory/, err
|
34
|
+
ensure
|
35
|
+
ARGV.clear
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_single_flac
|
39
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
40
|
+
ARGV.clear
|
41
|
+
ARGV << File.join(@temp_dir, 'test.flac')
|
42
|
+
out, = capture_io { @app.convert }
|
43
|
+
assert_match /test\.flac converted/, out
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_single_wav
|
47
|
+
FileUtils.cp 'test/fixtures/test2.wav', @temp_dir
|
48
|
+
ARGV.clear
|
49
|
+
ARGV << File.join(@temp_dir, 'test2.wav')
|
50
|
+
out, = capture_io { @app.convert }
|
51
|
+
assert_match /test2\.wav converted/, out
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_mixed_directory
|
55
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
56
|
+
FileUtils.cp 'test/fixtures/test2.wav', @temp_dir
|
57
|
+
ARGV.clear
|
58
|
+
ARGV << @temp_dir
|
59
|
+
out, = capture_io { @app.convert }
|
60
|
+
assert_match /test\.flac converted/, out
|
61
|
+
assert_match /test2\.wav converted/, out
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_single_flac_file_exists
|
65
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
66
|
+
FileUtils.cp 'test/fixtures/test.m4a', @temp_dir
|
67
|
+
ARGV.clear
|
68
|
+
ARGV << File.join(@temp_dir, 'test.flac')
|
69
|
+
out, err = capture_io { @app.convert }
|
70
|
+
assert_match /test\.m4a exists/, err
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_single_flac_file_exists_force_overwrite
|
74
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
75
|
+
FileUtils.cp 'test/fixtures/test.m4a', @temp_dir
|
76
|
+
ARGV.clear
|
77
|
+
ARGV << '--force' << File.join(@temp_dir, 'test.flac')
|
78
|
+
out, = capture_io { @app.convert }
|
79
|
+
assert_match /test\.flac converted/, out
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_mixed_directory_file_exists
|
83
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
84
|
+
FileUtils.cp 'test/fixtures/test2.wav', @temp_dir
|
85
|
+
FileUtils.cp 'test/fixtures/test.m4a', @temp_dir
|
86
|
+
ARGV.clear
|
87
|
+
ARGV << File.join(@temp_dir)
|
88
|
+
out, err = capture_io { @app.convert }
|
89
|
+
assert_match /test\.m4a exists/, err
|
90
|
+
assert_match /test2\.wav converted/, out
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_mixed_directory_file_exists_force_overwrite
|
94
|
+
FileUtils.cp 'test/fixtures/test.flac', @temp_dir
|
95
|
+
FileUtils.cp 'test/fixtures/test2.wav', @temp_dir
|
96
|
+
FileUtils.cp 'test/fixtures/test.m4a', @temp_dir
|
97
|
+
ARGV.clear
|
98
|
+
ARGV << '--force' << File.join(@temp_dir)
|
99
|
+
out, = capture_io { @app.convert }
|
100
|
+
assert_match /test\.flac converted/, out
|
101
|
+
assert_match /test2\.wav converted/, out
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_standard_exception_handling_invalid_option
|
105
|
+
app = AlacIt::Application.new
|
106
|
+
out, err = capture_io do
|
107
|
+
e = assert_raises SystemExit do
|
108
|
+
app.standard_exception_handling do
|
109
|
+
raise OptionParser::InvalidOption, 'foo'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
assert_equal 1, e.status
|
113
|
+
end
|
114
|
+
assert_empty out
|
115
|
+
assert_equal "invalid option: foo\n", err
|
116
|
+
end
|
117
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alacit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70249714818540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70249714818540
|
25
25
|
description: Quickly convert entire directories of FLAC and WAV files to Apple Lossless
|
26
26
|
(ALAC) for importation into iTunes, iPhones, iPads, and iPods.
|
27
27
|
email: me@russbrooks.com
|
@@ -30,14 +30,26 @@ executables:
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.markdown
|
37
|
+
- Rakefile
|
38
|
+
- alacit.gemspec
|
33
39
|
- bin/alacit
|
40
|
+
- lib/alacit.rb
|
41
|
+
- lib/application.rb
|
42
|
+
- lib/version.rb
|
43
|
+
- test/converter_test.rb
|
44
|
+
- test/fixtures/test.flac
|
45
|
+
- test/fixtures/test.m4a
|
46
|
+
- test/fixtures/test2.wav
|
34
47
|
homepage: http://russbrooks.com
|
35
48
|
licenses: []
|
36
49
|
post_install_message:
|
37
50
|
rdoc_options: []
|
38
51
|
require_paths:
|
39
52
|
- lib
|
40
|
-
- lib
|
41
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
54
|
none: false
|
43
55
|
requirements:
|
@@ -56,4 +68,8 @@ rubygems_version: 1.8.11
|
|
56
68
|
signing_key:
|
57
69
|
specification_version: 3
|
58
70
|
summary: FLAC and WAV to Apple Lossless (ALAC) batch conversion utility.
|
59
|
-
test_files:
|
71
|
+
test_files:
|
72
|
+
- test/converter_test.rb
|
73
|
+
- test/fixtures/test.flac
|
74
|
+
- test/fixtures/test.m4a
|
75
|
+
- test/fixtures/test2.wav
|