taglib-ruby 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +9 -0
  3. data/README.md +40 -9
  4. data/Rakefile +1 -2
  5. data/docs/taglib/aiff.rb +63 -0
  6. data/docs/taglib/base.rb +22 -1
  7. data/docs/taglib/id3v2.rb +21 -2
  8. data/docs/taglib/riff.rb +3 -0
  9. data/docs/taglib/wav.rb +63 -0
  10. data/ext/extconf_common.rb +15 -1
  11. data/ext/taglib_aiff/extconf.rb +4 -0
  12. data/ext/taglib_aiff/taglib_aiff.i +68 -0
  13. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +2920 -0
  14. data/ext/taglib_base/includes.i +7 -2
  15. data/ext/taglib_base/taglib_base_wrap.cxx +109 -115
  16. data/ext/taglib_flac/taglib_flac_wrap.cxx +108 -114
  17. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +109 -115
  18. data/ext/taglib_id3v2/taglib_id3v2.i +3 -1
  19. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +139 -119
  20. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +109 -115
  21. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +108 -114
  22. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +109 -115
  23. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +108 -114
  24. data/ext/taglib_wav/extconf.rb +4 -0
  25. data/ext/taglib_wav/taglib_wav.i +66 -0
  26. data/ext/taglib_wav/taglib_wav_wrap.cxx +3057 -0
  27. data/lib/taglib.rb +2 -0
  28. data/lib/taglib/aiff.rb +7 -0
  29. data/lib/taglib/version.rb +1 -1
  30. data/lib/taglib/wav.rb +7 -0
  31. data/taglib-ruby.gemspec +27 -2
  32. data/tasks/ext.rake +17 -10
  33. data/tasks/swig.rake +10 -0
  34. data/test/aiff_examples_test.rb +39 -0
  35. data/test/aiff_file_test.rb +94 -0
  36. data/test/aiff_file_write_test.rb +88 -0
  37. data/test/data/Makefile +8 -2
  38. data/test/data/aiff-sample.aiff +0 -0
  39. data/test/data/wav-create.cpp +55 -0
  40. data/test/data/wav-dump.cpp +74 -0
  41. data/test/data/wav-sample.wav +0 -0
  42. data/test/file_test.rb +21 -0
  43. data/test/id3v2_unknown_frames_test.rb +30 -0
  44. data/test/wav_examples_test.rb +42 -0
  45. data/test/wav_file_test.rb +96 -0
  46. data/test/wav_file_write_test.rb +88 -0
  47. metadata +49 -45
@@ -14,3 +14,5 @@ require 'taglib/ogg'
14
14
  require 'taglib/vorbis'
15
15
  require 'taglib/flac'
16
16
  require 'taglib/mp4'
17
+ require 'taglib/aiff'
18
+ require 'taglib/wav'
@@ -0,0 +1,7 @@
1
+ require 'taglib_aiff'
2
+
3
+ module TagLib::RIFF::AIFF
4
+ class File
5
+ extend ::TagLib::FileOpenable
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  module TagLib
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 6
4
+ MINOR = 7
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -0,0 +1,7 @@
1
+ require 'taglib_wav'
2
+
3
+ module TagLib::RIFF::WAV
4
+ class File
5
+ extend ::TagLib::FileOpenable
6
+ end
7
+ end
@@ -7,7 +7,7 @@ require 'taglib/version'
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "taglib-ruby"
9
9
  s.version = TagLib::Version::STRING
10
- s.authors = ["Robin Stocker", "Jacob Vosmaer"]
10
+ s.authors = ["Robin Stocker", "Jacob Vosmaer", "Thomas Chevereau"]
11
11
  s.email = ["robin@nibor.org"]
12
12
  s.homepage = "http://robinst.github.io/taglib-ruby/"
13
13
  s.licenses = ["MIT"]
@@ -24,7 +24,7 @@ DESC
24
24
  s.requirements = ["taglib (libtag1-dev in Debian/Ubuntu, taglib-devel in Fedora/RHEL)"]
25
25
 
26
26
  s.add_development_dependency 'bundler', '~> 1.2'
27
- s.add_development_dependency 'rake-compiler', '~> 0.8'
27
+ s.add_development_dependency 'rake-compiler', '~> 0.9'
28
28
  s.add_development_dependency 'shoulda-context', '~> 1.0'
29
29
  s.add_development_dependency 'yard', '~> 0.7'
30
30
  s.add_development_dependency 'kramdown', '~> 1.0'
