taglib-ruby 1.1.0 → 1.1.1

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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +2 -0
  5. data/Guardfile +4 -2
  6. data/README.md +55 -35
  7. data/Rakefile +5 -5
  8. data/docs/taglib/aiff.rb +0 -3
  9. data/docs/taglib/base.rb +0 -4
  10. data/docs/taglib/flac.rb +1 -3
  11. data/docs/taglib/id3v2.rb +1 -1
  12. data/docs/taglib/mp4.rb +2 -4
  13. data/docs/taglib/mpeg.rb +0 -1
  14. data/docs/taglib/ogg.rb +0 -4
  15. data/docs/taglib/vorbis.rb +0 -1
  16. data/docs/taglib/wav.rb +0 -4
  17. data/ext/extconf_common.rb +24 -28
  18. data/ext/taglib_aiff/extconf.rb +2 -0
  19. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +217 -178
  20. data/ext/taglib_base/extconf.rb +2 -0
  21. data/ext/taglib_base/includes.i +1 -0
  22. data/ext/taglib_base/taglib_base_wrap.cxx +233 -191
  23. data/ext/taglib_flac/extconf.rb +2 -0
  24. data/ext/taglib_flac/taglib_flac_wrap.cxx +228 -189
  25. data/ext/taglib_flac_picture/extconf.rb +2 -0
  26. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +210 -168
  27. data/ext/taglib_id3v1/extconf.rb +2 -0
  28. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +223 -182
  29. data/ext/taglib_id3v2/extconf.rb +2 -0
  30. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +429 -407
  31. data/ext/taglib_mp4/extconf.rb +2 -0
  32. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +295 -260
  33. data/ext/taglib_mpeg/extconf.rb +2 -0
  34. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +243 -206
  35. data/ext/taglib_ogg/extconf.rb +2 -0
  36. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +214 -171
  37. data/ext/taglib_vorbis/extconf.rb +2 -0
  38. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +217 -178
  39. data/ext/taglib_wav/extconf.rb +2 -0
  40. data/ext/taglib_wav/taglib_wav_wrap.cxx +217 -178
  41. data/lib/taglib/aiff.rb +2 -0
  42. data/lib/taglib/base.rb +3 -1
  43. data/lib/taglib/flac.rb +2 -0
  44. data/lib/taglib/id3v1.rb +2 -0
  45. data/lib/taglib/id3v2.rb +2 -0
  46. data/lib/taglib/mp4.rb +10 -13
  47. data/lib/taglib/mpeg.rb +2 -0
  48. data/lib/taglib/ogg.rb +2 -0
  49. data/lib/taglib/version.rb +3 -1
  50. data/lib/taglib/vorbis.rb +2 -0
  51. data/lib/taglib/wav.rb +2 -1
  52. data/lib/taglib.rb +4 -3
  53. data/taglib-ruby.gemspec +164 -163
  54. data/tasks/docs_coverage.rake +10 -8
  55. data/tasks/ext.rake +26 -25
  56. data/tasks/gemspec_check.rake +6 -4
  57. data/tasks/swig.rake +10 -11
  58. data/test/aiff_examples_test.rb +8 -13
  59. data/test/aiff_file_test.rb +29 -29
  60. data/test/aiff_file_write_test.rb +19 -20
  61. data/test/base_test.rb +4 -2
  62. data/test/data/add-relative-volume.cpp +7 -3
  63. data/test/data/flac-create.cpp +15 -5
  64. data/test/data/get_picture_data.cpp +5 -1
  65. data/test/data/id3v1-create.cpp +6 -3
  66. data/test/data/mp4-create.cpp +12 -4
  67. data/test/data/vorbis-create.cpp +12 -5
  68. data/test/data/wav-create.cpp +18 -3
  69. data/test/file_test.rb +7 -5
  70. data/test/fileref_open_test.rb +12 -10
  71. data/test/fileref_properties_test.rb +6 -4
  72. data/test/fileref_write_test.rb +14 -13
  73. data/test/flac_file_test.rb +32 -27
  74. data/test/flac_file_write_test.rb +17 -18
  75. data/test/flac_picture_memory_test.rb +13 -17
  76. data/test/helper.rb +3 -1
  77. data/test/id3v1_genres_test.rb +14 -12
  78. data/test/id3v1_tag_test.rb +7 -5
  79. data/test/id3v2_frames_test.rb +34 -34
  80. data/test/id3v2_header_test.rb +14 -13
  81. data/test/id3v2_memory_test.rb +21 -20
  82. data/test/id3v2_relative_volume_test.rb +11 -9
  83. data/test/id3v2_tag_test.rb +16 -14
  84. data/test/id3v2_unicode_test.rb +12 -10
  85. data/test/id3v2_unknown_frames_test.rb +7 -5
  86. data/test/id3v2_write_test.rb +28 -29
  87. data/test/mp4_file_test.rb +27 -26
  88. data/test/mp4_file_write_test.rb +12 -13
  89. data/test/mp4_items_test.rb +78 -79
  90. data/test/mpeg_file_test.rb +32 -30
  91. data/test/tag_test.rb +5 -3
  92. data/test/unicode_filename_test.rb +7 -7
  93. data/test/vorbis_file_test.rb +14 -12
  94. data/test/vorbis_tag_test.rb +46 -44
  95. data/test/wav_examples_test.rb +8 -16
  96. data/test/wav_file_test.rb +29 -29
  97. data/test/wav_file_write_test.rb +22 -23
  98. metadata +19 -18
