taglib-ruby 0.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +7 -0
  3. data/README.md +25 -10
  4. data/Rakefile +11 -1
  5. data/docs/taglib/aiff.rb +35 -3
  6. data/docs/taglib/base.rb +8 -1
  7. data/docs/taglib/flac.rb +60 -4
  8. data/docs/taglib/id3v1.rb +29 -0
  9. data/docs/taglib/id3v2.rb +1 -1
  10. data/docs/taglib/mp4.rb +124 -13
  11. data/docs/taglib/mpeg.rb +30 -1
  12. data/docs/taglib/ogg.rb +47 -5
  13. data/docs/taglib/vorbis.rb +1 -1
  14. data/docs/taglib/wav.rb +56 -3
  15. data/ext/extconf_common.rb +9 -2
  16. data/ext/taglib_aiff/taglib_aiff.i +16 -0
  17. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +228 -58
  18. data/ext/taglib_base/includes.i +4 -4
  19. data/ext/taglib_base/taglib_base.i +24 -2
  20. data/ext/taglib_base/taglib_base_wrap.cxx +76 -51
  21. data/ext/taglib_flac/taglib_flac.i +14 -18
  22. data/ext/taglib_flac/taglib_flac_wrap.cxx +341 -799
  23. data/ext/taglib_flac_picture/extconf.rb +4 -0
  24. data/ext/taglib_flac_picture/includes.i +15 -0
  25. data/ext/taglib_flac_picture/taglib_flac_picture.i +15 -0
  26. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +3087 -0
  27. data/ext/taglib_id3v1/taglib_id3v1.i +19 -0
  28. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +241 -58
  29. data/ext/taglib_id3v2/taglib_id3v2.i +52 -1
  30. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +152 -155
  31. data/ext/taglib_mp4/taglib_mp4.i +100 -19
  32. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +939 -148
  33. data/ext/taglib_mpeg/taglib_mpeg.i +11 -16
  34. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +522 -208
  35. data/ext/taglib_ogg/taglib_ogg.i +11 -0
  36. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +328 -57
  37. data/ext/taglib_vorbis/taglib_vorbis.i +8 -0
  38. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +53 -22
  39. data/ext/taglib_wav/taglib_wav.i +24 -0
  40. data/ext/taglib_wav/taglib_wav_wrap.cxx +543 -198
  41. data/lib/taglib/mp4.rb +2 -1
  42. data/lib/taglib/version.rb +3 -3
  43. data/lib/taglib/wav.rb +4 -0
  44. data/taglib-ruby.gemspec +15 -9
  45. data/tasks/ext.rake +36 -15
  46. data/tasks/swig.rake +26 -2
  47. data/test/aiff_examples_test.rb +1 -1
  48. data/test/aiff_file_test.rb +12 -3
  49. data/test/data/vorbis-create.cpp +20 -1
  50. data/test/data/vorbis.oga +0 -0
  51. data/test/fileref_properties_test.rb +1 -1
  52. data/test/flac_file_test.rb +45 -30
  53. data/test/id3v1_genres_test.rb +23 -0
  54. data/test/id3v1_tag_test.rb +1 -0
  55. data/test/id3v2_tag_test.rb +6 -6
  56. data/test/id3v2_write_test.rb +10 -13
  57. data/test/mp4_file_test.rb +33 -4
  58. data/test/mp4_file_write_test.rb +5 -5
  59. data/test/mp4_items_test.rb +83 -29
  60. data/test/mpeg_file_test.rb +120 -7
  61. data/test/vorbis_file_test.rb +2 -2
  62. data/test/vorbis_tag_test.rb +61 -7
  63. data/test/wav_examples_test.rb +1 -1
  64. data/test/wav_file_test.rb +53 -41
  65. data/test/wav_file_write_test.rb +25 -0
  66. metadata +19 -9
@@ -22,8 +22,8 @@ class TestVorbisFile < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  should "contain basic information" do
25
- assert_equal 0, @properties.length # file is short
26
- assert_equal 64, @properties.bitrate
25
+ assert_equal 0, @properties.length_in_seconds # file is short
26
+ assert_equal 371, @properties.bitrate
27
27
  assert_equal 44100, @properties.sample_rate