@@ -38,6 +38,8 @@ DESC
38
38
  "ext/taglib_vorbis/extconf.rb",
39
39
  "ext/taglib_flac/extconf.rb",
40
40
  "ext/taglib_mp4/extconf.rb",
41
+ "ext/taglib_aiff/extconf.rb",
42
+ "ext/taglib_wav/extconf.rb",
41
43
  ]
42
44
  s.extra_rdoc_files = [
43
45
  "CHANGES.md",
@@ -53,6 +55,7 @@ DESC
53
55
  "README.md",
54
56
  "Rakefile",
55
57
  "docs/default/fulldoc/html/css/common.css",
58
+ "docs/taglib/aiff.rb",
56
59
  "docs/taglib/base.rb",
57
60
  "docs/taglib/flac.rb",
58
61
  "docs/taglib/id3v1.rb",
@@ -60,8 +63,13 @@ DESC
60
63
  "docs/taglib/mp4.rb",
61
64
  "docs/taglib/mpeg.rb",
62
65
  "docs/taglib/ogg.rb",
66
+ "docs/taglib/riff.rb",
63
67
  "docs/taglib/vorbis.rb",
68
+ "docs/taglib/wav.rb",
64
69
  "ext/extconf_common.rb",
70
+ "ext/taglib_aiff/extconf.rb",
71
+ "ext/taglib_aiff/taglib_aiff.i",
72
+ "ext/taglib_aiff/taglib_aiff_wrap.cxx",
65
73
  "ext/taglib_base/extconf.rb",
66
74
  "ext/taglib_base/includes.i",
67
75
  "ext/taglib_base/taglib_base.i",
@@ -88,9 +96,13 @@ DESC
88
96
  "ext/taglib_vorbis/extconf.rb",
89
97
  "ext/taglib_vorbis/taglib_vorbis.i",
90
98
  "ext/taglib_vorbis/taglib_vorbis_wrap.cxx",
99
+ "ext/taglib_wav/extconf.rb",
100
+ "ext/taglib_wav/taglib_wav.i",
101
+ "ext/taglib_wav/taglib_wav_wrap.cxx",
91
102
  "ext/valgrind-suppressions.txt",
92
103
  "ext/win.cmake",
93
104
  "lib/taglib.rb",
105
+ "lib/taglib/aiff.rb",
94
106
  "lib/taglib/base.rb",
95
107
  "lib/taglib/flac.rb",
96
108
  "lib/taglib/id3v1.rb",
@@ -100,6 +112,7 @@ DESC
100
112
  "lib/taglib/ogg.rb",
101
113
  "lib/taglib/version.rb",
102
114
  "lib/taglib/vorbis.rb",
115
+ "lib/taglib/wav.rb",
103
116
  "taglib-ruby.gemspec",
104
117
  "tasks/docs_coverage.rake",
105
118
  "tasks/ext.rake",
@@ -107,6 +120,7 @@ DESC
107
120
  "tasks/swig.rake",
108
121
  "test/base_test.rb",
109
122
  "test/data/Makefile",
123
+ "test/data/aiff-sample.aiff",
110
124
  "test/data/add-relative-volume.cpp",
111
125
  "test/data/crash.mp3",
112
126
  "test/data/flac-create.cpp",
@@ -123,10 +137,17 @@ DESC
123
137
  "test/data/unicode.mp3",
124
138
  "test/data/vorbis-create.cpp",
125
139
  "test/data/vorbis.oga",
140
+ "test/data/wav-create.cpp",
141
+ "test/data/wav-dump.cpp",
142
+ "test/data/wav-sample.wav",
143
+ "test/aiff_examples_test.rb",
144
+ "test/aiff_file_test.rb",
145
+ "test/aiff_file_write_test.rb",
126
146
  "test/helper.rb",
127
147
  "test/fileref_open_test.rb",
128
148
  "test/fileref_properties_test.rb",
129
149
  "test/fileref_write_test.rb",
150
+ "test/file_test.rb",
130
151
  "test/flac_file_test.rb",
131
152
  "test/flac_file_write_test.rb",
132
153
  "test/id3v1_tag_test.rb",
@@ -136,6 +157,7 @@ DESC
136
157
  "test/id3v2_relative_volume_test.rb",
137
158
  "test/id3v2_tag_test.rb",
138
159
  "test/id3v2_unicode_test.rb",
160
+ "test/id3v2_unknown_frames_test.rb",
139
161
  "test/id3v2_write_test.rb",
140
162
  "test/mp4_file_test.rb",
141
163
  "test/mp4_file_write_test.rb",
@@ -145,5 +167,8 @@ DESC
145
167
  "test/unicode_filename_test.rb",
146
168
  "test/vorbis_file_test.rb",
147
169
  "test/vorbis_tag_test.rb",
170
+ "test/wav_examples_test.rb",
171
+ "test/wav_file_test.rb",
172
+ "test/wav_file_write_test.rb",
148
173
  ]
149
174
  end
@@ -1,23 +1,23 @@
1
1
  # Extension tasks and cross-compiling
2
2
 
3
3
  host = 'i686-w64-mingw32'
4
- plat = 'x86-mingw32'
4
+ $plat = 'i386-mingw32'
5
5
 
6
- tmp = "#{Dir.pwd}/tmp/#{plat}"
6
+ tmp = "#{Dir.pwd}/tmp/#{$plat}"
7
7
  toolchain_file = "#{Dir.pwd}/ext/win.cmake"
8
8
  install_dir = "#{tmp}/install"
9
9
  install_dll = "#{install_dir}/bin/libtag.dll"
10
- ldflags = "-static-libgcc -static-libstdc++"
11
- $cross_config_options = [%(--with-opt-dir=#{install_dir} --with-ldflags="#{ldflags}")]
10
+ $cross_config_options = ["--with-opt-dir=#{install_dir}"]
12
11
 
13
- taglib_version = '1.8'
12
+ taglib_version = '1.9.1'
14
13
  taglib = "taglib-#{taglib_version}"
15
- taglib_url = "http://cloud.github.com/downloads/taglib/taglib/#{taglib}.tar.gz"
14
+ taglib_url = "https://github.com/taglib/taglib/releases/download/v#{taglib_version}/#{taglib}.tar.gz"
16
15
  # WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8
17
16
  taglib_options = "-DCMAKE_BUILD_TYPE=Release -DWITH_MP4=ON -DWITH_ASF=ON"
18
17
 
19
18
  def configure_cross_compile(ext)
20
19
  ext.cross_compile = true
20
+ ext.cross_platform = $plat
21
21
  ext.cross_config_options.concat($cross_config_options)
22
22
  ext.cross_compiling do |gem|
23
23
  gem.files << "lib/libtag.dll"
@@ -49,19 +49,26 @@ end
49
49
  Rake::ExtensionTask.new("taglib_mp4", $gemspec) do |ext|
50
50
  configure_cross_compile(ext)
51
51
  end
52
+ Rake::ExtensionTask.new("taglib_aiff", $gemspec) do |ext|
53
+ configure_cross_compile(ext)
54
+ end
55
+ Rake::ExtensionTask.new("taglib_wav", $gemspec) do |ext|
56
+ configure_cross_compile(ext)
57
+ end
52
58
 
53
- task :cross => [:taglib] do
59
+ task :cross do
54
60
  # Mkmf just uses "g++" as C++ compiler, despite what's in rbconfig.rb.
55
61
  # So, we need to hack around it by setting CXX to the cross compiler.
56
62
  ENV["CXX"] = "#{host}-g++"
57
- install install_dll, "lib/"
58
63
  end
59
64
 
60
- task :taglib => [install_dll]
65
+ file "tmp/#{$plat}/stage/lib/libtag.dll" => [install_dll] do |f|
66
+ install install_dll, f
67
+ end
61
68
 
62
69
  file install_dll => ["#{tmp}/#{taglib}"] do
63
70
  chdir "#{tmp}/#{taglib}" do
64
- sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} -DCMAKE_SHARED_LINKER_FLAGS="#{ldflags}" #{taglib_options})
71
+ sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} #{taglib_options})
65
72
  sh "make VERBOSE=1"
66
73
  sh "make install"
67
74
  end
@@ -17,6 +17,8 @@ task :swig =>
17
17
  'ext/taglib_vorbis/taglib_vorbis_wrap.cxx',
18
18
  'ext/taglib_flac/taglib_flac_wrap.cxx',
19
19
  'ext/taglib_mp4/taglib_mp4_wrap.cxx',
20
+ 'ext/taglib_aiff/taglib_aiff_wrap.cxx',
21
+ 'ext/taglib_wav/taglib_wav_wrap.cxx',
20
22
  ]
21
23
 
22
24
  base_dependencies = ['ext/taglib_base/taglib_base.i', 'ext/taglib_base/includes.i']
