taglib-ruby 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/.yardopts +1 -1
  4. data/{CHANGES.md → CHANGELOG.md} +35 -14
  5. data/Gemfile +2 -0
  6. data/Guardfile +4 -2
  7. data/README.md +56 -38
  8. data/Rakefile +8 -8
  9. data/docs/taglib/aiff.rb +0 -3
  10. data/docs/taglib/base.rb +0 -4
  11. data/docs/taglib/flac.rb +1 -3
  12. data/docs/taglib/id3v2.rb +1 -1
  13. data/docs/taglib/mp4.rb +2 -4
  14. data/docs/taglib/mpeg.rb +0 -1
  15. data/docs/taglib/ogg.rb +0 -4
  16. data/docs/taglib/vorbis.rb +0 -1
  17. data/docs/taglib/wav.rb +0 -4
  18. data/ext/extconf_common.rb +24 -28
  19. data/ext/taglib_aiff/extconf.rb +2 -0
  20. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +217 -178
  21. data/ext/taglib_base/extconf.rb +2 -0
  22. data/ext/taglib_base/includes.i +25 -0
  23. data/ext/taglib_base/taglib_base.i +18 -0
  24. data/ext/taglib_base/taglib_base_wrap.cxx +233 -191
  25. data/ext/taglib_flac/extconf.rb +2 -0
  26. data/ext/taglib_flac/taglib_flac.i +7 -0
  27. data/ext/taglib_flac/taglib_flac_wrap.cxx +235 -189
  28. data/ext/taglib_flac_picture/extconf.rb +2 -0
  29. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +210 -168
  30. data/ext/taglib_id3v1/extconf.rb +2 -0
  31. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +223 -182
  32. data/ext/taglib_id3v2/extconf.rb +2 -0
  33. data/ext/taglib_id3v2/taglib_id3v2.i +17 -0
  34. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +2922 -993
  35. data/ext/taglib_mp4/extconf.rb +2 -0
  36. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +295 -260
  37. data/ext/taglib_mpeg/extconf.rb +2 -0
  38. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +243 -206
  39. data/ext/taglib_ogg/extconf.rb +2 -0
  40. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +214 -171
  41. data/ext/taglib_vorbis/extconf.rb +2 -0
  42. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +217 -178
  43. data/ext/taglib_wav/extconf.rb +2 -0
  44. data/ext/taglib_wav/taglib_wav_wrap.cxx +217 -178
  45. data/lib/taglib/aiff.rb +2 -0
  46. data/lib/taglib/base.rb +3 -1
  47. data/lib/taglib/flac.rb +2 -0
  48. data/lib/taglib/id3v1.rb +2 -0
  49. data/lib/taglib/id3v2.rb +2 -0
  50. data/lib/taglib/mp4.rb +10 -13
  51. data/lib/taglib/mpeg.rb +2 -0
  52. data/lib/taglib/ogg.rb +2 -0
  53. data/lib/taglib/version.rb +4 -2
  54. data/lib/taglib/vorbis.rb +2 -0
  55. data/lib/taglib/wav.rb +2 -1
  56. data/lib/taglib.rb +4 -3
  57. data/taglib-ruby.gemspec +165 -162
  58. data/tasks/docs_coverage.rake +10 -8
  59. data/tasks/ext.rake +26 -25
  60. data/tasks/gemspec_check.rake +7 -5
  61. data/tasks/swig.rake +10 -11
  62. data/test/aiff_examples_test.rb +8 -13
  63. data/test/aiff_file_test.rb +29 -29
  64. data/test/aiff_file_write_test.rb +19 -20
  65. data/test/base_test.rb +4 -2
  66. data/test/data/add-relative-volume.cpp +7 -3
  67. data/test/data/flac-create.cpp +15 -5
  68. data/test/data/flac_nopic.flac +0 -0
  69. data/test/data/get_picture_data.cpp +5 -1
  70. data/test/data/id3v1-create.cpp +6 -3
  71. data/test/data/mp4-create.cpp +12 -4
  72. data/test/data/vorbis-create.cpp +12 -5
  73. data/test/data/wav-create.cpp +18 -3
  74. data/test/file_test.rb +7 -5
  75. data/test/fileref_open_test.rb +12 -10
  76. data/test/fileref_properties_test.rb +6 -4
  77. data/test/fileref_write_test.rb +14 -13
  78. data/test/flac_file_test.rb +32 -27
  79. data/test/flac_file_write_test.rb +17 -18
  80. data/test/flac_picture_memory_test.rb +39 -0
  81. data/test/helper.rb +3 -1
  82. data/test/id3v1_genres_test.rb +14 -12
  83. data/test/id3v1_tag_test.rb +7 -5
  84. data/test/id3v2_frames_test.rb +98 -34
  85. data/test/id3v2_header_test.rb +14 -13
  86. data/test/id3v2_memory_test.rb +21 -20
  87. data/test/id3v2_relative_volume_test.rb +11 -9
  88. data/test/id3v2_tag_test.rb +16 -14
  89. data/test/id3v2_unicode_test.rb +12 -10
  90. data/test/id3v2_unknown_frames_test.rb +7 -5
  91. data/test/id3v2_write_test.rb +28 -29
  92. data/test/mp4_file_test.rb +27 -26
  93. data/test/mp4_file_write_test.rb +12 -13
  94. data/test/mp4_items_test.rb +78 -79
  95. data/test/mpeg_file_test.rb +32 -30
  96. data/test/tag_test.rb +5 -3
  97. data/test/unicode_filename_test.rb +7 -7
  98. data/test/vorbis_file_test.rb +14 -12
  99. data/test/vorbis_tag_test.rb +46 -44
  100. data/test/wav_examples_test.rb +8 -16
  101. data/test/wav_file_test.rb +29 -29
  102. data/test/wav_file_write_test.rb +22 -23
  103. metadata +26 -23
