taglib-ruby 1.0.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/.yardopts +1 -1
  4. data/CHANGELOG.md +15 -0
  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 +21 -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_wrap.cxx +228 -189
  27. data/ext/taglib_flac_picture/extconf.rb +2 -0
  28. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +210 -168
  29. data/ext/taglib_id3v1/extconf.rb +2 -0
  30. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +223 -182
  31. data/ext/taglib_id3v2/extconf.rb +2 -0
  32. data/ext/taglib_id3v2/taglib_id3v2.i +17 -0
  33. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +2923 -999
  34. data/ext/taglib_mp4/extconf.rb +2 -0
  35. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +311 -281
  36. data/ext/taglib_mpeg/extconf.rb +2 -0
  37. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +243 -206
  38. data/ext/taglib_ogg/extconf.rb +2 -0
  39. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +214 -171
  40. data/ext/taglib_vorbis/extconf.rb +2 -0
  41. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +217 -178
  42. data/ext/taglib_wav/extconf.rb +2 -0
  43. data/ext/taglib_wav/taglib_wav_wrap.cxx +217 -178
  44. data/lib/taglib/aiff.rb +2 -0
  45. data/lib/taglib/base.rb +3 -1
  46. data/lib/taglib/flac.rb +2 -0
  47. data/lib/taglib/id3v1.rb +2 -0
  48. data/lib/taglib/id3v2.rb +2 -0
  49. data/lib/taglib/mp4.rb +10 -13
  50. data/lib/taglib/mpeg.rb +2 -0
  51. data/lib/taglib/ogg.rb +2 -0
  52. data/lib/taglib/version.rb +4 -2
  53. data/lib/taglib/vorbis.rb +2 -0
  54. data/lib/taglib/wav.rb +2 -1
  55. data/lib/taglib.rb +4 -3
  56. data/taglib-ruby.gemspec +165 -162
  57. data/tasks/docs_coverage.rake +10 -8
  58. data/tasks/ext.rake +26 -25
  59. data/tasks/gemspec_check.rake +7 -5
  60. data/tasks/swig.rake +10 -11
  61. data/test/aiff_examples_test.rb +8 -13
  62. data/test/aiff_file_test.rb +29 -29
  63. data/test/aiff_file_write_test.rb +19 -20
  64. data/test/base_test.rb +4 -2
  65. data/test/data/add-relative-volume.cpp +7 -3
  66. data/test/data/flac-create.cpp +15 -5
  67. data/test/data/flac_nopic.flac +0 -0
  68. data/test/data/get_picture_data.cpp +5 -1
  69. data/test/data/id3v1-create.cpp +6 -3
  70. data/test/data/mp4-create.cpp +12 -4
  71. data/test/data/vorbis-create.cpp +12 -5
  72. data/test/data/wav-create.cpp +18 -3
  73. data/test/file_test.rb +7 -5
  74. data/test/fileref_open_test.rb +12 -10
  75. data/test/fileref_properties_test.rb +6 -4
  76. data/test/fileref_write_test.rb +14 -13
  77. data/test/flac_file_test.rb +32 -27
  78. data/test/flac_file_write_test.rb +17 -18
  79. data/test/flac_picture_memory_test.rb +39 -0
  80. data/test/helper.rb +3 -1
  81. data/test/id3v1_genres_test.rb +14 -12
  82. data/test/id3v1_tag_test.rb +7 -5
  83. data/test/id3v2_frames_test.rb +103 -34
  84. data/test/id3v2_header_test.rb +14 -13
  85. data/test/id3v2_memory_test.rb +21 -20
  86. data/test/id3v2_relative_volume_test.rb +11 -9
  87. data/test/id3v2_tag_test.rb +16 -14
  88. data/test/id3v2_unicode_test.rb +12 -10
  89. data/test/id3v2_unknown_frames_test.rb +7 -5
  90. data/test/id3v2_write_test.rb +28 -29
  91. data/test/mp4_file_test.rb +27 -26
  92. data/test/mp4_file_write_test.rb +12 -13
  93. data/test/mp4_items_test.rb +78 -79
  94. data/test/mpeg_file_test.rb +32 -30
  95. data/test/tag_test.rb +5 -3
  96. data/test/unicode_filename_test.rb +7 -7
  97. data/test/vorbis_file_test.rb +14 -12
  98. data/test/vorbis_tag_test.rb +46 -44
  99. data/test/wav_examples_test.rb +8 -16
  100. data/test/wav_file_test.rb +29 -29
  101. data/test/wav_file_write_test.rb +22 -23
  102. metadata +24 -21
