taglib-ruby 0.4.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +9 -0
- data/CHANGES.md +53 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +29 -0
- data/docs/default/fulldoc/html/css/common.css +1 -0
- data/docs/taglib/base.rb +202 -0
- data/docs/taglib/id3v1.rb +5 -0
- data/docs/taglib/id3v2.rb +444 -0
- data/docs/taglib/mpeg.rb +120 -0
- data/docs/taglib/ogg.rb +77 -0
- data/docs/taglib/vorbis.rb +62 -0
- data/ext/extconf_common.rb +29 -0
- data/ext/taglib_base/extconf.rb +4 -0
- data/ext/taglib_base/includes.i +115 -0
- data/ext/taglib_base/taglib_base.i +139 -0
- data/ext/taglib_base/taglib_base_wrap.cxx +5153 -0
- data/ext/taglib_id3v1/extconf.rb +4 -0
- data/ext/taglib_id3v1/taglib_id3v1.i +11 -0
- data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +3110 -0
- data/ext/taglib_id3v2/extconf.rb +4 -0
- data/ext/taglib_id3v2/relativevolumeframe.i +35 -0
- data/ext/taglib_id3v2/taglib_id3v2.i +112 -0
- data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +9033 -0
- data/ext/taglib_mpeg/extconf.rb +4 -0
- data/ext/taglib_mpeg/taglib_mpeg.i +75 -0
- data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +4726 -0
- data/ext/taglib_ogg/extconf.rb +4 -0
- data/ext/taglib_ogg/taglib_ogg.i +36 -0
- data/ext/taglib_ogg/taglib_ogg_wrap.cxx +3631 -0
- data/ext/taglib_vorbis/extconf.rb +4 -0
- data/ext/taglib_vorbis/taglib_vorbis.i +48 -0
- data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +3083 -0
- data/ext/valgrind-suppressions.txt +170 -0
- data/ext/win.cmake +5 -0
- data/lib/libtag.dll +0 -0
- data/lib/taglib.rb +14 -0
- data/lib/taglib/base.rb +19 -0
- data/lib/taglib/id3v1.rb +1 -0
- data/lib/taglib/id3v2.rb +20 -0
- data/lib/taglib/mpeg.rb +7 -0
- data/lib/taglib/ogg.rb +1 -0
- data/lib/taglib/version.rb +10 -0
- data/lib/taglib/vorbis.rb +7 -0
- data/lib/taglib_base.so +0 -0
- data/lib/taglib_id3v1.so +0 -0
- data/lib/taglib_id3v2.so +0 -0
- data/lib/taglib_mpeg.so +0 -0
- data/lib/taglib_ogg.so +0 -0
- data/lib/taglib_vorbis.so +0 -0
- data/taglib-ruby.gemspec +122 -0
- data/tasks/docs_coverage.rake +26 -0
- data/tasks/ext.rake +81 -0
- data/tasks/gemspec_check.rake +19 -0
- data/tasks/swig.rake +43 -0
- data/test/data/Makefile +15 -0
- data/test/data/add-relative-volume.cpp +40 -0
- data/test/data/crash.mp3 +0 -0
- data/test/data/globe_east_540.jpg +0 -0
- data/test/data/id3v1-create.cpp +31 -0
- data/test/data/id3v1.mp3 +0 -0
- data/test/data/relative-volume.mp3 +0 -0
- data/test/data/sample.mp3 +0 -0
- data/test/data/unicode.mp3 +0 -0
- data/test/data/vorbis-create.cpp +42 -0
- data/test/data/vorbis.oga +0 -0
- data/test/fileref_open_test.rb +32 -0
- data/test/fileref_properties_test.rb +21 -0
- data/test/fileref_write_test.rb +62 -0
- data/test/helper.rb +10 -0
- data/test/id3v1_tag_test.rb +36 -0
- data/test/id3v2_frames_test.rb +115 -0
- data/test/id3v2_memory_test.rb +87 -0
- data/test/id3v2_relative_volume_test.rb +62 -0
- data/test/id3v2_tag_test.rb +59 -0
- data/test/id3v2_unicode_test.rb +47 -0
- data/test/id3v2_write_test.rb +100 -0
- data/test/mpeg_file_test.rb +76 -0
- data/test/tag_test.rb +21 -0
- data/test/unicode_filename_test.rb +29 -0
- data/test/vorbis_file_test.rb +54 -0
- data/test/vorbis_tag_test.rb +79 -0
- metadata +191 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
desc "Checks file list in .gemspec against files tracked in Git"
|
2
|
+
task :gemspec_check do |t|
|
3
|
+
exclude = ['.gitignore', '.travis.yml']
|
4
|
+
git_files = `git ls-files`.split("\n") - exclude
|
5
|
+
gemspec_files = $gemspec.files
|
6
|
+
|
7
|
+
only_in_gemspec = gemspec_files - git_files
|
8
|
+
only_in_git = git_files - gemspec_files
|
9
|
+
|
10
|
+
unless only_in_gemspec.empty?
|
11
|
+
puts "In gemspec but not in git:"
|
12
|
+
puts only_in_gemspec
|
13
|
+
end
|
14
|
+
|
15
|
+
unless only_in_git.empty?
|
16
|
+
puts "In git but not in gemspec:"
|
17
|
+
puts only_in_git
|
18
|
+
end
|
19
|
+
end
|
data/tasks/swig.rake
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Tasks for generating SWIG wrappers in ext
|
2
|
+
|
3
|
+
def run_swig(mod)
|
4
|
+
swig = `which swig`.chomp
|
5
|
+
if swig.empty?
|
6
|
+
swig = `which swig2.0`.chomp
|
7
|
+
end
|
8
|
+
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/include #{mod}.i"
|
9
|
+
end
|
10
|
+
|
11
|
+
task :swig =>
|
12
|
+
['ext/taglib_base/taglib_base_wrap.cxx',
|
13
|
+
'ext/taglib_mpeg/taglib_mpeg_wrap.cxx',
|
14
|
+
'ext/taglib_id3v1/taglib_id3v1_wrap.cxx',
|
15
|
+
'ext/taglib_id3v2/taglib_id3v2_wrap.cxx',
|
16
|
+
'ext/taglib_ogg/taglib_ogg_wrap.cxx',
|
17
|
+
'ext/taglib_vorbis/taglib_vorbis_wrap.cxx']
|
18
|
+
|
19
|
+
base_dependencies = ['ext/taglib_base/taglib_base.i', 'ext/taglib_base/includes.i']
|
20
|
+
|
21
|
+
file 'ext/taglib_base/taglib_base_wrap.cxx' => base_dependencies do
|
22
|
+
run_swig('taglib_base')
|
23
|
+
end
|
24
|
+
|
25
|
+
file 'ext/taglib_mpeg/taglib_mpeg_wrap.cxx' => ['ext/taglib_mpeg/taglib_mpeg.i'] + base_dependencies do
|
26
|
+
run_swig('taglib_mpeg')
|
27
|
+
end
|
28
|
+
|
29
|
+
file 'ext/taglib_id3v1/taglib_id3v1_wrap.cxx' => ['ext/taglib_id3v1/taglib_id3v1.i'] + base_dependencies do
|
30
|
+
run_swig('taglib_id3v1')
|
31
|
+
end
|
32
|
+
|
33
|
+
file 'ext/taglib_id3v2/taglib_id3v2_wrap.cxx' => ['ext/taglib_id3v2/taglib_id3v2.i'] + base_dependencies do
|
34
|
+
run_swig('taglib_id3v2')
|
35
|
+
end
|
36
|
+
|
37
|
+
file 'ext/taglib_ogg/taglib_ogg_wrap.cxx' => ['ext/taglib_ogg/taglib_ogg.i'] + base_dependencies do
|
38
|
+
run_swig('taglib_ogg')
|
39
|
+
end
|
40
|
+
|
41
|
+
file 'ext/taglib_vorbis/taglib_vorbis_wrap.cxx' => ['ext/taglib_vorbis/taglib_vorbis.i'] + base_dependencies do
|
42
|
+
run_swig('taglib_vorbis')
|
43
|
+
end
|
data/test/data/Makefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
.PHONY: all clean
|
2
|
+
|
3
|
+
all:: add-relative-volume id3v1-create vorbis-create
|
4
|
+
|
5
|
+
add-relative-volume: add-relative-volume.cpp
|
6
|
+
g++ -o $@ $< -ltag -I/usr/include/taglib
|
7
|
+
|
8
|
+
id3v1-create: id3v1-create.cpp
|
9
|
+
g++ -o $@ $< -ltag -I/usr/include/taglib
|
10
|
+
|
11
|
+
vorbis-create: vorbis-create.cpp
|
12
|
+
g++ -o $@ $< -ltag -I/usr/include/taglib
|
13
|
+
|
14
|
+
clean::
|
15
|
+
-rm add-relative-volume id3v1-create
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#include <taglib/taglib.h>
|
5
|
+
#include <taglib/mpegfile.h>
|
6
|
+
#include <taglib/id3v2tag.h>
|
7
|
+
#include <taglib/relativevolumeframe.h>
|
8
|
+
|
9
|
+
using namespace TagLib;
|
10
|
+
|
11
|
+
int main(int argc, char **argv) {
|
12
|
+
if (argc != 2) {
|
13
|
+
std::cout << "usage: " << argv[0] << " file.mp3" << std::endl;
|
14
|
+
exit(1);
|
15
|
+
}
|
16
|
+
char *filename = argv[1];
|
17
|
+
|
18
|
+
MPEG::File file(filename);
|
19
|
+
ID3v2::Tag *tag = file.ID3v2Tag(true);
|
20
|
+
|
21
|
+
ID3v2::RelativeVolumeFrame *rv = new ID3v2::RelativeVolumeFrame();
|
22
|
+
|
23
|
+
rv->setVolumeAdjustmentIndex(512);
|
24
|
+
rv->setVolumeAdjustmentIndex(1024, ID3v2::RelativeVolumeFrame::Subwoofer);
|
25
|
+
|
26
|
+
ID3v2::RelativeVolumeFrame::PeakVolume pv1;
|
27
|
+
pv1.bitsRepresentingPeak = 8;
|
28
|
+
pv1.peakVolume = "A"; // 0x41, 0b01000001
|
29
|
+
rv->setPeakVolume(pv1);
|
30
|
+
|
31
|
+
ID3v2::RelativeVolumeFrame::PeakVolume pv2;
|
32
|
+
pv2.bitsRepresentingPeak = 4;
|
33
|
+
pv2.peakVolume = "?"; // 0x3F, 0b00111111
|
34
|
+
rv->setPeakVolume(pv2, ID3v2::RelativeVolumeFrame::Subwoofer);
|
35
|
+
|
36
|
+
tag->addFrame(rv);
|
37
|
+
file.save();
|
38
|
+
}
|
39
|
+
|
40
|
+
// vim: set filetype=cpp sw=2 ts=2 expandtab:
|
data/test/data/crash.mp3
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#include <taglib/taglib.h>
|
5
|
+
#include <taglib/mpegfile.h>
|
6
|
+
#include <taglib/id3v1tag.h>
|
7
|
+
|
8
|
+
using namespace TagLib;
|
9
|
+
|
10
|
+
int main(int argc, char **argv) {
|
11
|
+
if (argc != 2) {
|
12
|
+
std::cout << "usage: " << argv[0] << " file.mp3" << std::endl;
|
13
|
+
exit(1);
|
14
|
+
}
|
15
|
+
char *filename = argv[1];
|
16
|
+
|
17
|
+
MPEG::File file(filename);
|
18
|
+
ID3v1::Tag *tag = file.ID3v1Tag(true);
|
19
|
+
|
20
|
+
tag->setTitle("Title");
|
21
|
+
tag->setArtist("Artist");
|
22
|
+
tag->setAlbum("Album");
|
23
|
+
tag->setComment("Comment");
|
24
|
+
tag->setGenre("Pop");
|
25
|
+
tag->setYear(2011);
|
26
|
+
tag->setTrack(7);
|
27
|
+
|
28
|
+
file.save(MPEG::File::ID3v1);
|
29
|
+
}
|
30
|
+
|
31
|
+
// vim: set filetype=cpp sw=2 ts=2 expandtab:
|
data/test/data/id3v1.mp3
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#include <taglib/taglib.h>
|
5
|
+
#include <taglib/vorbisfile.h>
|
6
|
+
|
7
|
+
using namespace TagLib;
|
8
|
+
|
9
|
+
int main(int argc, char **argv) {
|
10
|
+
if (argc != 2) {
|
11
|
+
std::cout << "usage: " << argv[0] << " file.mp3" << std::endl;
|
12
|
+
exit(1);
|
13
|
+
}
|
14
|
+
char *filename = argv[1];
|
15
|
+
|
16
|
+
Vorbis::File file(filename);
|
17
|
+
Ogg::XiphComment *tag = file.tag();
|
18
|
+
|
19
|
+
tag->setTitle("Title");
|
20
|
+
tag->setArtist("Artist");
|
21
|
+
tag->setAlbum("Album");
|
22
|
+
tag->setComment("Comment");
|
23
|
+
tag->setGenre("Pop");
|
24
|
+
tag->setYear(2011);
|
25
|
+
tag->setTrack(7);
|
26
|
+
|
27
|
+
tag->addField("VERSION", "original");
|
28
|
+
tag->addField("PERFORMER", "Performer");
|
29
|
+
tag->addField("COPYRIGHT", "2011 Me, myself and I");
|
30
|
+
tag->addField("LICENSE", "Any Use Permitted");
|
31
|
+
tag->addField("ORGANIZATION", "Organization");
|
32
|
+
tag->addField("DESCRIPTION", "Test file");
|
33
|
+
tag->addField("LOCATION", "Earth");
|
34
|
+
tag->addField("CONTACT", "Contact");
|
35
|
+
|
36
|
+
tag->addField("MULTIPLE", "A");
|
37
|
+
tag->addField("MULTIPLE", "B", false);
|
38
|
+
|
39
|
+
file.save();
|
40
|
+
}
|
41
|
+
|
42
|
+
// vim: set filetype=cpp sw=2 ts=2 expandtab:
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class FileRefOpenTest < Test::Unit::TestCase
|
4
|
+
context "TagLib::FileRef.open" do
|
5
|
+
should "return result" do
|
6
|
+
title = TagLib::FileRef.open("test/data/vorbis.oga", false) do |file|
|
7
|
+
tag = file.tag
|
8
|
+
assert_not_nil tag
|
9
|
+
tag.title
|
10
|
+
end
|
11
|
+
assert_equal "Title", title
|
12
|
+
end
|
13
|
+
|
14
|
+
should "close even with exception" do
|
15
|
+
f = nil
|
16
|
+
begin
|
17
|
+
TagLib::FileRef.open("test/data/vorbis.oga", false) do |file|
|
18
|
+
f = file
|
19
|
+
raise NotImplementedError
|
20
|
+
end
|
21
|
+
flunk("Should have raised NotImplementedError.")
|
22
|
+
rescue NotImplementedError
|
23
|
+
begin
|
24
|
+
f.tag
|
25
|
+
flunk("Should have raised ObjectPreviouslyDeleted.")
|
26
|
+
rescue => e
|
27
|
+
assert_equal "ObjectPreviouslyDeleted", e.class.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestFileRefProperties < Test::Unit::TestCase
|
4
|
+
context "The crash.mp3 file audio properties" do
|
5
|
+
setup do
|
6
|
+
@fileref = TagLib::FileRef.new("test/data/crash.mp3", true, TagLib::AudioProperties::Average)
|
7
|
+
@properties = @fileref.audio_properties
|
8
|
+
end
|
9
|
+
|
10
|
+
should "exist" do
|
11
|
+
assert_not_nil @properties
|
12
|
+
end
|
13
|
+
|
14
|
+
should "contain basic information" do
|
15
|
+
assert_equal 2, @properties.length
|
16
|
+
assert_equal 157, @properties.bitrate
|
17
|
+
assert_equal 44100, @properties.sample_rate
|
18
|
+
assert_equal 2, @properties.channels
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestFileRefWrite < Test::Unit::TestCase
|
6
|
+
|
7
|
+
SAMPLE_FILE = "test/data/sample.mp3"
|
8
|
+
OUTPUT_FILE = "test/data/output.mp3"
|
9
|
+
|
10
|
+
context "TagLib::FileRef" do
|
11
|
+
setup do
|
12
|
+
FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
|
13
|
+
@file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
|
14
|
+
end
|
15
|
+
|
16
|
+
should "be able to save the title" do
|
17
|
+
tag = @file.tag
|
18
|
+
assert_not_nil tag
|
19
|
+
tag.title = "New Title"
|
20
|
+
success = @file.save
|
21
|
+
assert success
|
22
|
+
@file.close
|
23
|
+
@file = nil
|
24
|
+
|
25
|
+
written_file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
|
26
|
+
assert_equal "New Title", written_file.tag.title
|
27
|
+
written_file.close
|
28
|
+
end
|
29
|
+
|
30
|
+
teardown do
|
31
|
+
if @file
|
32
|
+
@file.close
|
33
|
+
@file = nil
|
34
|
+
end
|
35
|
+
FileUtils.rm OUTPUT_FILE
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "TagLib::FileRef.open" do
|
40
|
+
setup do
|
41
|
+
FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
|
42
|
+
end
|
43
|
+
|
44
|
+
should "be able to save file" do
|
45
|
+
TagLib::MPEG::File.open(OUTPUT_FILE, false) do |file|
|
46
|
+
tag = file.tag
|
47
|
+
tag.title = "New Title"
|
48
|
+
file.save
|
49
|
+
end
|
50
|
+
|
51
|
+
title = TagLib::MPEG::File.open(OUTPUT_FILE, false) do |file|
|
52
|
+
tag = file.tag
|
53
|
+
tag.title
|
54
|
+
end
|
55
|
+
assert_equal "New Title", title
|
56
|
+
end
|
57
|
+
|
58
|
+
teardown do
|
59
|
+
FileUtils.rm OUTPUT_FILE
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestID3v1Tag < Test::Unit::TestCase
|
4
|
+
context "The id3v1.mp3 file" do
|
5
|
+
setup do
|
6
|
+
read_properties = false
|
7
|
+
@file = TagLib::MPEG::File.new("test/data/id3v1.mp3", read_properties)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "have an ID3v1 tag" do
|
11
|
+
assert_not_nil @file.id3v1_tag
|
12
|
+
end
|
13
|
+
|
14
|
+
context "ID3v1 tag" do
|
15
|
+
setup do
|
16
|
+
@tag = @file.id3v1_tag
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have basic properties" do
|
20
|
+
assert_equal 'Title', @tag.title
|
21
|
+
assert_equal 'Artist', @tag.artist
|
22
|
+
assert_equal 'Album', @tag.album
|
23
|
+
assert_equal 'Comment', @tag.comment
|
24
|
+
assert_equal 'Pop', @tag.genre
|
25
|
+
assert_equal 2011, @tag.year
|
26
|
+
assert_equal 7, @tag.track
|
27
|
+
assert_equal false, @tag.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
teardown do
|
32
|
+
@file.close
|
33
|
+
@file = nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestID3v2Frames < Test::Unit::TestCase
|
4
|
+
context "The sample.mp3 file's frames" do
|
5
|
+
setup do
|
6
|
+
read_properties = false
|
7
|
+
# It's important that file is an instance variable, otherwise the
|
8
|
+
# tag would get garbage collected along with the file, even if tag
|
9
|
+
# itself would still be reachable. The reason is because
|
10
|
+
# TagLib::MPEG::File owns the TagLib::ID3v2::Tag and automatically
|
11
|
+
# deletes it in its destructor.
|
12
|
+
@file = TagLib::MPEG::File.new("test/data/sample.mp3", read_properties)
|
13
|
+
picture_file = File.open("test/data/globe_east_540.jpg", "rb") do |f|
|
14
|
+
@picture_data = f.read
|
15
|
+
end
|
16
|
+
@tag = @file.id3v2_tag
|
17
|
+
@frames = @tag.frame_list
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be complete" do
|
21
|
+
assert_not_nil @frames
|
22
|
+
assert_equal 11, @frames.size
|
23
|
+
frame = @frames.first
|
24
|
+
assert_equal "Dummy Title", frame.to_string
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be enumerable" do
|
28
|
+
ids = @frames.collect{ |frame| frame.frame_id }
|
29
|
+
assert_equal ["TIT2", "TPE1", "TALB", "TRCK", "TDRC",
|
30
|
+
"COMM", "COMM", "TCON", "TXXX", "COMM", "APIC"], ids
|
31
|
+
end
|
32
|
+
|
33
|
+
should "be automatically converted" do
|
34
|
+
apic = @tag.frame_list('APIC').first
|
35
|
+
comm = @tag.frame_list('COMM').first
|
36
|
+
tit2 = @tag.frame_list('TIT2').first
|
37
|
+
txxx = @tag.frame_list('TXXX').first
|
38
|
+
assert_equal TagLib::ID3v2::AttachedPictureFrame, apic.class
|
39
|
+
assert_equal TagLib::ID3v2::CommentsFrame, comm.class
|
40
|
+
assert_equal TagLib::ID3v2::TextIdentificationFrame, tit2.class
|
41
|
+
assert_equal TagLib::ID3v2::UserTextIdentificationFrame, txxx.class
|
42
|
+
end
|
43
|
+
|
44
|
+
should "be removable" do
|
45
|
+
assert_equal 11, @tag.frame_list.size
|
46
|
+
tit2 = @tag.frame_list('TIT2').first
|
47
|
+
@tag.remove_frame(tit2)
|
48
|
+
assert_equal 10, @tag.frame_list.size
|
49
|
+
begin
|
50
|
+
tit2.to_string
|
51
|
+
flunk("Should have raised ObjectPreviouslyDeleted.")
|
52
|
+
rescue => e
|
53
|
+
assert_equal "ObjectPreviouslyDeleted", e.class.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
should "be removable by ID" do
|
58
|
+
frames = @tag.frame_list
|
59
|
+
@tag.remove_frames('COMM')
|
60
|
+
tit2 = frames.find{ |f| f.frame_id == 'TIT2' }
|
61
|
+
# Other frames should still be accessible
|
62
|
+
assert_equal "Dummy Title", tit2.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
context "APIC frame" do
|
66
|
+
setup do
|
67
|
+
@apic = @tag.frame_list('APIC').first
|
68
|
+
end
|
69
|
+
|
70
|
+
should "have a type" do
|
71
|
+
assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
|
72
|
+
end
|
73
|
+
|
74
|
+
should "have a description" do
|
75
|
+
assert_equal "Blue Marble", @apic.description
|
76
|
+
end
|
77
|
+
|
78
|
+
should "have a mime type" do
|
79
|
+
assert_equal "image/jpeg", @apic.mime_type
|
80
|
+
end
|
81
|
+
|
82
|
+
should "have picture bytes" do
|
83
|
+
assert_equal 61649, @apic.picture.size
|
84
|
+
if HAVE_ENCODING
|
85
|
+
assert_equal @picture_data.encoding, @apic.picture.encoding
|
86
|
+
end
|
87
|
+
assert_equal @picture_data, @apic.picture
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "TXXX frame" do
|
92
|
+
setup do
|
93
|
+
@txxx_frame = @tag.frame_list('TXXX').first
|
94
|
+
end
|
95
|
+
|
96
|
+
should "exist" do
|
97
|
+
assert_not_nil @txxx_frame
|
98
|
+
end
|
99
|
+
|
100
|
+
should "have to_s" do
|
101
|
+
expected = "[MusicBrainz Album Id] MusicBrainz Album Id 992dc19a-5631-40f5-b252-fbfedbc328a9"
|
102
|
+
assert_equal expected, @txxx_frame.to_string
|
103
|
+
end
|
104
|
+
|
105
|
+
should "have field_list" do
|
106
|
+
assert_equal ["MusicBrainz Album Id", "992dc19a-5631-40f5-b252-fbfedbc328a9"], @txxx_frame.field_list
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
teardown do
|
111
|
+
@file.close
|
112
|
+
@file = nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|