taglib-ruby 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,5 +1,5 @@
1
1
  #include <iostream>
2
- #include <stdlib.h>
2
+ #include <cstdlib>
3
3
 
4
4
  #include <taglib/taglib.h>
5
5
  #include <taglib/vorbisfile.h>
@@ -10,9 +10,10 @@ using namespace TagLib;
10
10
 
11
11
  int main(int argc, char **argv) {
12
12
  if (argc != 2) {
13
- std::cout << "usage: " << argv[0] << " file.oga" << std::endl;
14
- exit(1);
13
+ std::cerr << "usage: " << argv[0] << " file.oga" << std::endl;
14
+ return EXIT_FAILURE;
15
15
  }
16
+
16
17
  char *filename = argv[1];
17
18
 
18
19
  Vorbis::File file(filename);
@@ -41,7 +42,11 @@ int main(int argc, char **argv) {
41
42
  tag->addField("MULTIPLE", "A");
42
43
  tag->addField("MULTIPLE", "B", false);
43
44
 
44
- ByteVector pictureData = getPictureData("globe_east_90.jpg");
45
+ const ByteVector data = getPictureData("globe_east_90.jpg");
46
+ if (data.isEmpty()) {
47
+ std::cerr << "failed to get picture data" << std::endl;
48
+ return EXIT_FAILURE;
49
+ }
45
50
 
46
51
  FLAC::Picture picture;
47
52
  picture.setType(FLAC::Picture::FrontCover);
@@ -51,11 +56,13 @@ int main(int argc, char **argv) {
51
56
  picture.setHeight(90);
52
57
  picture.setColorDepth(24);
53
58
  picture.setNumColors(0);
54
- picture.setData(pictureData);
59
+ picture.setData(data);
55
60
 
56
61
  tag->addField("METADATA_BLOCK_PICTURE", picture.render().toBase64());
57
62
 
58
63
  file.save();
64
+
65
+ return EXIT_SUCCESS;
59
66
  }
60
67
 
61
68
  // vim: set filetype=cpp sw=2 ts=2 expandtab:
@@ -1,3 +1,6 @@
1
+ #include <iostream>
2
+ #include <cstdlib>
3
+
1
4
  #include <taglib/taglib.h>
2
5
  #include <taglib/wavfile.h>
3
6
  #include <taglib/wavproperties.h>
@@ -7,12 +10,12 @@
7
10
 
8
11
  using namespace TagLib;
9
12
 
10
-
11
13
  int main(int argc, char **argv) {
12
14
  if (argc != 2) {
13
- std::cout << "usage: " << argv[0] << " file.wav" << std::endl;
14
- exit(1);
15
+ std::cerr << "usage: " << argv[0] << " file.wav" << std::endl;
16
+ return EXIT_FAILURE;
15
17
  }
18
+
16
19
  char *filename = argv[1];
17
20
 
18
21
  RIFF::WAV::File file(filename);
@@ -32,6 +35,11 @@ int main(int argc, char **argv) {
32
35
  ID3v2::AttachedPictureFrame *apic;
33
36
 
34
37
  picture_data = getPictureData("globe_east_540.jpg");
38
+ if (picture_data.isEmpty()) {
39
+ std::cerr << "failed to get picture data" << std::endl;
40
+ return EXIT_FAILURE;
41
+ }
42
+
35
43
  apic = new ID3v2::AttachedPictureFrame();
36
44
  apic->setPicture(picture_data);
37
45
  apic->setMimeType("image/jpeg");
@@ -41,6 +49,11 @@ int main(int argc, char **argv) {
41
49
  tag->addFrame(apic);
42
50
 
43
51
  picture_data = getPictureData("globe_east_90.jpg");
52
+ if (picture_data.isEmpty()) {
53
+ std::cerr << "failed to get picture data" << std::endl;
54
+ return EXIT_FAILURE;
55
+ }
56
+
44
57
  apic = new ID3v2::AttachedPictureFrame();
45
58
  apic->setPicture(picture_data);
46
59
  apic->setMimeType("image/jpeg");
@@ -50,6 +63,8 @@ int main(int argc, char **argv) {
50
63
  tag->addFrame(apic);
51
64
 
52
65
  file.save();
66
+
67
+ return EXIT_SUCCESS;
53
68
  }
54
69
 
55
70
  // vim: set filetype=cpp sw=2 ts=2 expandtab:
data/test/file_test.rb CHANGED
@@ -1,18 +1,20 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestFile < Test::Unit::TestCase
4
- context "The sample.mp3 file" do
6
+ context 'The sample.mp3 file' do
5
7
  setup do
6
- @mpeg_file = TagLib::MPEG::File.new("test/data/sample.mp3", false)
8
+ @mpeg_file = TagLib::MPEG::File.new('test/data/sample.mp3', false)
7
9
  end
8
10
 
9
- context "filename" do
10
- should "be the right name" do
11
+ context 'filename' do
12
+ should 'be the right name' do
11
13
  assert_equal 'test/data/sample.mp3', @mpeg_file.name
12
14
  end
13
15
 
14
16
  if HAVE_ENCODING
15
- should "have the right encoding" do
17
+ should 'have the right encoding' do
16
18
  assert_equal Encoding.find('filesystem'), @mpeg_file.name.encoding
17
19
  end
18
20
  end
@@ -1,30 +1,32 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  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|
6
+ context 'TagLib::FileRef.open' do
7
+ should 'return result' do
8
+ title = TagLib::FileRef.open('test/data/vorbis.oga', false) do |file|
7
9
  tag = file.tag
8
10
  assert_not_nil tag
9
11
  tag.title
10
12
  end
11
- assert_equal "Title", title
13
+ assert_equal 'Title', title
12
14
  end
13
15
 
14
- should "close even with exception" do
16
+ should 'close even with exception' do
15
17
  f = nil
16
18
  begin
17
- TagLib::FileRef.open("test/data/vorbis.oga", false) do |file|
19
+ TagLib::FileRef.open('test/data/vorbis.oga', false) do |file|
18
20
  f = file
19
21
  raise NotImplementedError
20
22
  end
21
- flunk("Should have raised NotImplementedError.")
23
+ flunk('Should have raised NotImplementedError.')
22
24
  rescue NotImplementedError
23
25
  begin
24
26
  f.tag
25
- flunk("Should have raised ObjectPreviouslyDeleted.")
26
- rescue => e
27
- assert_equal "ObjectPreviouslyDeleted", e.class.to_s
27
+ flunk('Should have raised ObjectPreviouslyDeleted.')
28
+ rescue StandardError => e
29
+ assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
28
30
  end
29
31
  end
30
32
  end
@@ -1,17 +1,19 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestFileRefProperties < Test::Unit::TestCase
4
- context "The crash.mp3 file audio properties" do
6
+ context 'The crash.mp3 file audio properties' do
5
7
  setup do
6
- @fileref = TagLib::FileRef.new("test/data/crash.mp3", true, TagLib::AudioProperties::Average)
8
+ @fileref = TagLib::FileRef.new('test/data/crash.mp3', true, TagLib::AudioProperties::Average)
7
9
  @properties = @fileref.audio_properties
8
10
  end
9
11
 
10
- should "exist" do
12
+ should 'exist' do
11
13
  assert_not_nil @properties
12
14
  end
13
15
 
14
- should "contain basic information" do
16
+ should 'contain basic information' do
15
17
  assert_equal 2, @properties.length_in_seconds
16
18
  assert_equal 157, @properties.bitrate
17
19
  assert_equal 44100, @properties.sample_rate
@@ -1,36 +1,37 @@
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 TestFileRefWrite < Test::Unit::TestCase
8
+ SAMPLE_FILE = 'test/data/sample.mp3'
9
+ OUTPUT_FILE = 'test/data/output.mp3'
6
10
 
7
- SAMPLE_FILE = "test/data/sample.mp3"
8
- OUTPUT_FILE = "test/data/output.mp3"
9
-
10
- context "TagLib::FileRef" do
11
+ context 'TagLib::FileRef' do
11
12
  setup do
12
13
  FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
13
14
  @file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
14
15
  end
15
16
 
16
- should "be able to save the title" do
17
+ should 'be able to save the title' do
17
18
  tag = @file.tag
18
19
  assert_not_nil tag
19
- tag.title = "New Title"
20
+ tag.title = 'New Title'
20
21
  success = @file.save
21
22
  assert success
22
23
  @file.close
23
24
  @file = nil
24
25
 
25
26
  written_file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
26
- assert_equal "New Title", written_file.tag.title
27
+ assert_equal 'New Title', written_file.tag.title
27
28
  written_file.close
28
29
  end
29
30
 
30
- should "not segfault when setting int" do
31
+ should 'not segfault when setting int' do
31
32
  begin
32
33
  @file.tag.title = 42
33
- flunk("Should have raised a TypeError")
34
+ flunk('Should have raised a TypeError')
34
35
  rescue TypeError
35
36
  # this is good
36
37
  end
@@ -45,15 +46,15 @@ class TestFileRefWrite < Test::Unit::TestCase
45
46
  end
46
47
  end
47
48
 
48
- context "TagLib::FileRef.open" do
49
+ context 'TagLib::FileRef.open' do
49
50
  setup do
50
51
  FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
51
52
  end
52
53
 
53
- should "be able to save file" do
54
+ should 'be able to save file' do
54
55
  TagLib::MPEG::File.open(OUTPUT_FILE, false) do |file|
55
56
  tag = file.tag
56
- tag.title = "New Title"
57
+ tag.title = 'New Title'
57
58
  file.save
58
59
  end
59
60
 
@@ -61,7 +62,7 @@ class TestFileRefWrite < Test::Unit::TestCase
61
62
  tag = file.tag
62
63
  tag.title
63
64
  end
64
- assert_equal "New Title", title
65
+ assert_equal 'New Title', title
65
66
  end
66
67
 
67
68
  teardown do
@@ -1,49 +1,54 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class FlacFileTest < Test::Unit::TestCase
4
- context "TagLib::FLAC::File" do
6
+ context 'TagLib::FLAC::File' do
5
7
  setup do
6
- @file = TagLib::FLAC::File.new("test/data/flac.flac")
8
+ @file = TagLib::FLAC::File.new('test/data/flac.flac')
7
9
  end
8
10
 
9
- should "have a tag" do
11
+ should 'have a tag' do
10
12
  tag = @file.tag
11
13
  assert_not_nil tag
12
14
  assert_equal TagLib::Tag, tag.class
13
15
  end
14
16
 
15
- should "have XiphComment" do
17
+ should 'have XiphComment' do
16
18
  assert @file.xiph_comment?
17
19
  tag = @file.xiph_comment
18
20
  assert_not_nil tag
19
21
  assert_equal TagLib::Ogg::XiphComment, tag.class
22
+ assert_not_nil @file.xiph_comment(true)
20
23
  end
21
24
 
22
- should "have method for ID3v1 tag" do
25
+ should 'have method for ID3v1 tag' do
23
26
  refute @file.id3v1_tag?
24
27
  assert_nil @file.id3v1_tag
28
+ assert_not_nil @file.id3v1_tag(true)
25
29
  end
26
30
 
27
- should "have method for ID3v2 tag" do
31
+ should 'have method for ID3v2 tag' do
28
32
  refute @file.id3v2_tag?
29
33
  assert_nil @file.id3v2_tag
34
+ assert_not_nil @file.id3v2_tag(true)
30
35
  end
31
36
 
32
- should "support stripping tags by type" do
37
+ should 'support stripping tags by type' do
33
38
  @file.strip(TagLib::FLAC::File::XiphComment)
34
39
  assert @file.xiph_comment?
35
40
  end
36
41
 
37
- context "audio properties" do
42
+ context 'audio properties' do
38
43
  setup do
39
44
  @properties = @file.audio_properties
40
45
  end
41
46
 
42
- should "exist" do
47
+ should 'exist' do
43
48
  assert_not_nil @properties
44
49
  end
45
50
 
46
- should "contain basic information" do
51
+ should 'contain basic information' do
47
52
  assert_equal 1, @properties.length_in_seconds
48
53
  assert_equal 1017, @properties.length_in_milliseconds
49
54
  assert_equal 209, @properties.bitrate
@@ -51,51 +56,51 @@ class FlacFileTest < Test::Unit::TestCase
51
56
  assert_equal 1, @properties.channels
52
57
  end
53
58
 
54
- should "contain flac-specific information" do
59
+ should 'contain flac-specific information' do
55
60
  assert_equal 16, @properties.bits_per_sample
56
- s = ["78d19b86df2cd488b35957e6bd884968"].pack('H*')
61
+ s = ['78d19b86df2cd488b35957e6bd884968'].pack('H*')
57
62
  assert_equal s, @properties.signature
58
63
  end
59
64
  end
60
65
 
61
- should "have pictures" do
66
+ should 'have pictures' do
62
67
  refute_empty @file.picture_list
63
68
  end
64
69
 
65
- context "first picture" do
70
+ context 'first picture' do
66
71
  setup do
67
72
  @picture = @file.picture_list.first
68
73
  end
69
74
 
70
- should "be a TagLib::FLAC::Picture," do
75
+ should 'be a TagLib::FLAC::Picture,' do
71
76
  assert_equal TagLib::FLAC::Picture, @picture.class
72
77
  end
73
78
 
74
- should "have meta-data" do
79
+ should 'have meta-data' do
75
80
  assert_equal TagLib::FLAC::Picture::FrontCover, @picture.type
76
- assert_equal "image/jpeg", @picture.mime_type
77
- assert_equal "Globe", @picture.description
81
+ assert_equal 'image/jpeg', @picture.mime_type
82
+ assert_equal 'Globe', @picture.description
78
83
  assert_equal 90, @picture.width
79
84
  assert_equal 90, @picture.height
80
85
  assert_equal 8, @picture.color_depth
81
86
  assert_equal 0, @picture.num_colors
82
87
  end
83
88
 
84
- should "have data" do
85
- picture_data = File.open("test/data/globe_east_90.jpg", 'rb'){ |f| f.read }
89
+ should 'have data' do
90
+ picture_data = File.open('test/data/globe_east_90.jpg', 'rb') { |f| f.read }
86
91
  assert_equal picture_data, @picture.data
87
92
  end
88
93
  end
89
94
 
90
- should "support removing a picture" do
95
+ should 'support removing a picture' do
91
96
  refute_empty @file.picture_list
92
97
  @file.remove_picture(@file.picture_list.first)
93
98
  assert_empty @file.picture_list
94
99
  end
95
100
 
96
- should "support removing all pictures" do
101
+ should 'support removing all pictures' do
97
102
  refute_empty @file.picture_list
98
- @file.remove_pictures()
103
+ @file.remove_pictures
99
104
  assert_empty @file.picture_list
100
105
  end
101
106
 
@@ -105,13 +110,13 @@ class FlacFileTest < Test::Unit::TestCase
105
110
  end
106
111
  end
107
112
 
108
- context "TagLib::FLAC::File.open" do
109
- should "should work" do
113
+ context 'TagLib::FLAC::File.open' do
114
+ should 'should work' do
110
115
  title = nil
111
- TagLib::FLAC::File.open("test/data/flac.flac", false) do |file|
116
+ TagLib::FLAC::File.open('test/data/flac.flac', false) do |file|
112
117
  title = file.tag.title
113
118
  end
114
- assert_equal "Title", title
119
+ assert_equal 'Title', title
115
120
  end
116
121
  end
117
122
  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 FlacFileWriteTest < Test::Unit::TestCase
6
+ SAMPLE_FILE = 'test/data/flac.flac'
7
+ OUTPUT_FILE = 'test/data/output.flac'
8
+ PICTURE_FILE = 'test/data/globe_east_90.jpg'
4
9
 
5
- SAMPLE_FILE = "test/data/flac.flac"
6
- OUTPUT_FILE = "test/data/output.flac"
7
- PICTURE_FILE = "test/data/globe_east_90.jpg"
8
-
9
- def reloaded
10
- TagLib::FLAC::File.open(OUTPUT_FILE, false) do |file|
11
- yield file
12
- end
10
+ def reloaded(&block)
11
+ TagLib::FLAC::File.open(OUTPUT_FILE, false, &block)
13
12
  end
14
13
 
15
- context "TagLib::FLAC::File" do
14
+ context 'TagLib::FLAC::File' do
16
15
  setup do
17
16
  FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
18
17
  @file = TagLib::FLAC::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 FlacFileWriteTest < 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 remove pictures" do
35
+ should 'be able to remove pictures' do
37
36
  assert_equal 1, @file.picture_list.size
38
37
  @file.remove_pictures
39
38
  assert_equal 0, @file.picture_list.size
@@ -41,13 +40,13 @@ class FlacFileWriteTest < Test::Unit::TestCase
41
40
  assert success
42
41
  end
43
42
 
44
- should "be able to add and save a new picture" do
43
+ should 'be able to add and save a new picture' do
45
44
  picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
46
45
 
47
46
  pic = TagLib::FLAC::Picture.new
48
47
  pic.type = TagLib::FLAC::Picture::FrontCover
49
- pic.mime_type = "image/jpeg"
50
- pic.description = "desc"
48
+ pic.mime_type = 'image/jpeg'
49
+ pic.description = 'desc'
51
50
  pic.width = 90
52
51
  pic.height = 90
53
52
  pic.data = picture_data
@@ -62,8 +61,8 @@ class FlacFileWriteTest < Test::Unit::TestCase
62
61
  reloaded do |file|
63
62
  written_pic = file.picture_list.last
64
63
  assert_equal TagLib::FLAC::Picture::FrontCover, written_pic.type
65
- assert_equal "image/jpeg", written_pic.mime_type
66
- assert_equal "desc", written_pic.description
64
+ assert_equal 'image/jpeg', written_pic.mime_type
65
+ assert_equal 'desc', written_pic.description
67
66
  assert_equal 90, written_pic.width
68
67
  assert_equal 90, written_pic.height
69
68
  assert_equal picture_data, written_pic.data
@@ -1,43 +1,39 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestFlacPictureMemory < Test::Unit::TestCase
4
-
5
6
  N = 10000
6
7
 
7
- context "TagLib::FLAC::Picture" do
8
-
8
+ context 'TagLib::FLAC::Picture' do
9
9
  setup do
10
-
11
10
  end
12
11
 
13
- should "release memory when closing flac file with picture data" do
12
+ should 'release memory when closing flac file with picture data' do
14
13
  c = 0
15
14
  N.times do
16
- TagLib::FLAC::File.open("test/data/flac.flac", false) do |f|
17
- f.picture_list.each do |p|
18
- x = p.data
19
- c = c + 1
15
+ TagLib::FLAC::File.open('test/data/flac.flac', false) do |f|
16
+ f.picture_list.each do |_p|
17
+ c += 1
20
18
  end
21
19
  end
22
20
  end
23
- assert_equal N,c
21
+ assert_equal N, c
24
22
  end
25
23
 
26
- should "process a flac file without picture data" do
24
+ should 'process a flac file without picture data' do
27
25
  c = 0
28
26
  N.times do
29
- TagLib::FLAC::File.open("test/data/flac_nopic.flac", false) do |f|
30
- f.picture_list.each do |p|
31
- x = p.data
32
- c = c + 1
27
+ TagLib::FLAC::File.open('test/data/flac_nopic.flac', false) do |f|
28
+ f.picture_list.each do |_p|
29
+ c += 1
33
30
  end
34
31
  end
35
32
  end
36
- assert_equal 0,c
33
+ assert_equal 0, c
37
34
  end
38
35
 
39
36
  teardown do
40
-
41
37
  end
42
38
  end
43
39
  end
data/test/helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'test/unit'
3
5
  require 'shoulda-context'
@@ -7,4 +9,4 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
9
 
8
10
  require 'taglib'
9
11
 
10
- HAVE_ENCODING = !RUBY_VERSION.start_with?("1.8")
12
+ HAVE_ENCODING = !RUBY_VERSION.start_with?('1.8')
@@ -1,23 +1,25 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestVorbisTag < Test::Unit::TestCase
4
- context "TagLib::ID3v1" do
5
- should "list genres" do
6
- assert_equal "Jazz", TagLib::ID3v1::genre_list[8]
6
+ context 'TagLib::ID3v1' do
7
+ should 'list genres' do
8
+ assert_equal 'Jazz', TagLib::ID3v1.genre_list[8]
7
9
  end
8
10
 
9
- should "map genres to their index" do
10
- assert_equal 8, TagLib::ID3v1::genre_map["Jazz"]
11
+ should 'map genres to their index' do
12
+ assert_equal 8, TagLib::ID3v1.genre_map['Jazz']
11
13
  end
12
14
 
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)
15
+ should 'support to query the value of a genre' do
16
+ assert_equal 'Jazz', TagLib::ID3v1.genre(8)
17
+ assert_equal '', TagLib::ID3v1.genre(255)
16
18
  end
17
19
 
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")
20
+ should 'support to query the index of a genre' do
21
+ assert_equal 8, TagLib::ID3v1.genre_index('Jazz')
22
+ assert_equal 255, TagLib::ID3v1.genre_index('Unknown')
21
23
  end
22
24
  end
23
- end
25
+ end
@@ -1,22 +1,24 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestID3v1Tag < Test::Unit::TestCase
4
- context "The id3v1.mp3 file" do
6
+ context 'The id3v1.mp3 file' do
5
7
  setup do
6
8
  read_properties = false
7
- @file = TagLib::MPEG::File.new("test/data/id3v1.mp3", read_properties)
9
+ @file = TagLib::MPEG::File.new('test/data/id3v1.mp3', read_properties)
8
10
  end
9
11
 
10
- should "have an ID3v1 tag" do
12
+ should 'have an ID3v1 tag' do
11
13
  assert_not_nil @file.id3v1_tag
12
14
  end
13
15
 
14
- context "ID3v1 tag" do
16
+ context 'ID3v1 tag' do
15
17
  setup do
16
18
  @tag = @file.id3v1_tag
17
19
  end
18
20
 
19
- should "have basic properties" do
21
+ should 'have basic properties' do
20
22
  assert_equal 'Title', @tag.title
21
23
  assert_equal 'Artist', @tag.artist
22
24
  assert_equal 'Album', @tag.album