@@ -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
@@ -1,22 +1,22 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
  require 'fileutils'
3
5
 
4
6
  class TestUnicodeFilename < Test::Unit::TestCase
5
- SRC_FILE = "test/data/vorbis.oga"
7
+ SRC_FILE = 'test/data/vorbis.oga'
6
8
  # That's "hello-" followed by "ni hao" in UTF-8
7
- DST_FILE = "test/data/hello-\xE4\xBD\xA0\xE5\xA5\xBD.oga"
9
+ DST_FILE = "test/data/hello-\xE4\xBD\xA0\xE5\xA5\xBD.oga".dup # mutable
8
10
 
9
- context "TagLib::FileRef" do
11
+ context 'TagLib::FileRef' do
10
12
  setup do
11
- if HAVE_ENCODING
12
- DST_FILE.force_encoding('UTF-8')
13
- end
13
+ DST_FILE.force_encoding('UTF-8') if HAVE_ENCODING
14
14
  FileUtils.cp SRC_FILE, DST_FILE
15
15
  @fileref = TagLib::FileRef.new(DST_FILE, false)
16
16
  @tag = @fileref.tag
17
17
  end
18
18
 
19
- should "be possible to read" do
19
+ should 'be possible to read' do
20
20
  assert_not_nil @tag
21
21
  assert_equal 'Title', @tag.title
22
22
  end
@@ -1,34 +1,36 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class TestVorbisFile < Test::Unit::TestCase
4
- context "The vorbis.oga file" do
6
+ context 'The vorbis.oga file' do
5
7
  setup do
6
- @file = TagLib::Ogg::Vorbis::File.new("test/data/vorbis.oga")
8
+ @file = TagLib::Ogg::Vorbis::File.new('test/data/vorbis.oga')
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::Ogg::XiphComment, tag.class
13
15
  end
14
16
 
15
- context "audio properties" do
17
+ context 'audio properties' do
16
18
  setup do
17
19
  @properties = @file.audio_properties
18
20
  end
19
21
 
20
- should "exist" do
22
+ should 'exist' do
21
23
  assert_not_nil @properties
22
24
  end
23
25
 
24
- should "contain basic information" do
26
+ should 'contain basic information' do
25
27
  assert_equal 0, @properties.length_in_seconds # file is short
26
- assert_equal 371, @properties.bitrate
28
+ assert_includes [371, 76], @properties.bitrate
27
29
  assert_equal 44100, @properties.sample_rate
28
30
  assert_equal 2, @properties.channels
29
31
  end
30
32
 
31
- should "contain vorbis-specific information" do
33
+ should 'contain vorbis-specific information' do
32
34
  assert_equal 0, @properties.vorbis_version
33
35
  assert_equal 0, @properties.bitrate_maximum
34
36
  assert_equal 64000, @properties.bitrate_nominal
@@ -42,13 +44,13 @@ class TestVorbisFile < Test::Unit::TestCase
42
44
  end
43
45
  end
44
46
 
45
- context "TagLib::Ogg::Vorbis::File" do
46
- should "have open method" do
47
+ context 'TagLib::Ogg::Vorbis::File' do
48
+ should 'have open method' do
47
49
  title = nil
48
- TagLib::Ogg::Vorbis::File.open("test/data/vorbis.oga", false) do |file|
50
+ TagLib::Ogg::Vorbis::File.open('test/data/vorbis.oga', false) do |file|
49
51
  title = file.tag.title
50
52
  end
51
- assert_equal "Title", title
53
+ assert_equal 'Title', title
52
54
  end
53
55
  end
54
56
  end
@@ -1,118 +1,120 @@
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 "The vorbis.oga file tag" do
6
+ context 'The vorbis.oga file tag' do
5
7
  setup do
6
- @file = TagLib::Ogg::Vorbis::File.new("test/data/vorbis.oga")
8
+ @file = TagLib::Ogg::Vorbis::File.new('test/data/vorbis.oga')
7
9
  @tag = @file.tag
8
10
  end
9
11
 
10
- should "contain basic tag information" do
11
- assert_equal "Title", @tag.title
12
- assert_equal "Artist", @tag.artist
13
- assert_equal "Album", @tag.album
12
+ should 'contain basic tag information' do
13
+ assert_equal 'Title', @tag.title
14
+ assert_equal 'Artist', @tag.artist
15
+ assert_equal 'Album', @tag.album
14
16
  # Use DESCRIPTION if it exists, otherwise COMMENT.
15
- assert_equal "Test file", @tag.comment
16
- assert_equal "Pop", @tag.genre
17
+ assert_equal 'Test file', @tag.comment
18
+ assert_equal 'Pop', @tag.genre
17
19
  assert_equal 2011, @tag.year