@@ -1,62 +1,64 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class MP4FileTest < Test::Unit::TestCase
4
- context "TagLib::MP4::File" do
6
+ context 'TagLib::MP4::File' do
5
7
  setup do
6
- @file = TagLib::MP4::File.new("test/data/mp4.m4a")
8
+ @file = TagLib::MP4::File.new('test/data/mp4.m4a')
7
9
  @tag = @file.tag
8
10
  end
9
11
 
10
- should "have an MP4 tag" do
12
+ should 'have an MP4 tag' do
11
13
  assert @file.mp4_tag?
12
14
  refute_nil @tag
13
15
  end
14
16
 
15
- should "contain basic tag information" do
16
- assert_equal "Title", @tag.title
17
- assert_equal "Artist", @tag.artist
18
- assert_equal "Album", @tag.album
19
- assert_equal "Comment", @tag.comment
20
- assert_equal "Pop", @tag.genre
17
+ should 'contain basic tag information' do
18
+ assert_equal 'Title', @tag.title
19
+ assert_equal 'Artist', @tag.artist
20
+ assert_equal 'Album', @tag.album
21
+ assert_equal 'Comment', @tag.comment
22
+ assert_equal 'Pop', @tag.genre
21
23
  assert_equal 2011, @tag.year
22
24
  assert_equal 7, @tag.track
23
25
 
24
26
  assert_equal false, @tag.empty?
25
27
  end
26
28
 
27
- should "support testing for the presence of items" do
28
- refute @tag.contains "unknown"
29
- assert @tag.contains "trkn"
29
+ should 'support testing for the presence of items' do
30
+ refute @tag.contains 'unknown'
31
+ assert @tag.contains 'trkn'
30
32
  end
31
33
 
32
- should "support accessing items" do
33
- refute @tag["unkn"].valid?
34
+ should 'support accessing items' do
35
+ refute @tag['unkn'].valid?
34
36
 
35
- assert @tag["trkn"].valid?
37
+ assert @tag['trkn'].valid?
36
38
  assert_equal 7, @tag.track
37
39
  end
38
40
 
39
- should "support editing items" do
40
- @tag["trkn"] = TagLib::MP4::Item.from_int(1)
41
+ should 'support editing items' do
42
+ @tag['trkn'] = TagLib::MP4::Item.from_int(1)
41
43
  assert_equal 1, @tag.track
42
44
  end
43
45
 