@@ -1,26 +1,25 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  require 'fileutils'
4
6
 
5
7
  class TestID3v2Write < Test::Unit::TestCase
8
+ SAMPLE_FILE = 'test/data/sample.mp3'
9
+ OUTPUT_FILE = 'test/data/output.mp3'
10
+ PICTURE_FILE = 'test/data/globe_east_540.jpg'
6
11
 
7
- SAMPLE_FILE = "test/data/sample.mp3"
8
- OUTPUT_FILE = "test/data/output.mp3"
9
- PICTURE_FILE = "test/data/globe_east_540.jpg"
10
-
11
- def reloaded
12
- TagLib::MPEG::File.open(OUTPUT_FILE, false) do |file|
13
- yield file
14
- end
12
+ def reloaded(&block)
13
+ TagLib::MPEG::File.open(OUTPUT_FILE, false, &block)
15
14
  end
16
15
 
17
- context "TagLib::MPEG::File" do
16
+ context 'TagLib::MPEG::File' do
18
17
  setup do
19
18
  FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
20
19
  @file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
21
20
  end
22
21
 
23
- should "be able to strip the tag" do
22
+ should 'be able to strip the tag' do
24
23
  assert_not_nil @file.id3v2_tag
25
24
  success = @file.strip
26
25
  assert success
@@ -34,7 +33,7 @@ class TestID3v2Write < Test::Unit::TestCase
34
33
  end
35
34
  end
36
35
 
37
- should "be able to save only ID3v2 tag" do
36
+ should 'be able to save only ID3v2 tag' do
38
37
  assert_not_nil @file.id3v2_tag
39
38
  assert_not_nil @file.id3v1_tag
40
39
  @file.save(TagLib::MPEG::File::ID3v2)
@@ -54,7 +53,7 @@ class TestID3v2Write < Test::Unit::TestCase
54
53
  end
55
54
  end
56
55
 
57
- should "be able to save ID3v2.3" do
56
+ should 'be able to save ID3v2.3' do
58
57
  success = @file.save(TagLib::MPEG::File::ID3v2, true, 3)