18
20
  assert_equal 7, @tag.track
19
21
  assert_equal false, @tag.empty?
20
22
  end
21
23
 
22
- should "have contains? method" do
24
+ should 'have contains? method' do
23
25
  assert @tag.contains?('TITLE')
24
26
  assert !@tag.contains?('DOESNTEXIST')
25
27
  end
26
28
 
27
- should "have field_count" do
29
+ should 'have field_count' do
28
30
  assert_equal 18, @tag.field_count
29
31
  end
30
32
 
31
- should "have vendor_id" do
32
- assert_equal "Xiph.Org libVorbis I 20101101 (Schaufenugget)", @tag.vendor_id
33
+ should 'have vendor_id' do
34
+ assert_equal 'Xiph.Org libVorbis I 20101101 (Schaufenugget)', @tag.vendor_id
33
35
  end
34
36
 
35
- context "fields" do
37
+ context 'fields' do
36
38
  setup do
37
39
  @fields = @tag.field_list_map
38
40
  end
39
41
 
40
- should "exist" do
42
+ should 'exist' do
41
43
  assert_not_nil @fields
42
44
  end
43
45
 
44
- should "be usable as a Hash" do
45
- assert_equal ["Title"], @fields['TITLE']
46
+ should 'be usable as a Hash' do
47
+ assert_equal ['Title'], @fields['TITLE']
46
48
  assert_nil @fields['DOESNTEXIST']
47
49
  end
48
50
 
49
- should "be able to return more than one value for a key" do
50
- assert_equal ["A", "B"], @fields['MULTIPLE']
51
+ should 'be able to return more than one value for a key' do
52
+ assert_equal %w[A B], @fields['MULTIPLE']
51
53
  end
52
54
  end
53
55
 
54
- should "support add_field with replace" do
55
- @tag.add_field('TITLE', "New Title")
56
- assert_equal ["New Title"], @tag.field_list_map['TITLE']
56
+ should 'support add_field with replace' do
57
+ @tag.add_field('TITLE', 'New Title')
58
+ assert_equal ['New Title'], @tag.field_list_map['TITLE']
57
59
  end
58
60
 
59
- should "support add_field without replace" do
61
+ should 'support add_field without replace' do
60
62
  replace = false
61
- @tag.add_field('TITLE', "Additional Title", replace)
62
- assert_equal ["Title", "Additional Title"], @tag.field_list_map['TITLE']
63
+ @tag.add_field('TITLE', 'Additional Title', replace)
64
+ assert_equal ['Title', 'Additional Title'], @tag.field_list_map['TITLE']
63
65
  end
64
66
 
65
- should "support remove_fields" do
67
+ should 'support remove_fields' do
66
68
  assert @tag.contains?('MULTIPLE')
67
69
  @tag.remove_fields('MULTIPLE')
68
70
  refute @tag.contains?('MULTIPLE')
69
71
  end
70
72
 
71
- should "support remove_all_fields" do
73
+ should 'support remove_all_fields' do
72
74
  refute_equal 0, @tag.field_count
73
- @tag.remove_all_fields()
75
+ @tag.remove_all_fields
74
76
  # remove_all_fields() do not remove pictures
75
77
  assert_equal 1, @tag.field_count
76
78
  end
77
79
 
78
- should "have pictures" do
80
+ should 'have pictures' do
79
81
  refute_empty @tag.picture_list
80
82
  end
81
83
 
82
- context "first picture" do
84
+ context 'first picture' do
83
85
  setup do
84
86
  @picture = @tag.picture_list.first
85
87
  end
86
88
 
87
- should "be a TagLib::FLAC::Picture," do
89
+ should 'be a TagLib::FLAC::Picture,' do
88
90
  assert_equal TagLib::FLAC::Picture, @picture.class
89
91
  end
90
92
 
91
- should "have meta-data" do
93
+ should 'have meta-data' do
92
94
  assert_equal TagLib::FLAC::Picture::FrontCover, @picture.type
93
- assert_equal "image/jpeg", @picture.mime_type
94
- assert_equal "Globe", @picture.description
95
+ assert_equal 'image/jpeg', @picture.mime_type
96
+ assert_equal 'Globe', @picture.description
95
97
  assert_equal 90, @picture.width
96
98
  assert_equal 90, @picture.height
97
99
  assert_equal 24, @picture.color_depth
98
100
  assert_equal 0, @picture.num_colors
99
101
  end
100
102
 
