taglib-ruby 0.7.1 → 1.0.0
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.
- checksums.yaml +5 -5
- data/CHANGES.md +7 -0
- data/README.md +25 -10
- data/Rakefile +11 -1
- data/docs/taglib/aiff.rb +35 -3
- data/docs/taglib/base.rb +8 -1
- data/docs/taglib/flac.rb +60 -4
- data/docs/taglib/id3v1.rb +29 -0
- data/docs/taglib/id3v2.rb +1 -1
- data/docs/taglib/mp4.rb +124 -13
- data/docs/taglib/mpeg.rb +30 -1
- data/docs/taglib/ogg.rb +47 -5
- data/docs/taglib/vorbis.rb +1 -1
- data/docs/taglib/wav.rb +56 -3
- data/ext/extconf_common.rb +9 -2
- data/ext/taglib_aiff/taglib_aiff.i +16 -0
- data/ext/taglib_aiff/taglib_aiff_wrap.cxx +228 -58
- data/ext/taglib_base/includes.i +4 -4
- data/ext/taglib_base/taglib_base.i +24 -2
- data/ext/taglib_base/taglib_base_wrap.cxx +76 -51
- data/ext/taglib_flac/taglib_flac.i +14 -18
- data/ext/taglib_flac/taglib_flac_wrap.cxx +341 -799
- data/ext/taglib_flac_picture/extconf.rb +4 -0
- data/ext/taglib_flac_picture/includes.i +15 -0
- data/ext/taglib_flac_picture/taglib_flac_picture.i +15 -0
- data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +3087 -0
- data/ext/taglib_id3v1/taglib_id3v1.i +19 -0
- data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +241 -58
- data/ext/taglib_id3v2/taglib_id3v2.i +52 -1
- data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +152 -155
- data/ext/taglib_mp4/taglib_mp4.i +100 -19
- data/ext/taglib_mp4/taglib_mp4_wrap.cxx +939 -148
- data/ext/taglib_mpeg/taglib_mpeg.i +11 -16
- data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +522 -208
- data/ext/taglib_ogg/taglib_ogg.i +11 -0
- data/ext/taglib_ogg/taglib_ogg_wrap.cxx +328 -57
- data/ext/taglib_vorbis/taglib_vorbis.i +8 -0
- data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +53 -22
- data/ext/taglib_wav/taglib_wav.i +24 -0
- data/ext/taglib_wav/taglib_wav_wrap.cxx +543 -198
- data/lib/taglib/mp4.rb +2 -1
- data/lib/taglib/version.rb +3 -3
- data/lib/taglib/wav.rb +4 -0
- data/taglib-ruby.gemspec +15 -9
- data/tasks/ext.rake +36 -15
- data/tasks/swig.rake +26 -2
- data/test/aiff_examples_test.rb +1 -1
- data/test/aiff_file_test.rb +12 -3
- data/test/data/vorbis-create.cpp +20 -1
- data/test/data/vorbis.oga +0 -0
- data/test/fileref_properties_test.rb +1 -1
- data/test/flac_file_test.rb +45 -30
- data/test/id3v1_genres_test.rb +23 -0
- data/test/id3v1_tag_test.rb +1 -0
- data/test/id3v2_tag_test.rb +6 -6
- data/test/id3v2_write_test.rb +10 -13
- data/test/mp4_file_test.rb +33 -4
- data/test/mp4_file_write_test.rb +5 -5
- data/test/mp4_items_test.rb +83 -29
- data/test/mpeg_file_test.rb +120 -7
- data/test/vorbis_file_test.rb +2 -2
- data/test/vorbis_tag_test.rb +61 -7
- data/test/wav_examples_test.rb +1 -1
- data/test/wav_file_test.rb +53 -41
- data/test/wav_file_write_test.rb +25 -0
- metadata +19 -9
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestVorbisTag < Test::Unit::TestCase
|
4
|
+
context "TagLib::ID3v1" do
|
5
|
+
should "list genres" do
|
6
|
+
assert_equal "Jazz", TagLib::ID3v1::genre_list[8]
|
7
|
+
end
|
8
|
+
|
9
|
+
should "map genres to their index" do
|
10
|
+
assert_equal 8, TagLib::ID3v1::genre_map["Jazz"]
|
11
|
+
end
|
12
|
+
|
13
|
+
should "support to query the value of a genre" do
|
14
|
+
assert_equal "Jazz", TagLib::ID3v1::genre(8)
|
15
|
+
assert_equal "", TagLib::ID3v1::genre(255)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "support to query the index of a genre" do
|
19
|
+
assert_equal 8, TagLib::ID3v1::genre_index("Jazz")
|
20
|
+
assert_equal 255, TagLib::ID3v1::genre_index("Unknown")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/id3v1_tag_test.rb
CHANGED
@@ -22,6 +22,7 @@ class TestID3v1Tag < Test::Unit::TestCase
|
|
22
22
|
assert_equal 'Album', @tag.album
|
23
23
|
assert_equal 'Comment', @tag.comment
|
24
24
|
assert_equal 'Pop', @tag.genre
|
25
|
+
assert_equal 13, @tag.genre_number
|
25
26
|
assert_equal 2011, @tag.year
|
26
27
|
assert_equal 7, @tag.track
|
27
28
|
assert_equal false, @tag.empty?
|
data/test/id3v2_tag_test.rb
CHANGED
@@ -43,12 +43,12 @@ class TestID3v2Tag < Test::Unit::TestCase
|
|
43
43
|
assert @tag.empty?
|
44
44
|
end
|
45
45
|
|
46
|
-
should "have
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
should "have empty string attributes" do
|
47
|
+
assert_equal "", @tag.title
|
48
|
+
assert_equal "", @tag.artist
|
49
|
+
assert_equal "", @tag.album
|
50
|
+
assert_equal "", @tag.comment
|
51
|
+
assert_equal "", @tag.genre
|
52
52
|
end
|
53
53
|
|
54
54
|
should "have 0 for numeric attributes" do
|
data/test/id3v2_write_test.rb
CHANGED
@@ -54,21 +54,18 @@ class TestID3v2Write < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
should "be able to save ID3v2.3
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@file.close
|
63
|
-
@file = nil
|
57
|
+
should "be able to save ID3v2.3" do
|
58
|
+
success = @file.save(TagLib::MPEG::File::ID3v2, true, 3)
|
59
|
+
assert_equal true, success
|
60
|
+
@file.close
|
61
|
+
@file = nil
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
# 3 stands for v2.3
|
69
|
-
s = "ID3" + 3.chr + 0.chr
|
70
|
-
assert_equal s, header
|
63
|
+
header = File.open(OUTPUT_FILE, 'rb') do |f|
|
64
|
+
f.read(5)
|
71
65
|
end
|
66
|
+
# 3 stands for v2.3
|
67
|
+
s = "ID3" + 3.chr + 0.chr
|
68
|
+
assert_equal s, header
|
72
69
|
end
|
73
70
|
|
74
71
|
should "be able to set fields to nil" do
|
data/test/mp4_file_test.rb
CHANGED
@@ -7,6 +7,11 @@ class MP4FileTest < Test::Unit::TestCase
|
|
7
7
|
@tag = @file.tag
|
8
8
|
end
|
9
9
|
|
10
|
+
should "have an MP4 tag" do
|
11
|
+
assert @file.mp4_tag?
|
12
|
+
refute_nil @tag
|
13
|
+
end
|
14
|
+
|
10
15
|
should "contain basic tag information" do
|
11
16
|
assert_equal "Title", @tag.title
|
12
17
|
assert_equal "Artist", @tag.artist
|
@@ -15,9 +20,33 @@ class MP4FileTest < Test::Unit::TestCase
|
|
15
20
|
assert_equal "Pop", @tag.genre
|
16
21
|
assert_equal 2011, @tag.year
|
17
22
|
assert_equal 7, @tag.track
|
23
|
+
|
18
24
|
assert_equal false, @tag.empty?
|
19
25
|
end
|
20
26
|
|
27
|
+
should "support testing for the presence of items" do
|
28
|
+
refute @tag.contains "unknown"
|
29
|
+
assert @tag.contains "trkn"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "support accessing items" do
|
33
|
+
refute @tag["unkn"].valid?
|
34
|
+
|
35
|
+
assert @tag["trkn"].valid?
|
36
|
+
assert_equal 7, @tag.track
|
37
|
+
end
|
38
|
+
|
39
|
+
should "support editing items" do
|
40
|
+
@tag["trkn"] = TagLib::MP4::Item.from_int(1)
|
41
|
+
assert_equal 1, @tag.track
|
42
|
+
end
|
43
|
+
|
44
|
+
should "support removing items" do
|
45
|
+
assert @tag.contains "trkn"
|
46
|
+
@tag.remove_item("trkn")
|
47
|
+
refute @tag.contains "trkn"
|
48
|
+
end
|
49
|
+
|
21
50
|
context "audio properties" do
|
22
51
|
setup do
|
23
52
|
@properties = @file.audio_properties
|
@@ -28,8 +57,8 @@ class MP4FileTest < Test::Unit::TestCase
|
|
28
57
|
end
|
29
58
|
|
30
59
|
should "contain basic information" do
|
31
|
-
assert_equal 1, @properties.
|
32
|
-
assert_equal
|
60
|
+
assert_equal 1, @properties.length_in_seconds
|
61
|
+
assert_equal 55, @properties.bitrate
|
33
62
|
assert_equal 44100, @properties.sample_rate
|
34
63
|
# The test file is mono, this appears to be a TagLib bug
|
35
64
|
assert_equal 2, @properties.channels
|
@@ -37,8 +66,8 @@ class MP4FileTest < Test::Unit::TestCase
|
|
37
66
|
|
38
67
|
should "contain mp4-specific information" do
|
39
68
|
assert_equal 16, @properties.bits_per_sample
|
40
|
-
|
41
|
-
|
69
|
+
assert_equal false, @properties.encrypted?
|
70
|
+
assert_equal TagLib::MP4::Properties::AAC, @properties.codec
|
42
71
|
end
|
43
72
|
end
|
44
73
|
|
data/test/mp4_file_write_test.rb
CHANGED
@@ -34,22 +34,22 @@ class MP4FileWriteTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
should "be able to add and save new cover art" do
|
37
|
-
|
38
|
-
cover_art_list =
|
37
|
+
item_map = @file.tag.item_map
|
38
|
+
cover_art_list = item_map['covr'].to_cover_art_list
|
39
39
|
assert_equal 1, cover_art_list.size
|
40
40
|
|
41
41
|
data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
|
42
42
|
new_cover_art = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, data)
|
43
43
|
|
44
44
|
cover_art_list << new_cover_art
|
45
|
-
|
46
|
-
assert_equal 2,
|
45
|
+
item_map.insert('covr', TagLib::MP4::Item.from_cover_art_list(cover_art_list))
|
46
|
+
assert_equal 2, item_map['covr'].to_cover_art_list.size
|
47
47
|
|
48
48
|
success = @file.save
|
49
49
|
assert success
|
50
50
|
|
51
51
|
reloaded do |file|
|
52
|
-
written_cover_art = file.tag.
|
52
|
+
written_cover_art = file.tag.item_map['covr'].to_cover_art_list.last
|
53
53
|
assert_equal TagLib::MP4::CoverArt::JPEG, written_cover_art.format
|
54
54
|
assert_equal data, written_cover_art.data
|
55
55
|
end
|
data/test/mp4_items_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.join(File.dirname(__FILE__), 'helper')
|
3
|
+
require 'set'
|
3
4
|
|
4
5
|
class MP4ItemsTest < Test::Unit::TestCase
|
5
6
|
ITUNES_LEADER = "\xC2\xA9"
|
@@ -8,44 +9,44 @@ class MP4ItemsTest < Test::Unit::TestCase
|
|
8
9
|
setup do
|
9
10
|
@file = TagLib::MP4::File.new("test/data/mp4.m4a")
|
10
11
|
@tag = @file.tag
|
11
|
-
@
|
12
|
+
@item_map = @file.tag.item_map
|
12
13
|
@item_keys = [
|
13
|
-
"
|
14
|
+
"covr", "#{ITUNES_LEADER}nam", "#{ITUNES_LEADER}ART", "#{ITUNES_LEADER}alb",
|
14
15
|
"#{ITUNES_LEADER}cmt", "#{ITUNES_LEADER}gen", "#{ITUNES_LEADER}day",
|
15
16
|
"trkn", "#{ITUNES_LEADER}too", "#{ITUNES_LEADER}cpy"
|
16
17
|
]
|
17
18
|
end
|
18
19
|
|
19
|
-
context "
|
20
|
+
context "item_map" do
|
20
21
|
should "exist" do
|
21
|
-
assert_not_nil @
|
22
|
+
assert_not_nil @item_map
|
22
23
|
end
|
23
24
|
|
24
25
|
should "not be empty" do
|
25
|
-
assert_equal false, @
|
26
|
+
assert_equal false, @item_map.empty?
|
26
27
|
end
|
27
28
|
|
28
29
|
should "contain 10 items" do
|
29
|
-
assert_equal @item_keys.count, @
|
30
|
+
assert_equal @item_keys.count, @item_map.size
|
30
31
|
end
|
31
32
|
|
32
33
|
should "have keys" do
|
33
|
-
assert_equal true, @
|
34
|
-
assert_equal true, @
|
35
|
-
assert_equal true, @
|
36
|
-
assert_equal false, @
|
34
|
+
assert_equal true, @item_map.contains("trkn")
|
35
|
+
assert_equal true, @item_map.has_key?("#{ITUNES_LEADER}too")
|
36
|
+
assert_equal true, @item_map.include?("#{ITUNES_LEADER}cpy")
|
37
|
+
assert_equal false, @item_map.include?("none such key")
|
37
38
|
end
|
38
39
|
|
39
40
|
should "look up keys" do
|
40
|
-
assert_nil @
|
41
|
-
assert_equal ["Title"], @
|
41
|
+
assert_nil @item_map["none such key"]
|
42
|
+
assert_equal ["Title"], @item_map["#{ITUNES_LEADER}nam"].to_string_list
|
42
43
|
end
|
43
44
|
|
44
45
|
should "be clearable" do
|
45
|
-
assert_equal 10, @
|
46
|
-
comment = @
|
47
|
-
@
|
48
|
-
assert_equal true, @
|
46
|
+
assert_equal 10, @item_map.size
|
47
|
+
comment = @item_map["#{ITUNES_LEADER}cmt"]
|
48
|
+
@item_map.clear
|
49
|
+
assert_equal true, @item_map.empty?
|
49
50
|
begin
|
50
51
|
comment.to_string_list
|
51
52
|
flunk("Should have raised ObjectPreviouslyDeleted.")
|
@@ -54,23 +55,29 @@ class MP4ItemsTest < Test::Unit::TestCase
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
should "be
|
58
|
-
array = @
|
58
|
+
should "be convertible to an array" do
|
59
|
+
array = @item_map.to_a
|
59
60
|
assert_equal 10, array.count
|
60
61
|
array.each do |object|
|
61
62
|
assert_equal Array, object.class
|
62
63
|
assert_equal 2, object.count
|
63
64
|
assert_equal String, object.first.class
|
64
65
|
assert_equal TagLib::MP4::Item, object.last.class
|
66
|
+
assert_includes @item_keys, object.first
|
65
67
|
end
|
66
68
|
end
|
69
|
+
|
70
|
+
should "be convertible to a hash" do
|
71
|
+
hsh = @item_map.to_h
|
72
|
+
assert_equal Set.new(hsh.keys), Set.new(@item_keys)
|
73
|
+
end
|
67
74
|
end
|
68
75
|
|
69
76
|
should "be removable" do
|
70
|
-
assert_equal 10, @
|
71
|
-
title = @
|
72
|
-
@
|
73
|
-
assert_equal 9, @
|
77
|
+
assert_equal 10, @item_map.size
|
78
|
+
title = @item_map["#{ITUNES_LEADER}nam"]
|
79
|
+
@item_map.erase("#{ITUNES_LEADER}nam")
|
80
|
+
assert_equal 9, @item_map.size
|
74
81
|
begin
|
75
82
|
title.to_string_list
|
76
83
|
flunk("Should have raised ObjectPreviouslyDeleted.")
|
@@ -79,18 +86,47 @@ class MP4ItemsTest < Test::Unit::TestCase
|
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
89
|
+
should "reflect edition of items from the tag" do
|
90
|
+
assert @tag.contains "trkn"
|
91
|
+
track = @item_map["trkn"]
|
92
|
+
|
93
|
+
@tag["trkn"] = TagLib::MP4::Item.from_int(1)
|
94
|
+
|
95
|
+
begin
|
96
|
+
track.to_int_pair[0]
|
97
|
+
flunk("Should have raised ObjectPreviouslyDeleted.")
|
98
|
+
rescue => e
|
99
|
+
assert_equal "ObjectPreviouslyDeleted", e.class.to_s
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
should "reflect removal of items from the tag" do
|
104
|
+
assert @tag.contains "trkn"
|
105
|
+
track = @item_map["trkn"]
|
106
|
+
|
107
|
+
@tag.remove_item("trkn")
|
108
|
+
refute @item_map.contains "trkn"
|
109
|
+
|
110
|
+
begin
|
111
|
+
track.to_int_pair[0]
|
112
|
+
flunk("Should have raised ObjectPreviouslyDeleted.")
|
113
|
+
rescue => e
|
114
|
+
assert_equal "ObjectPreviouslyDeleted", e.class.to_s
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
82
118
|
context "inserting items" do
|
83
119
|
should "insert a new item" do
|
84
120
|
new_title = TagLib::MP4::Item.from_string_list(['new title'])
|
85
|
-
@
|
121
|
+
@item_map.insert("#{ITUNES_LEADER}nam", new_title)
|
86
122
|
new_title = nil
|
87
123
|
GC.start
|
88
|
-
assert_equal ['new title'], @
|
124
|
+
assert_equal ['new title'], @item_map["#{ITUNES_LEADER}nam"].to_string_list
|
89
125
|
end
|
90
126
|
|
91
127
|
should "unlink items that get replaced" do
|
92
|
-
title = @
|
93
|
-
@
|
128
|
+
title = @item_map["#{ITUNES_LEADER}nam"]
|
129
|
+
@item_map.insert("#{ITUNES_LEADER}nam", TagLib::MP4::Item.from_int(1))
|
94
130
|
begin
|
95
131
|
title.to_string_list
|
96
132
|
flunk("Should have raised ObjectPreviouslyDeleted.")
|
@@ -101,16 +137,34 @@ class MP4ItemsTest < Test::Unit::TestCase
|
|
101
137
|
end
|
102
138
|
|
103
139
|
context "TagLib::MP4::Item" do
|
140
|
+
should "be creatable from a boolean" do
|
141
|
+
item = TagLib::MP4::Item.from_bool(false)
|
142
|
+
assert_equal TagLib::MP4::Item, item.class
|
143
|
+
assert_equal false, item.to_bool
|
144
|
+
end
|
145
|
+
|
146
|
+
should "be creatable from a byte" do
|
147
|
+
item = TagLib::MP4::Item.from_byte(123)
|
148
|
+
assert_equal TagLib::MP4::Item, item.class
|
149
|
+
assert_equal 123, item.to_byte
|
150
|
+
end
|
151
|
+
|
152
|
+
should "be creatable from an unsigned int" do
|
153
|
+
item = TagLib::MP4::Item.from_int(12346)
|
154
|
+
assert_equal TagLib::MP4::Item, item.class
|
155
|
+
assert_equal 12346, item.to_uint
|
156
|
+
end
|
157
|
+
|
104
158
|
should "be creatable from an int" do
|
105
159
|
item = TagLib::MP4::Item.from_int(-42)
|
106
160
|
assert_equal TagLib::MP4::Item, item.class
|
107
161
|
assert_equal -42, item.to_int
|
108
162
|
end
|
109
163
|
|
110
|
-
should "be creatable from a
|
111
|
-
item = TagLib::MP4::Item.
|
164
|
+
should "be creatable from a long long" do
|
165
|
+
item = TagLib::MP4::Item.from_long_long(1234567890)
|
112
166
|
assert_equal TagLib::MP4::Item, item.class
|
113
|
-
assert_equal
|
167
|
+
assert_equal 1234567890, item.to_long_long
|
114
168
|
end
|
115
169
|
|
116
170
|
context ".from_int_pair" do
|
data/test/mpeg_file_test.rb
CHANGED
@@ -11,12 +11,7 @@ class TestMPEGFile < Test::Unit::TestCase
|
|
11
11
|
tag = @file.tag
|
12
12
|
assert_not_nil tag
|
13
13
|
assert_equal TagLib::Tag, tag.class
|
14
|
-
|
15
|
-
|
16
|
-
should "have an ID3v2 tag" do
|
17
|
-
tag = @file.id3v2_tag(false)
|
18
|
-
assert_not_nil tag
|
19
|
-
assert_equal TagLib::ID3v2::Tag, tag.class
|
14
|
+
assert tag.empty?
|
20
15
|
end
|
21
16
|
|
22
17
|
context "audio properties" do
|
@@ -29,7 +24,8 @@ class TestMPEGFile < Test::Unit::TestCase
|
|
29
24
|
end
|
30
25
|
|
31
26
|
should "contain information" do
|
32
|
-
assert_equal 2, @properties.
|
27
|
+
assert_equal 2, @properties.length_in_seconds
|
28
|
+
assert_equal 2299, @properties.length_in_milliseconds
|
33
29
|
assert_equal 157, @properties.bitrate
|
34
30
|
assert_equal 44100, @properties.sample_rate
|
35
31
|
assert_equal 2, @properties.channels
|
@@ -54,10 +50,127 @@ class TestMPEGFile < Test::Unit::TestCase
|
|
54
50
|
assert @xing_header.valid?
|
55
51
|
assert_equal 88, @xing_header.total_frames
|
56
52
|
assert_equal 45140, @xing_header.total_size
|
53
|
+
assert_equal TagLib::MPEG::XingHeader::Xing, @xing_header.type
|
57
54
|
end
|
58
55
|
end
|
59
56
|
end
|
60
57
|
|
58
|
+
should "have no tag" do
|
59
|
+
refute @file.id3v1_tag?
|
60
|
+
refute @file.id3v2_tag?
|
61
|
+
refute @file.ape_tag?
|
62
|
+
end
|
63
|
+
|
64
|
+
teardown do
|
65
|
+
@file.close
|
66
|
+
@file = nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "The id3v1.mp3 file" do
|
71
|
+
setup do
|
72
|
+
read_properties = true
|
73
|
+
@file = TagLib::MPEG::File.new("test/data/id3v1.mp3", read_properties)
|
74
|
+
end
|
75
|
+
|
76
|
+
should "have a basic tag" do
|
77
|
+
tag = @file.tag
|
78
|
+
assert_not_nil tag
|
79
|
+
assert_equal TagLib::Tag, tag.class
|
80
|
+
refute tag.empty?
|
81
|
+
end
|
82
|
+
|
83
|
+
context "audio properties" do
|
84
|
+
setup do
|
85
|
+
@properties = @file.audio_properties
|
86
|
+
end
|
87
|
+
|
88
|
+
should "be MPEG audio properties" do
|
89
|
+
assert_equal TagLib::MPEG::Properties, @properties.class
|
90
|
+
end
|
91
|
+
|
92
|
+
should "contain information" do
|
93
|
+
assert_equal 0, @properties.length_in_seconds
|
94
|
+
assert_equal 261, @properties.length_in_milliseconds
|
95
|
+
assert_equal 141, @properties.bitrate
|
96
|
+
assert_equal 44100, @properties.sample_rate
|
97
|
+
assert_equal 2, @properties.channels
|
98
|
+
assert_equal TagLib::MPEG::Header::Version1, @properties.version
|
99
|
+
assert_equal 3, @properties.layer
|
100
|
+
assert_equal false, @properties.protection_enabled
|
101
|
+
assert_equal TagLib::MPEG::Header::JointStereo, @properties.channel_mode
|
102
|
+
assert_equal false, @properties.copyrighted?
|
103
|
+
assert_equal true, @properties.original?
|
104
|
+
end
|
105
|
+
|
106
|
+
context "Xing header" do
|
107
|
+
setup do
|
108
|
+
@xing_header = @properties.xing_header
|
109
|
+
end
|
110
|
+
|
111
|
+
should "exist" do
|
112
|
+
assert_not_nil @xing_header
|
113
|
+
end
|
114
|
+
|
115
|
+
should "contain information" do
|
116
|
+
assert @xing_header.valid?
|
117
|
+
assert_equal 10, @xing_header.total_frames
|
118
|
+
assert_equal 4596, @xing_header.total_size
|
119
|
+
assert_equal TagLib::MPEG::XingHeader::Xing, @xing_header.type
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "tag" do
|
125
|
+
setup do
|
126
|
+
@tag = @file.tag
|
127
|
+
end
|
128
|
+
|
129
|
+
should "exist" do
|
130
|
+
refute_nil @tag
|
131
|
+
assert_equal TagLib::Tag, @tag.class
|
132
|
+
end
|
133
|
+
|
134
|
+
should "have basic properties" do
|
135
|
+
refute @tag.empty?
|
136
|
+
|
137
|
+
assert_equal 'Title', @tag.title
|
138
|
+
assert_equal 'Artist', @tag.artist
|
139
|
+
assert_equal 'Album', @tag.album
|
140
|
+
assert_equal 'Comment', @tag.comment
|
141
|
+
assert_equal 'Pop', @tag.genre
|
142
|
+
assert_equal 2011, @tag.year
|
143
|
+
assert_equal 7, @tag.track
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "ID3V1 tag" do
|
148
|
+
setup do
|
149
|
+
@tag = @file.id3v1_tag(false)
|
150
|
+
end
|
151
|
+
|
152
|
+
should "exist" do
|
153
|
+
assert @file.id3v1_tag?
|
154
|
+
refute @file.id3v2_tag?
|
155
|
+
refute @file.ape_tag?
|
156
|
+
|
157
|
+
assert_not_nil @tag
|
158
|
+
assert_equal TagLib::ID3v1::Tag, @tag.class
|
159
|
+
end
|
160
|
+
|
161
|
+
should "have basic properties" do
|
162
|
+
refute @tag.empty?
|
163
|
+
|
164
|
+
assert_equal 'Title', @tag.title
|
165
|
+
assert_equal 'Artist', @tag.artist
|
166
|
+
assert_equal 'Album', @tag.album
|
167
|
+
assert_equal 'Comment', @tag.comment
|
168
|
+
assert_equal 'Pop', @tag.genre
|
169
|
+
assert_equal 2011, @tag.year
|
170
|
+
assert_equal 7, @tag.track
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
61
174
|
teardown do
|
62
175
|
@file.close
|
63
176
|
@file = nil
|