44
- should "support removing items" do
45
- assert @tag.contains "trkn"
46
- @tag.remove_item("trkn")
47
- refute @tag.contains "trkn"
46
+ should 'support removing items' do
47
+ assert @tag.contains 'trkn'
48
+ @tag.remove_item('trkn')
49
+ refute @tag.contains 'trkn'
48
50
  end
49
51
 
50
- context "audio properties" do
52
+ context 'audio properties' do
51
53
  setup do
52
54
  @properties = @file.audio_properties
53
55
  end
54
56
 
55
- should "exist" do
57
+ should 'exist' do
56
58
  assert_not_nil @properties
57
59
  end
58
60
 
59
- should "contain basic information" do
61
+ should 'contain basic information' do
60
62
  assert_equal 1, @properties.length_in_seconds
61
63
  assert_equal 55, @properties.bitrate
62
64
  assert_equal 44100, @properties.sample_rate
@@ -64,7 +66,7 @@ class MP4FileTest < Test::Unit::TestCase
64
66
  assert_equal 2, @properties.channels
65
67
  end
66
68
 
67
- should "contain mp4-specific information" do
69
+ should 'contain mp4-specific information' do
68
70
  assert_equal 16, @properties.bits_per_sample
69
71
  assert_equal false, @properties.encrypted?
70
72
  assert_equal TagLib::MP4::Properties::AAC, @properties.codec
@@ -76,5 +78,4 @@ class MP4FileTest < Test::Unit::TestCase
76
78
  @file = nil
77
79
  end
78
80
  end
79
-
80
81
  end
@@ -1,27 +1,26 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class MP4FileWriteTest < Test::Unit::TestCase
6
+ SAMPLE_FILE = 'test/data/mp4.m4a'
7
+ OUTPUT_FILE = 'test/data/output.m4a'
8
+ PICTURE_FILE = 'test/data/globe_east_540.jpg'
4
9
 
5
- SAMPLE_FILE = "test/data/mp4.m4a"
6
- OUTPUT_FILE = "test/data/output.m4a"
7
- PICTURE_FILE = "test/data/globe_east_540.jpg"
8
-
9
- def reloaded
10
- TagLib::MP4::File.open(OUTPUT_FILE, false) do |file|
11
- yield file
12
- end
10
+ def reloaded(&block)
11
+ TagLib::MP4::File.open(OUTPUT_FILE, false, &block)
13
12
  end
14
13
 
15
- context "TagLib::MP4::File" do
14
+ context 'TagLib::MP4::File' do
16
15
  setup do
17
16
  FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
18
17
  @file = TagLib::MP4::File.new(OUTPUT_FILE, false)
19
18
  end
20
19
 
21
- should "be able to save the title" do
20
+ should 'be able to save the title' do
22
21
  tag = @file.tag
23
22
  assert_not_nil tag
24
- tag.title = "New Title"
23
+ tag.title = 'New Title'
25
24
  success = @file.save
26
25
  assert success
27
26
  @file.close
@@ -30,10 +29,10 @@ class MP4FileWriteTest < Test::Unit::TestCase
30
29
  written_title = reloaded do |file|
31
30
  file.tag.title
32
31
  end
33
- assert_equal "New Title", written_title
32
+ assert_equal 'New Title', written_title
34
33
  end
35
34
 
36
- should "be able to add and save new cover art" do
35
+ should 'be able to add and save new cover art' do
37
36
  item_map = @file.tag.item_map
38
37
  cover_art_list = item_map['covr'].to_cover_art_list
39
38
  assert_equal 1, cover_art_list.size
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen-string-literal: true
2
+
2
3
  require File.join(File.dirname(__FILE__), 'helper')
3
4
  require 'set'
4
5
 
@@ -7,55 +8,55 @@ class MP4ItemsTest < Test::Unit::TestCase
7
8
 
8
9
  context "The mp4.m4a file's items" do
9
10
  setup do
10
- @file = TagLib::MP4::File.new("test/data/mp4.m4a")
11
+ @file = TagLib::MP4::File.new('test/data/mp4.m4a')
11
12
  @tag = @file.tag
12
13
  @item_map = @file.tag.item_map