101
- should "have data" do
102
- picture_data = File.open("test/data/globe_east_90.jpg", 'rb'){ |f| f.read }
103
+ should 'have data' do
104
+ picture_data = File.open('test/data/globe_east_90.jpg', 'rb') { |f| f.read }
103
105
  assert_equal picture_data, @picture.data
104
106
  end
105
107
  end
106
108
 
107
- should "support removing a picture" do
109
+ should 'support removing a picture' do
108
110
  refute_empty @tag.picture_list
109
111
  @tag.remove_picture(@tag.picture_list.first)
110
112
  assert_empty @tag.picture_list
111
113
  end
112
114
 
113
- should "support removing all pictures" do
115
+ should 'support removing all pictures' do
114
116
  refute_empty @tag.picture_list
115
- @tag.remove_all_pictures()
117
+ @tag.remove_all_pictures
116
118
  assert_empty @tag.picture_list
117
119
  end
118
120
 
@@ -122,12 +124,12 @@ class TestVorbisTag < Test::Unit::TestCase
122
124
  end
123
125
  end
124
126
 
125
- context "The XiphComment class" do
126
- should "support check_key" do
127
- refute TagLib::Ogg::XiphComment::check_key("")
128
- refute TagLib::Ogg::XiphComment::check_key("something=")
129
- refute TagLib::Ogg::XiphComment::check_key("something~")
130
- assert TagLib::Ogg::XiphComment::check_key("something")
127
+ context 'The XiphComment class' do
128
+ should 'support check_key' do
129
+ refute TagLib::Ogg::XiphComment.check_key('')
130
+ refute TagLib::Ogg::XiphComment.check_key('something=')
131
+ refute TagLib::Ogg::XiphComment.check_key('something~')
132
+ assert TagLib::Ogg::XiphComment.check_key('something')
131
133
  end
132
134
  end
133
135
  end
@@ -1,42 +1,34 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class WAVExamples < Test::Unit::TestCase
6
+ DATA_FILE_PREFIX = 'test/data/wav-'
4
7
 
5
- DATA_FILE_PREFIX = "test/data/wav-"
6
-
7
- context "TagLib::RIFF::WAV::File" do
8
-
9
- should "Run TagLib::RIFF::WAV::File examples" do
10
-
11
-
8
+ context 'TagLib::RIFF::WAV::File' do
9
+ should 'Run TagLib::RIFF::WAV::File examples' do
12
10
  # Reading the title
13
-
14
11
  title = TagLib::RIFF::WAV::File.open("#{DATA_FILE_PREFIX}sample.wav") do |file|
15
12
  file.tag.title
16
13
  end
17
14
 
18
15
  # Reading WAV-specific audio properties
19
-
20
16
  TagLib::RIFF::WAV::File.open("#{DATA_FILE_PREFIX}sample.wav") do |file|
21
- file.audio_properties.sample_rate #=> 8
17
+ file.audio_properties.sample_rate #=> 8
22
18
  end
23
19
 
24
20
  # Saving ID3v2 cover-art to disk
25
-
26
21
  TagLib::RIFF::WAV::File.open("#{DATA_FILE_PREFIX}sample.wav") do |file|
27
22
  id3v2_tag = file.tag
28
23
  cover = id3v2_tag.frame_list('APIC').first
29
24
  ext = cover.mime_type.rpartition('/')[2]
30
- File.open("#{DATA_FILE_PREFIX}cover-art.#{ext}", "wb") { |f| f.write cover.picture }
25
+ File.open("#{DATA_FILE_PREFIX}cover-art.#{ext}", 'wb') { |f| f.write cover.picture }
31
26
  end
32
27
 
33
-
34
28
  # checks
35
- assert_equal "WAV Dummy Track Title", title
29
+ assert_equal 'WAV Dummy Track Title', title
36
30
  assert_equal true, File.exist?("#{DATA_FILE_PREFIX}cover-art.jpeg")
37
31
  FileUtils.rm("#{DATA_FILE_PREFIX}cover-art.jpeg")
38
32
  end
39
-
40
33
  end
41
-
42
34
  end
@@ -1,29 +1,30 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'helper')
2
4
 
3
5
  class WAVFileTest < Test::Unit::TestCase
6
+ SAMPLE_FILE = 'test/data/wav-sample.wav'
7
+ PICTURE_FILE = 'test/data/globe_east_540.jpg'
4
8
 
5
- SAMPLE_FILE = "test/data/wav-sample.wav"
6
- PICTURE_FILE = "test/data/globe_east_540.jpg"
7
-
8
- context "TagLib::RIFF::WAV::File" do
9
+ context 'TagLib::RIFF::WAV::File' do
9
10
  setup do