@@ -52,3 +54,11 @@ end
52
54
  file 'ext/taglib_mp4/taglib_mp4_wrap.cxx' => ['ext/taglib_mp4/taglib_mp4.i'] + base_dependencies do
53
55
  run_swig('taglib_mp4')
54
56
  end
57
+
58
+ file 'ext/taglib_aiff/taglib_aiff_wrap.cxx' => ['ext/taglib_aiff/taglib_aiff.i'] + base_dependencies do
59
+ run_swig('taglib_aiff')
60
+ end
61
+
62
+ file 'ext/taglib_wav/taglib_wav_wrap.cxx' => ['ext/taglib_wav/taglib_wav.i'] + base_dependencies do
63
+ run_swig('taglib_wav')
64
+ end
@@ -0,0 +1,39 @@
1
+ require File.join(File.dirname(__FILE__), 'helper')
2
+
3
+ class AIFFExamples < Test::Unit::TestCase
4
+
5
+ DATA_FILE_PREFIX = "test/data/aiff-"
6
+
7
+ context "TagLib::RIFF::AIFF::File" do
8
+
9
+ should "Run TagLib::RIFF::AIFF::File examples" do
10
+
11
+
12
+ # @example Reading the title
13
+ title = TagLib::RIFF::AIFF::File.open("#{DATA_FILE_PREFIX}sample.aiff") do |file|
14
+ file.tag.title
15
+ end
16
+
17
+ # @example Reading AIFF-specific audio properties
18
+ TagLib::RIFF::AIFF::File.open("#{DATA_FILE_PREFIX}sample.aiff") do |file|
19
+ file.audio_properties.sample_width #=> 16
20
+ end
21
+
22
+ # @example Saving ID3v2 cover-art to disk
23
+ TagLib::RIFF::AIFF::File.open("#{DATA_FILE_PREFIX}sample.aiff") do |file|
24
+ id3v2_tag = file.tag
25
+ cover = id3v2_tag.frame_list('APIC').first
26
+ ext = cover.mime_type.rpartition('/')[2]
27
+ File.open("#{DATA_FILE_PREFIX}cover-art.#{ext}", "wb") { |f| f.write cover.picture }
28
+ end
29
+
30
+
31
+ # checks
32
+ assert_equal "AIFF Dummy Track Title - ID3v2.4", title
33
+ assert_equal true, File.exist?("#{DATA_FILE_PREFIX}cover-art.jpeg")
34
+ FileUtils.rm("#{DATA_FILE_PREFIX}cover-art.jpeg")
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,94 @@
1
+ require File.join(File.dirname(__FILE__), 'helper')
2
+
3
+ class AIFFFileTest < Test::Unit::TestCase
4
+
5
+ SAMPLE_FILE = "test/data/aiff-sample.aiff"
6
+ PICTURE_FILE = "test/data/globe_east_540.jpg"
7
+
8
+ context "TagLib::RIFF::AIFF::File" do
9
+ setup do
10
+ @file = TagLib::RIFF::AIFF::File.new(SAMPLE_FILE)
11
+ @tag = @file.tag
12
+ File.open(PICTURE_FILE, "rb") do |f|
13
+ @picture_data = f.read
14
+ end
15
+ end
16
+
17
+ should "have an ID3v2 tag" do
18
+ assert_not_nil @tag
19
+ assert_equal TagLib::ID3v2::Tag, @tag.class
20
+ end
21
+
22
+ should "contain basic tag information" do
23
+ assert_equal "AIFF Dummy Track Title - ID3v2.4", @tag.title
24
+ assert_equal "AIFF Dummy Artist Name", @tag.artist
25
+ assert_equal "AIFF Dummy Album Title", @tag.album
26
+ assert_equal "AIFF Dummy Comment", @tag.comment
27
+ assert_equal "Jazz", @tag.genre
28
+ assert_equal 2014, @tag.year
29
+ assert_equal 3, @tag.track
30
+ assert_equal false, @tag.empty?
31
+ end
32
+
33
+ context "APIC frame" do
34
+ setup do
35
+ @apic = @tag.frame_list('APIC').first
36
+ end
37
+
38
+ should "exist" do
39
+ assert_not_nil @apic
40
+ assert_equal TagLib::ID3v2::AttachedPictureFrame, @apic.class
41
+ end
42
+
43
+ should "have a type" do
44
+ assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
45
+ end
46
+
47
+ should "have a mime type" do
48
+ assert_equal "image/jpeg", @apic.mime_type
49
+ end
50
+
51
+ should "have picture bytes" do
52
+ assert_equal 61649, @apic.picture.size
53
+ assert_equal @picture_data, @apic.picture
54
+ end
55
+ end
56
+
57
+ context "audio properties" do
58
+ setup do
59
+ @properties = @file.audio_properties
60
+ end
61
+
62
+ should "exist" do
63
+ assert_not_nil @properties
64
+ end
65
+
66
+ should "contain basic information" do
67
+ assert_equal 2, @properties.length
68
+ assert_equal 256, @properties.bitrate
69
+ assert_equal 8000, @properties.sample_rate
70
+ assert_equal 2, @properties.channels
71
+ end
72
+
73
+ should "contain AIFF-specific information" do
74
+ assert_equal 16, @properties.sample_width
75
+ end
76
+ end
77
+
78
+ teardown do
79
+ @file.close
80
+ @file = nil
81
+ end
82
+ end
83
+
84
+ context "TagLib::RIFF::AIFF::File.open" do
85
+ should "have open method" do
86
+ title = nil
87
+ TagLib::RIFF::AIFF::File.open(SAMPLE_FILE, false) do |file|
88
+ title = file.tag.title
89
+ end
90
+ assert_equal "AIFF Dummy Track Title - ID3v2.4", title
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,88 @@
1
+ require File.join(File.dirname(__FILE__), 'helper')
2
+
3
+ class AIFFFileWriteTest < Test::Unit::TestCase
4
+
5
+ SAMPLE_FILE = "test/data/aiff-sample.aiff"
6
+ OUTPUT_FILE = "test/data/_output.aiff"
7
+ PICTURE_FILE = "test/data/globe_east_90.jpg"
8
+
9
+ def reloaded
10
+ TagLib::RIFF::AIFF::File.open(OUTPUT_FILE, false) do |file|
11
+ yield file
12
+ end
13
+ end
14
+
15
+ context "TagLib::RIFF::AIFF::File" do
16
+ setup do
17
+ FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
18
+ @file = TagLib::RIFF::AIFF::File.new(OUTPUT_FILE, false)
19
+ end
20
+
21
+ should "be able to save the title" do
22
+ tag = @file.tag
23
+ assert_not_nil tag
24
+ tag.title = "New Title"
25
+ success = @file.save
26
+ assert success
27
+ @file.close
28
+ @file = nil
29
+
30
+ written_title = reloaded do |file|
31
+ file.tag.title
32
+ end
33
+ assert_equal "New Title", written_title
34
+ end
35
+
36
+ should "have one picture frame" do
37
+ assert_equal 1, @file.tag.frame_list('APIC').size
38
+ end
39
+
40
+ should "be able to remove all picture frames" do
41
+ @file.tag.remove_frames('APIC')
42
+ success = @file.save
43
+ assert success
44
+ @file.close
45
+ @file = nil
46
+
47
+ reloaded do |file|
48
+ assert_equal 0, file.tag.frame_list('APIC').size
49
+ end
50
+ end
51
+
52
+ should "be able to add a picture frame" do
53
+ picture_data = File.open(PICTURE_FILE, 'rb') { |f| f.read }
54
+
55
+ apic = TagLib::ID3v2::AttachedPictureFrame.new
56
+ apic.mime_type = "image/jpeg"
57
+ apic.description = "desc"
58
+ apic.text_encoding = TagLib::String::UTF8
59
+ apic.picture = picture_data
60
+ apic.type = TagLib::ID3v2::AttachedPictureFrame::BackCover
61
+
62
+ @file.tag.add_frame(apic)
63
+ success = @file.save
64
+ assert success
65
+ @file.close
66
+ @file = nil
67
+
68
+ reloaded do |file|
69
+ assert_equal 2, file.tag.frame_list('APIC').size
70
+ end
71
+
72
+ reloaded do |file|
73
+ written_apic = file.tag.frame_list("APIC")[1]
74
+ assert_equal "image/jpeg", written_apic.mime_type
75
+ assert_equal "desc", written_apic.description
76
+ assert_equal picture_data, written_apic.picture
77
+ end
78
+ end
79
+
80
+ teardown do
81
+ if @file
82
+ @file.close
83
+ @file = nil
84
+ end
85
+ FileUtils.rm OUTPUT_FILE
86
+ end
87
+ end
88
+ end