13
14
  @item_keys = [
14
- "covr", "#{ITUNES_LEADER}nam", "#{ITUNES_LEADER}ART", "#{ITUNES_LEADER}alb",
15
+ 'covr', "#{ITUNES_LEADER}nam", "#{ITUNES_LEADER}ART", "#{ITUNES_LEADER}alb",
15
16
  "#{ITUNES_LEADER}cmt", "#{ITUNES_LEADER}gen", "#{ITUNES_LEADER}day",
16
- "trkn", "#{ITUNES_LEADER}too", "#{ITUNES_LEADER}cpy"
17
+ 'trkn', "#{ITUNES_LEADER}too", "#{ITUNES_LEADER}cpy"
17
18
  ]
18
19
  end
19
20
 
20
- context "item_map" do
21
- should "exist" do
21
+ context 'item_map' do
22
+ should 'exist' do
22
23
  assert_not_nil @item_map
23
24
  end
24
25
 
25
- should "not be empty" do
26
+ should 'not be empty' do
26
27
  assert_equal false, @item_map.empty?
27
28
  end
28
29
 
29
- should "contain 10 items" do
30
+ should 'contain 10 items' do
30
31
  assert_equal @item_keys.count, @item_map.size
31
32
  end
32
33
 
33
- should "have keys" do
34
- assert_equal true, @item_map.contains("trkn")
34
+ should 'have keys' do
35
+ assert_equal true, @item_map.contains('trkn')
35
36
  assert_equal true, @item_map.has_key?("#{ITUNES_LEADER}too")
36
37
  assert_equal true, @item_map.include?("#{ITUNES_LEADER}cpy")
37
- assert_equal false, @item_map.include?("none such key")
38
+ assert_equal false, @item_map.include?('none such key')
38
39
  end
39
40
 
40
- should "look up keys" do
41
- assert_nil @item_map["none such key"]
42
- assert_equal ["Title"], @item_map["#{ITUNES_LEADER}nam"].to_string_list
41
+ should 'look up keys' do
42
+ assert_nil @item_map['none such key']
43
+ assert_equal ['Title'], @item_map["#{ITUNES_LEADER}nam"].to_string_list
43
44
  end
44
45
 
45
- should "be clearable" do
46
+ should 'be clearable' do
46
47
  assert_equal 10, @item_map.size
47
48
  comment = @item_map["#{ITUNES_LEADER}cmt"]
48
49
  @item_map.clear
49
50
  assert_equal true, @item_map.empty?
50
51
  begin
51
52
  comment.to_string_list
52
- flunk("Should have raised ObjectPreviouslyDeleted.")
53
- rescue => e
54
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
53
+ flunk('Should have raised ObjectPreviouslyDeleted.')
54
+ rescue StandardError => e
55
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
55
56
  end
56
57
  end
57
58
 
58
- should "be convertible to an array" do
59
+ should 'be convertible to an array' do
59
60
  array = @item_map.to_a
60
61
  assert_equal 10, array.count
61
62
  array.each do |object|
@@ -67,150 +68,149 @@ class MP4ItemsTest < Test::Unit::TestCase
67
68
  end
68
69
  end
69
70
 
70
- should "be convertible to a hash" do
71
+ should 'be convertible to a hash' do
71
72
  hsh = @item_map.to_h
72
73
  assert_equal Set.new(hsh.keys), Set.new(@item_keys)
73
74
  end
74
75
  end
75
76
 
76
- should "be removable" do
77
+ should 'be removable' do
77
78
  assert_equal 10, @item_map.size
78
79
  title = @item_map["#{ITUNES_LEADER}nam"]
79
80
  @item_map.erase("#{ITUNES_LEADER}nam")
80
81
  assert_equal 9, @item_map.size
81
82
  begin
82
83
  title.to_string_list
83
- flunk("Should have raised ObjectPreviouslyDeleted.")
84
- rescue => e
85
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
84
+ flunk('Should have raised ObjectPreviouslyDeleted.')
85
+ rescue StandardError => e
86
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
86
87
  end
87
88
  end
88
89
 
89
- should "reflect edition of items from the tag" do
90
- assert @tag.contains "trkn"
91
- track = @item_map["trkn"]
90
+ should 'reflect edition of items from the tag' do
91
+ assert @tag.contains 'trkn'
92
+ track = @item_map['trkn']
92
93
 
93
- @tag["trkn"] = TagLib::MP4::Item.from_int(1)
94
+ @tag['trkn'] = TagLib::MP4::Item.from_int(1)
94
95
 
95
96
  begin
96
97
  track.to_int_pair[0]
97
- flunk("Should have raised ObjectPreviouslyDeleted.")
98
- rescue => e
99
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
98
+ flunk('Should have raised ObjectPreviouslyDeleted.')
99
+ rescue StandardError => e
100
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
100
101
  end
101
102
  end
102
103
 
103
- should "reflect removal of items from the tag" do
104
- assert @tag.contains "trkn"
105
- track = @item_map["trkn"]
104
+ should 'reflect removal of items from the tag' do
105
+ assert @tag.contains 'trkn'
106
+ track = @item_map['trkn']
106
107
 
107
- @tag.remove_item("trkn")
108
- refute @item_map.contains "trkn"
108
+ @tag.remove_item('trkn')
109
+ refute @item_map.contains 'trkn'
109
110
 
110
111
  begin
111
112
  track.to_int_pair[0]
112
- flunk("Should have raised ObjectPreviouslyDeleted.")
113
- rescue => e
114
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
113
+ flunk('Should have raised ObjectPreviouslyDeleted.')
114
+ rescue StandardError => e
115
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
115
116
  end
116
117
  end
117
118
 
118
- context "inserting items" do
119
- should "insert a new item" do
119
+ context 'inserting items' do
120
+ should 'insert a new item' do
120
121
  new_title = TagLib::MP4::Item.from_string_list(['new title'])
121
122
  @item_map.insert("#{ITUNES_LEADER}nam", new_title)
122
- new_title = nil
123
123
  GC.start
124
124
  assert_equal ['new title'], @item_map["#{ITUNES_LEADER}nam"].to_string_list
125
125
  end
126
126
 
127
- should "unlink items that get replaced" do
127
+ should 'unlink items that get replaced' do
128
128
  title = @item_map["#{ITUNES_LEADER}nam"]
129
129
  @item_map.insert("#{ITUNES_LEADER}nam", TagLib::MP4::Item.from_int(1))
130
130
  begin
131
131
  title.to_string_list
132
- flunk("Should have raised ObjectPreviouslyDeleted.")
133
- rescue => e
134
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
132
+ flunk('Should have raised ObjectPreviouslyDeleted.')
133
+ rescue StandardError => e
134
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
135
135
  end
136
136
  end
137
137
  end
138
138
 
139
- context "TagLib::MP4::Item" do
140
- should "be creatable from a boolean" do
139
+ context 'TagLib::MP4::Item' do
140
+ should 'be creatable from a boolean' do
141
141
  item = TagLib::MP4::Item.from_bool(false)
142
142
  assert_equal TagLib::MP4::Item, item.class
143
143
  assert_equal false, item.to_bool
144
144
  end
145
145
 
146
- should "be creatable from a byte" do
146
+ should 'be creatable from a byte' do
147
147
  item = TagLib::MP4::Item.from_byte(123)
148
148
  assert_equal TagLib::MP4::Item, item.class
149
149
  assert_equal 123, item.to_byte
150
150
  end
151
151
 
152
- should "be creatable from an unsigned int" do
153
- item = TagLib::MP4::Item.from_int(12346)
152
+ should 'be creatable from an unsigned int' do
153
+ item = TagLib::MP4::Item.from_int(12_346)
154
154
  assert_equal TagLib::MP4::Item, item.class
155
- assert_equal 12346, item.to_uint
155
+ assert_equal 12_346, item.to_uint
156
156
  end
157
157
 
158
- should "be creatable from an int" do
158
+ should 'be creatable from an int' do
159
159
  item = TagLib::MP4::Item.from_int(-42)