10
11
  @file = TagLib::RIFF::WAV::File.new(SAMPLE_FILE)
11
12
  end
12
13
 
13
- should "open" do
14
+ should 'open' do
14
15
  assert_not_nil @file
15
16
  end
16
17
 
17
- context "audio properties" do
18
+ context 'audio properties' do
18
19
  setup do
19
20
  @properties = @file.audio_properties
20
21
  end
21
22
 
22
- should "exist" do
23
+ should 'exist' do
23
24
  assert_not_nil @properties
24
25
  end
25
26
 
26
- should "contain basic information" do
27
+ should 'contain basic information' do
27
28
  assert_equal 0, @properties.length_in_seconds
28
29
  assert_equal 698, @properties.length_in_milliseconds
29
30
  assert_equal 88, @properties.bitrate
@@ -31,59 +32,59 @@ class WAVFileTest < Test::Unit::TestCase
31
32
  assert_equal 1, @properties.channels
32
33
  end
33
34
 
34
- should "contain WAV-specific information" do
35
+ should 'contain WAV-specific information' do
35
36
  assert_equal 8, @properties.bits_per_sample
36
37
  assert_equal TagLib::RIFF::WAV::FORMAT_PCM, @properties.format
37
38
  end
38
39
  end
39
40
 
40
- context "ID3V2 tag" do
41
+ context 'ID3V2 tag' do
41
42
  setup do
42
43
  @tag = @file.tag
43
44
  end
44
45
 
45
- should "exist" do
46
+ should 'exist' do
46
47
  assert @file.id3v2_tag?
47
48
  assert_not_nil @tag
48
49
  assert_equal TagLib::ID3v2::Tag, @tag.class
49
50
  end
50
51
 
51
- should "not have an Info tag" do
52
+ should 'not have an Info tag' do
52
53
  refute @file.info_tag?
53
54
  end
54
55
 
55
- should "contain basic tag information" do
56
- assert_equal "WAV Dummy Track Title", @tag.title
57
- assert_equal "WAV Dummy Artist Name", @tag.artist
58
- assert_equal "WAV Dummy Album Title", @tag.album
59
- assert_equal "WAV Dummy Comment", @tag.comment
60
- assert_equal "Jazz", @tag.genre
56
+ should 'contain basic tag information' do
57
+ assert_equal 'WAV Dummy Track Title', @tag.title
58
+ assert_equal 'WAV Dummy Artist Name', @tag.artist
59
+ assert_equal 'WAV Dummy Album Title', @tag.album
60
+ assert_equal 'WAV Dummy Comment', @tag.comment
61
+ assert_equal 'Jazz', @tag.genre
61
62
  assert_equal 2014, @tag.year
62
63
  assert_equal 5, @tag.track
63
64
  assert_equal false, @tag.empty?
64
65
  end
65
66
 
66
- context "APIC frame" do
67
+ context 'APIC frame' do
67
68
  setup do
68
69
  @picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
69
70
  @apic = @tag.frame_list('APIC').first
70
71
  end
71
72
 
72
- should "exist" do
73
+ should 'exist' do
73
74
  assert_not_nil @apic
74
75
  assert_equal TagLib::ID3v2::AttachedPictureFrame, @apic.class
75
76
  end
76
77
 
77
- should "have a type" do
78
+ should 'have a type' do
78
79
  assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
79
80
  end
80
81
 
81
- should "have a mime type" do
82
- assert_equal "image/jpeg", @apic.mime_type
82
+ should 'have a mime type' do
83
+ assert_equal 'image/jpeg', @apic.mime_type
83
84
  end
84
85
 
85
- should "have picture bytes" do
86
- assert_equal 61649, @apic.picture.size
86
+ should 'have picture bytes' do
87
+ assert_equal 61_649, @apic.picture.size
87
88
  assert_equal @picture_data, @apic.picture
88
89
  end
89
90
  end
@@ -95,14 +96,13 @@ class WAVFileTest < Test::Unit::TestCase
95
96
  end
96
97
  end
97
98
 
98
- context "TagLib::RIFF::WAV::File.open" do
99
- should "have open method" do
99
+ context 'TagLib::RIFF::WAV::File.open' do
100
+ should 'have open method' do
100
101
  title = nil
101
102
  TagLib::RIFF::WAV::File.open(SAMPLE_FILE, false) do |file|
102
103
  title = file.tag.title
103
104
  end
104
- assert_equal "WAV Dummy Track Title", title
105
+ assert_equal 'WAV Dummy Track Title', title
105
106
  end
106
107
  end
107
-
108
108
  end