28
28
  assert_equal 2, @properties.channels
29
29
  end
@@ -11,6 +11,7 @@ class TestVorbisTag < Test::Unit::TestCase
11
11
  assert_equal "Title", @tag.title
12
12
  assert_equal "Artist", @tag.artist
13
13
  assert_equal "Album", @tag.album
14
+ # Use DESCRIPTION if it exists, otherwise COMMENT.
14
15
  assert_equal "Test file", @tag.comment
15
16
  assert_equal "Pop", @tag.genre
16
17
  assert_equal 2011, @tag.year
@@ -24,7 +25,7 @@ class TestVorbisTag < Test::Unit::TestCase
24
25
  end
25
26
 
26
27
  should "have field_count" do
27
- assert_equal 16, @tag.field_count
28
+ assert_equal 18, @tag.field_count
28
29
  end
29
30
 
30
31
  should "have vendor_id" do
@@ -61,14 +62,58 @@ class TestVorbisTag < Test::Unit::TestCase
61
62
  assert_equal ["Title", "Additional Title"], @tag.field_list_map['TITLE']
62
63
  end
63
64
 
64
- should "support remove_field with value" do
65
- @tag.remove_field('MULTIPLE', "A")
66
- assert_equal ["B"], @tag.field_list_map['MULTIPLE']
65
+ should "support remove_fields" do
66
+ assert @tag.contains?('MULTIPLE')
67
+ @tag.remove_fields('MULTIPLE')
68
+ refute @tag.contains?('MULTIPLE')
67
69
  end
68
70
 
69
- should "support remove_field without value" do
70
- @tag.remove_field('MULTIPLE')
71
- assert !@tag.contains?('MULTIPLE')
71
+ should "support remove_all_fields" do
72
+ refute_equal 0, @tag.field_count
73
+ @tag.remove_all_fields()
74
+ # remove_all_fields() do not remove pictures
75
+ assert_equal 1, @tag.field_count
76
+ end
77
+
78
+ should "have pictures" do
79
+ refute_empty @tag.picture_list
80
+ end
81
+
82
+ context "first picture" do
83
+ setup do
84
+ @picture = @tag.picture_list.first
85
+ end
86
+
87
+ should "be a TagLib::FLAC::Picture," do
88
+ assert_equal TagLib::FLAC::Picture, @picture.class
89
+ end
90
+
91
+ should "have meta-data" do
92
+ 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 90, @picture.width
96
+ assert_equal 90, @picture.height
97
+ assert_equal 24, @picture.color_depth
98
+ assert_equal 0, @picture.num_colors
99
+ end
100
+
101
+ should "have data" do
102
+ picture_data = File.open("test/data/globe_east_90.jpg", 'rb'){ |f| f.read }
103
+ assert_equal picture_data, @picture.data
104
+ end
105
+ end
106
+
107
+ should "support removing a picture" do
108
+ refute_empty @tag.picture_list
109
+ @tag.remove_picture(@tag.picture_list.first)
110
+ assert_empty @tag.picture_list
111
+ end
112
+
113
+ should "support removing all pictures" do
114
+ refute_empty @tag.picture_list
115
+ @tag.remove_all_pictures()
116
+ assert_empty @tag.picture_list
72
117
  end
73
118
 
74
119
  teardown do
@@ -76,4 +121,13 @@ class TestVorbisTag < Test::Unit::TestCase
76
121
  @file = nil
77
122
  end
78
123
  end
124
+
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")
131
+ end
132
+ end
79
133
  end
@@ -18,7 +18,7 @@ class WAVExamples < Test::Unit::TestCase
18
18
  # Reading WAV-specific audio properties
19
19
 
20
20
  TagLib::RIFF::WAV::File.open("#{DATA_FILE_PREFIX}sample.wav") do |file|
21
- file.audio_properties.sample_width #=> 8
21
+ file.audio_properties.sample_rate #=> 8
22
22
  end
23
23
 
24
24
  # Saving ID3v2 cover-art to disk