59
58
  assert_equal true, success
60
59
  @file.close
@@ -64,38 +63,38 @@ class TestID3v2Write < Test::Unit::TestCase
64
63
  f.read(5)
65
64
  end
66
65
  # 3 stands for v2.3
67
- s = "ID3" + 3.chr + 0.chr
66
+ s = "ID3#{3.chr}#{0.chr}"
68
67
  assert_equal s, header
69
68
  end
70
69
 
71
- should "be able to set fields to nil" do
70
+ should 'be able to set fields to nil' do
72
71
  tag = @file.id3v2_tag
73
72
  tag.title = nil
74
73
  assert_equal [], tag.frame_list('TIT2')
75
74
  end
76
75
 
77
- context "with a fresh tag" do
76
+ context 'with a fresh tag' do
78
77
  setup do
79
78
  @file.strip
80
79
  @tag = @file.id3v2_tag(true)
81
80
  end
82
81
 
83
- should "be able to create a new tag" do
82
+ should 'be able to create a new tag' do
84
83
  assert_not_nil @tag
85
84
  assert_equal 0, @tag.frame_list.size
86
85
  end
87
86
 
88
- should "be able to save it" do
87
+ should 'be able to save it' do
89
88
  success = @file.save
90
89
  assert success
91
90
  end
92
91
 
93
- should "be able to add a new frame to it and read it back" do
92
+ should 'be able to add a new frame to it and read it back' do
94
93
  picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
95
94
 
96
95
  apic = TagLib::ID3v2::AttachedPictureFrame.new
97
- apic.mime_type = "image/jpeg"
98
- apic.description = "desc"
96
+ apic.mime_type = 'image/jpeg'
97
+ apic.description = 'desc'
99
98
  apic.text_encoding = TagLib::String::UTF8
100
99
  apic.picture = picture_data
101
100
  apic.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover
@@ -108,16 +107,16 @@ class TestID3v2Write < Test::Unit::TestCase
108
107
  @file = nil
109
108
 
110
109
  written_file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
111
- written_apic = written_file.id3v2_tag.frame_list("APIC").first
112
- assert_equal "image/jpeg", written_apic.mime_type
113
- assert_equal "desc", written_apic.description
110
+ written_apic = written_file.id3v2_tag.frame_list('APIC').first
111
+ assert_equal 'image/jpeg', written_apic.mime_type
112
+ assert_equal 'desc', written_apic.description
114
113
  assert_equal picture_data, written_apic.picture
115
114
  written_file.close
116
115
  end
117
116
 
118
- should "be able to set field_list" do
119
- tit2 = TagLib::ID3v2::TextIdentificationFrame.new("TIT2", TagLib::String::UTF8)
120
- texts = ["one", "two"]
117
+ should 'be able to set field_list' do
118
+ tit2 = TagLib::ID3v2::TextIdentificationFrame.new('TIT2', TagLib::String::UTF8)
119
+ texts = %w[one two]
121
120
  tit2.field_list = texts
122
121
  assert_equal texts, tit2.field_list
123
122
  @tag.add_frame(tit2)
@@ -125,14 +124,14 @@ class TestID3v2Write < Test::Unit::TestCase
125
124
  assert success
126
125
  end
127
126
 
128
- should "not fail when field_list is nil" do
129
- tit2 = TagLib::ID3v2::TextIdentificationFrame.new("TIT2", TagLib::String::UTF8)
127
+ should 'not fail when field_list is nil' do
128
+ tit2 = TagLib::ID3v2::TextIdentificationFrame.new('TIT2', TagLib::String::UTF8)
130
129
  tit2.field_list = nil
131
130
  assert_equal [], tit2.field_list
132
131
  end
133
132
 
134
133
  if HAVE_ENCODING
135
- should "be able to set unicode fields" do
134
+ should 'be able to set unicode fields' do
136
135
  # Hello, Unicode Snowman (not in Latin1)
137
136
  text = "Hello, \u{2603}"
138
137
 
@@ -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