160
160
  assert_equal TagLib::MP4::Item, item.class
161
- assert_equal -42, item.to_int
161
+ assert_equal(-42, item.to_int)
162
162
  end
163
163
 
164
- should "be creatable from a long long" do
165
- item = TagLib::MP4::Item.from_long_long(1234567890)
164
+ should 'be creatable from a long long' do
165
+ item = TagLib::MP4::Item.from_long_long(1_234_567_890)
166
166
  assert_equal TagLib::MP4::Item, item.class
167
- assert_equal 1234567890, item.to_long_long
167
+ assert_equal 1_234_567_890, item.to_long_long
168
168
  end
169
169
 
170
- context ".from_int_pair" do
171
- should "be creatable from a pair of ints" do
170
+ context '.from_int_pair' do
171
+ should 'be creatable from a pair of ints' do
172
172
  item = TagLib::MP4::Item.from_int_pair([123, 456])
173
173
  assert_equal TagLib::MP4::Item, item.class
174
174
  assert_equal [123, 456], item.to_int_pair
175
175
  end
176
176
 
177
- should "raise an error when passed something other than an Array" do
177
+ should 'raise an error when passed something other than an Array' do
178
178
  begin
179
179
  TagLib::MP4::Item.from_int_pair(1)
180
- flunk("Should have raised ArgumentError.")
181
- rescue => e
182
- assert_equal "ArgumentError", e.class.to_s
180
+ flunk('Should have raised ArgumentError.')
181
+ rescue StandardError => e
182
+ assert_equal 'ArgumentError', e.class.to_s
183
183
  end
184
184
  end
185
185
 
186
- should "raise an error when passed an Array with more than two elements" do
186
+ should 'raise an error when passed an Array with more than two elements' do
187
187
  begin
188
188
  TagLib::MP4::Item.from_int_pair([1, 2, 3])
189
- flunk("Should have raised ArgumentError.")
190
- rescue => e
191
- assert_equal "ArgumentError", e.class.to_s
189
+ flunk('Should have raised ArgumentError.')
190
+ rescue StandardError => e
191
+ assert_equal 'ArgumentError', e.class.to_s
192
192
  end
193
193
  end
194
194
 
195
- should "raise an error when passed an Array with less than two elements" do
195
+ should 'raise an error when passed an Array with less than two elements' do
196
196
  begin
197
197
  TagLib::MP4::Item.from_int_pair([1])
198
- flunk("Should have raised ArgumentError.")
199
- rescue => e
200
- assert_equal "ArgumentError", e.class.to_s
198
+ flunk('Should have raised ArgumentError.')
199
+ rescue StandardError => e
200
+ assert_equal 'ArgumentError', e.class.to_s
201
201
  end
202
202
  end
203
203
  end
204
204
 
205
- context "created from an array of strings" do
206
- should "interpreted as strings with an encoding" do
207
- item = TagLib::MP4::Item.from_string_list(["héllo"])
205
+ context 'created from an array of strings' do
206
+ should 'interpreted as strings with an encoding' do
207
+ item = TagLib::MP4::Item.from_string_list(['héllo'])
208
208
  assert_equal TagLib::MP4::Item, item.class
209
- assert_equal ["héllo"], item.to_string_list
209
+ assert_equal ['héllo'], item.to_string_list
210
210
  end
211
211
  end
212
212
 
213
- should "be creatable from a CoverArt list" do
213
+ should 'be creatable from a CoverArt list' do
214
214
  cover_art = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, 'foo')
215
215
  item = TagLib::MP4::Item.from_cover_art_list([cover_art])
216
216
  assert_equal TagLib::MP4::Item, item.class
@@ -220,8 +220,8 @@ class MP4ItemsTest < Test::Unit::TestCase
220
220
  end
221
221
  end
222
222
 
223
- context "TagLib::MP4::CoverArt" do
224
- should "be creatable from a string" do
223
+ context 'TagLib::MP4::CoverArt' do
224
+ should 'be creatable from a string' do
225
225
  cover_art = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, 'foo')
226
226
  assert_equal TagLib::MP4::CoverArt::JPEG, cover_art.format
227
227
  assert_equal 'foo', cover_art.data
@@ -233,5 +233,4 @@ class MP4ItemsTest < Test::Unit::TestCase
233
233
  @file = nil
234
234
  end
235
235
  end
236
-
237
236
  end
@@ -1,29 +1,31 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestMPEGFile < Test::Unit::TestCase
4
- context "The crash.mp3 file" do
6
+ context 'The crash.mp3 file' do
5
7
  setup do
6
8
  read_properties = true
7
- @file = TagLib::MPEG::File.new("test/data/crash.mp3", read_properties)
9
+ @file = TagLib::MPEG::File.new('test/data/crash.mp3', read_properties)
8
10
  end
9
11
 
10
- should "have a basic tag" do
12
+ should 'have a basic tag' do
11
13
  tag = @file.tag
12
14
  assert_not_nil tag
13
15
  assert_equal TagLib::Tag, tag.class
14
16
  assert tag.empty?
15
17
  end
16
18
 
17
- context "audio properties" do
19
+ context 'audio properties' do
18
20
  setup do
19
21
  @properties = @file.audio_properties
20
22
  end
21
23
 
22
- should "be MPEG audio properties" do
24
+ should 'be MPEG audio properties' do
23
25
  assert_equal TagLib::MPEG::Properties, @properties.class
24
26
  end
25
27
 
26
- should "contain information" do
28
+ should 'contain information' do
27
29
  assert_equal 2, @properties.length_in_seconds
28
30
  assert_equal 2299, @properties.length_in_milliseconds
29
31
  assert_equal 157, @properties.bitrate
@@ -37,25 +39,25 @@ class TestMPEGFile < Test::Unit::TestCase
37
39
  assert_equal true, @properties.original?
38
40
  end
39
41
 
40
- context "Xing header" do
42
+ context 'Xing header' do
41
43
  setup do
42
44
  @xing_header = @properties.xing_header
43
45
  end
44
46
 
45
- should "exist" do
47
+ should 'exist' do
46
48
  assert_not_nil @xing_header
47
49
  end
48
50
 
49
- should "contain information" do
51
+ should 'contain information' do
50
52
  assert @xing_header.valid?
51
53
  assert_equal 88, @xing_header.total_frames
52
- assert_equal 45140, @xing_header.total_size
54
+ assert_equal 45_140, @xing_header.total_size
53
55
  assert_equal TagLib::MPEG::XingHeader::Xing, @xing_header.type
54
56
  end
55
57
  end
56
58
  end
57
59
 
58
- should "have no tag" do
60
+ should 'have no tag' do
59
61
  refute @file.id3v1_tag?
60
62
  refute @file.id3v2_tag?
61
63
  refute @file.ape_tag?
@@ -67,29 +69,29 @@ class TestMPEGFile < Test::Unit::TestCase
67
69
  end
68
70
  end
69
71
 
70
- context "The id3v1.mp3 file" do
72
+ context 'The id3v1.mp3 file' do
71
73
  setup do
72
74
  read_properties = true
73
- @file = TagLib::MPEG::File.new("test/data/id3v1.mp3", read_properties)
75
+ @file = TagLib::MPEG::File.new('test/data/id3v1.mp3', read_properties)
74
76
  end
75
77
 
76
- should "have a basic tag" do
78
+ should 'have a basic tag' do
77
79
  tag = @file.tag
78
80
  assert_not_nil tag
79
81
  assert_equal TagLib::Tag, tag.class
80
82
  refute tag.empty?
81
83
  end
82
84
 
83
- context "audio properties" do
85
+ context 'audio properties' do
84
86
  setup do
85
87
  @properties = @file.audio_properties
86
88
  end
87
89
 
88
- should "be MPEG audio properties" do
90
+ should 'be MPEG audio properties' do
89
91
  assert_equal TagLib::MPEG::Properties, @properties.class
90
92
  end
91
93
 
92
- should "contain information" do
94
+ should 'contain information' do
93
95
  assert_equal 0, @properties.length_in_seconds
94
96
  assert_equal 261, @properties.length_in_milliseconds
95
97
  assert_equal 141, @properties.bitrate
@@ -103,16 +105,16 @@ class TestMPEGFile < Test::Unit::TestCase
103
105
  assert_equal true, @properties.original?
104
106
  end
105
107
 
106
- context "Xing header" do
108
+ context 'Xing header' do
107
109
  setup do
108
110
  @xing_header = @properties.xing_header
109
111
  end
110
112
 
111
- should "exist" do
113
+ should 'exist' do
112
114
  assert_not_nil @xing_header
113
115
  end
114
116
 
115
- should "contain information" do
117
+ should 'contain information' do
116
118
  assert @xing_header.valid?
117
119
  assert_equal 10, @xing_header.total_frames
118
120
  assert_equal 4596, @xing_header.total_size
@@ -121,17 +123,17 @@ class TestMPEGFile < Test::Unit::TestCase
121
123
  end
122
124
  end
123
125
 
124
- context "tag" do
126
+ context 'tag' do
125
127
  setup do
126
128
  @tag = @file.tag
127
129
  end
128
130
 
129
- should "exist" do
131
+ should 'exist' do
130
132
  refute_nil @tag
131
133
  assert_equal TagLib::Tag, @tag.class
132
134
  end
133
135
 
134
- should "have basic properties" do
136
+ should 'have basic properties' do
135
137
  refute @tag.empty?
136
138
 
137
139
  assert_equal 'Title', @tag.title
@@ -144,12 +146,12 @@ class TestMPEGFile < Test::Unit::TestCase
144
146
  end
145
147
  end
146
148
 
147
- context "ID3V1 tag" do
149
+ context 'ID3V1 tag' do
148
150
  setup do
149
151
  @tag = @file.id3v1_tag(false)
150
152
  end
151
153
 
152
- should "exist" do
154
+ should 'exist' do
153
155
  assert @file.id3v1_tag?
154
156
  refute @file.id3v2_tag?
155
157
  refute @file.ape_tag?
@@ -158,7 +160,7 @@ class TestMPEGFile < Test::Unit::TestCase
158
160
  assert_equal TagLib::ID3v1::Tag, @tag.class
159
161
  end
160
162
 
161
- should "have basic properties" do
163
+ should 'have basic properties' do
162
164
  refute @tag.empty?
163
165
 
164
166
  assert_equal 'Title', @tag.title
@@ -177,13 +179,13 @@ class TestMPEGFile < Test::Unit::TestCase
177
179
  end
178
180
  end
179
181
 
180
- context "TagLib::MPEG::File" do
181
- should "have open method" do
182
+ context 'TagLib::MPEG::File' do
183
+ should 'have open method' do
182
184
  title = nil
183
- TagLib::MPEG::File.open("test/data/sample.mp3", false) do |file|
185
+ TagLib::MPEG::File.open('test/data/sample.mp3', false) do |file|
184
186
  title = file.tag.title
185
187
  end
186
- assert_equal "Dummy Title", title
188
+ assert_equal 'Dummy Title', title
187
189
  end
188
190
  end
189
191
  end
data/test/tag_test.rb CHANGED
@@ -1,13 +1,15 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestTag < Test::Unit::TestCase
4
- context "The sample.mp3 file" do
6
+ context 'The sample.mp3 file' do
5
7
  setup do
6
- @fileref = TagLib::FileRef.new("test/data/sample.mp3", false)
8
+ @fileref = TagLib::FileRef.new('test/data/sample.mp3', false)
7
9
  @tag = @fileref.tag
8
10
  end
9
11
 
10
- should "have basic tag information" do
12
+ should 'have basic tag information' do
11
13
  assert_equal 'Dummy Title', @tag.title
12
14
  assert_equal 'Dummy Artist', @tag.artist
13
15
  assert_equal 'Dummy Album', @tag.album