@@ -8,72 +8,84 @@ class WAVFileTest < Test::Unit::TestCase
8
8
  context "TagLib::RIFF::WAV::File" do
9
9
  setup do
10
10
  @file = TagLib::RIFF::WAV::File.new(SAMPLE_FILE)
11
- @tag = @file.tag
12
11
  end
13
12
 
14
13
  should "open" do
15
14
  assert_not_nil @file
16
15
  end
17
16
 
18
- should "have an ID3v2 tag" do
19
- assert_not_nil @tag
20
- assert_equal TagLib::ID3v2::Tag, @tag.class
21
- end
22
-
23
- should "contain basic tag information" do
24
- assert_equal "WAV Dummy Track Title", @tag.title
25
- assert_equal "WAV Dummy Artist Name", @tag.artist
26
- assert_equal "WAV Dummy Album Title", @tag.album
27
- assert_equal "WAV Dummy Comment", @tag.comment
28
- assert_equal "Jazz", @tag.genre
29
- assert_equal 2014, @tag.year
30
- assert_equal 5, @tag.track
31
- assert_equal false, @tag.empty?
32
- end
33
-
34
- context "APIC frame" do
17
+ context "audio properties" do
35
18
  setup do
36
- @picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
37
- @apic = @tag.frame_list('APIC').first
19
+ @properties = @file.audio_properties
38
20
  end
39
21
 
40
22
  should "exist" do
41
- assert_not_nil @apic
42
- assert_equal TagLib::ID3v2::AttachedPictureFrame, @apic.class
43
- end
44
-
45
- should "have a type" do
46
- assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
23
+ assert_not_nil @properties
47
24
  end
48
25
 
49
- should "have a mime type" do
50
- assert_equal "image/jpeg", @apic.mime_type
26
+ should "contain basic information" do
27
+ assert_equal 0, @properties.length_in_seconds
28
+ assert_equal 698, @properties.length_in_milliseconds
29
+ assert_equal 88, @properties.bitrate
30
+ assert_equal 11025, @properties.sample_rate
31
+ assert_equal 1, @properties.channels
51
32
  end
52
33
 
53
- should "have picture bytes" do
54
- assert_equal 61649, @apic.picture.size
55
- assert_equal @picture_data, @apic.picture
34
+ should "contain WAV-specific information" do
35
+ assert_equal 8, @properties.bits_per_sample
36
+ assert_equal TagLib::RIFF::WAV::FORMAT_PCM, @properties.format
56
37
  end
57
38
  end
58
39
 
59
- context "audio properties" do
40
+ context "ID3V2 tag" do
60
41
  setup do
61
- @properties = @file.audio_properties
42
+ @tag = @file.tag
62
43
  end
63
44
 
64
45
  should "exist" do
65
- assert_not_nil @properties
46
+ assert @file.id3v2_tag?
47
+ assert_not_nil @tag
48
+ assert_equal TagLib::ID3v2::Tag, @tag.class
66
49
  end
67
50
 
68
- should "contain basic information" do
69
- assert_equal 0, @properties.length
70
- assert_equal 88, @properties.bitrate
71
- assert_equal 11025, @properties.sample_rate
72
- assert_equal 1, @properties.channels
51
+ should "not have an Info tag" do
52
+ refute @file.info_tag?
73
53
  end
74
54
 
75
- should "contain WAV-specific information" do
76
- assert_equal 8, @properties.sample_width
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
61
+ assert_equal 2014, @tag.year
62
+ assert_equal 5, @tag.track
63
+ assert_equal false, @tag.empty?
64
+ end
65
+
66
+ context "APIC frame" do
67
+ setup do
68
+ @picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
69
+ @apic = @tag.frame_list('APIC').first
70
+ end
71
+
72
+ should "exist" do
73
+ assert_not_nil @apic
74
+ assert_equal TagLib::ID3v2::AttachedPictureFrame, @apic.class
75
+ end
76
+
77
+ should "have a type" do
78
+ assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
79
+ end
80
+
81
+ should "have a mime type" do
82
+ assert_equal "image/jpeg", @apic.mime_type
83
+ end
84
+
85
+ should "have picture bytes" do
86
+ assert_equal 61649, @apic.picture.size
87
+ assert_equal @picture_data, @apic.picture
88
+ end
77
89
  end
78
90
  end
79
91
 
@@ -85,4 +85,29 @@ class WAVFileWriteTest < Test::Unit::TestCase
85
85
  FileUtils.rm OUTPUT_FILE
86
86
  end
87
87
  end
88
+
89
+ context "TagLib::RIFF::WAV::File.strip" do
90
+ setup do
91
+ FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
92
+ @file = TagLib::RIFF::WAV::File.new(OUTPUT_FILE)
93
+ end
94
+
95
+ should "update the file immediately" do
96
+ assert @file.id3v2_tag?
97
+
98
+ @file.strip(TagLib::RIFF::WAV::File::ID3v2)
99
+
100
+ reloaded do |file|
101
+ refute @file.id3v2_tag?
102
+ end
103
+ end
104
+
105
+ teardown do
106
+ if @file
107
+ @file.close
108
+ @file = nil
109
+ end
110
+ FileUtils.rm OUTPUT_FILE
111
+ end
112
+ end
88
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taglib-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Stocker
@@ -10,22 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-28 00:00:00.000000000 Z
13
+ date: 2020-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.2'
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '3'
22
25
  type: :development
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
27
30
  - !ruby/object:Gem::Version
28
31
  version: '1.2'
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '3'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: rake-compiler
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +66,14 @@ dependencies:
60
66
  requirements:
61
67
  - - "~>"
62
68
  - !ruby/object:Gem::Version
63
- version: '0.7'
69
+ version: 0.9.12
64
70
  type: :development
65
71
  prerelease: false
66
72
  version_requirements: !ruby/object:Gem::Requirement
67
73
  requirements:
68
74
  - - "~>"
69
75
  - !ruby/object:Gem::Version
70
- version: '0.7'
76
+ version: 0.9.12
71
77
  - !ruby/object:Gem::Dependency
72
78
  name: kramdown
73
79
  requirement: !ruby/object:Gem::Requirement
@@ -113,6 +119,7 @@ extensions:
113
119
  - ext/taglib_ogg/extconf.rb
114
120
  - ext/taglib_vorbis/extconf.rb
115
121
  - ext/taglib_flac/extconf.rb
122
+ - ext/taglib_flac_picture/extconf.rb
116
123
  - ext/taglib_mp4/extconf.rb
117
124
  - ext/taglib_aiff/extconf.rb
118
125
  - ext/taglib_wav/extconf.rb
@@ -151,6 +158,10 @@ files:
151
158
  - ext/taglib_flac/extconf.rb
152
159
  - ext/taglib_flac/taglib_flac.i
153
160
  - ext/taglib_flac/taglib_flac_wrap.cxx
161
+ - ext/taglib_flac_picture/extconf.rb
162
+ - ext/taglib_flac_picture/includes.i
163
+ - ext/taglib_flac_picture/taglib_flac_picture.i
164
+ - ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx
154
165
  - ext/taglib_id3v1/extconf.rb
155
166
  - ext/taglib_id3v1/taglib_id3v1.i
156
167
  - ext/taglib_id3v1/taglib_id3v1_wrap.cxx
@@ -224,6 +235,7 @@ files:
224
235
  - test/flac_file_test.rb
225
236
  - test/flac_file_write_test.rb
226
237
  - test/helper.rb
238
+ - test/id3v1_genres_test.rb
227
239
  - test/id3v1_tag_test.rb
228
240
  - test/id3v2_frames_test.rb
229
241
  - test/id3v2_header_test.rb
@@ -264,10 +276,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
276
  version: '0'
265
277
  requirements:
266
278
  - taglib (libtag1-dev in Debian/Ubuntu, taglib-devel in Fedora/RHEL)
267
- rubyforge_project:
268
- rubygems_version: 2.5.1
279
+ rubygems_version: 3.0.3
269
280
  signing_key:
270
281
  specification_version: 4
271
282
  summary: Ruby interface for the taglib C++ library
272
283
  test_files: []
273
- has_rdoc: