taglib-ruby 0.6.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -1
  3. data/{CHANGES.md → CHANGELOG.md} +46 -11
  4. data/README.md +61 -17
  5. data/Rakefile +12 -3
  6. data/docs/taglib/aiff.rb +95 -0
  7. data/docs/taglib/base.rb +30 -2
  8. data/docs/taglib/flac.rb +60 -4
  9. data/docs/taglib/id3v1.rb +29 -0
  10. data/docs/taglib/id3v2.rb +22 -3
  11. data/docs/taglib/mp4.rb +124 -13
  12. data/docs/taglib/mpeg.rb +30 -1
  13. data/docs/taglib/ogg.rb +47 -5
  14. data/docs/taglib/riff.rb +3 -0
  15. data/docs/taglib/vorbis.rb +1 -1
  16. data/docs/taglib/wav.rb +116 -0
  17. data/ext/extconf_common.rb +24 -3
  18. data/ext/taglib_aiff/extconf.rb +4 -0
  19. data/ext/taglib_aiff/taglib_aiff.i +84 -0
  20. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +3111 -0
  21. data/ext/taglib_base/includes.i +34 -5
  22. data/ext/taglib_base/taglib_base.i +42 -2
  23. data/ext/taglib_base/taglib_base_wrap.cxx +226 -186
  24. data/ext/taglib_flac/taglib_flac.i +21 -18
  25. data/ext/taglib_flac/taglib_flac_wrap.cxx +519 -955
  26. data/ext/taglib_flac_picture/extconf.rb +4 -0
  27. data/ext/taglib_flac_picture/includes.i +15 -0
  28. data/ext/taglib_flac_picture/taglib_flac_picture.i +15 -0
  29. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +3087 -0
  30. data/ext/taglib_id3v1/taglib_id3v1.i +19 -0
  31. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +391 -193
  32. data/ext/taglib_id3v2/relativevolumeframe.i +4 -17
  33. data/ext/taglib_id3v2/taglib_id3v2.i +72 -2
  34. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +3051 -1113
  35. data/ext/taglib_mp4/taglib_mp4.i +101 -20
  36. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +1088 -282
  37. data/ext/taglib_mpeg/taglib_mpeg.i +11 -16
  38. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +646 -317
  39. data/ext/taglib_ogg/taglib_ogg.i +11 -0
  40. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +478 -192
  41. data/ext/taglib_vorbis/taglib_vorbis.i +8 -0
  42. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +202 -156
  43. data/ext/taglib_wav/extconf.rb +4 -0
  44. data/ext/taglib_wav/taglib_wav.i +90 -0
  45. data/ext/taglib_wav/taglib_wav_wrap.cxx +3423 -0
  46. data/lib/taglib.rb +2 -0
  47. data/lib/taglib/aiff.rb +7 -0
  48. data/lib/taglib/mp4.rb +2 -1
  49. data/lib/taglib/version.rb +2 -2
  50. data/lib/taglib/wav.rb +11 -0
  51. data/taglib-ruby.gemspec +42 -8
  52. data/tasks/ext.rake +48 -20
  53. data/tasks/gemspec_check.rake +1 -1
  54. data/tasks/swig.rake +36 -2
  55. data/test/aiff_examples_test.rb +39 -0
  56. data/test/aiff_file_test.rb +103 -0
  57. data/test/aiff_file_write_test.rb +88 -0
  58. data/test/data/Makefile +8 -2
  59. data/test/data/aiff-sample.aiff +0 -0
  60. data/test/data/flac_nopic.flac +0 -0
  61. data/test/data/vorbis-create.cpp +20 -1
  62. data/test/data/vorbis.oga +0 -0
  63. data/test/data/wav-create.cpp +55 -0
  64. data/test/data/wav-dump.cpp +74 -0
  65. data/test/data/wav-sample.wav +0 -0
  66. data/test/file_test.rb +21 -0
  67. data/test/fileref_properties_test.rb +1 -1
  68. data/test/flac_file_test.rb +45 -30
  69. data/test/flac_picture_memory_test.rb +43 -0
  70. data/test/id3v1_genres_test.rb +23 -0
  71. data/test/id3v1_tag_test.rb +1 -0
  72. data/test/id3v2_frames_test.rb +64 -0
  73. data/test/id3v2_tag_test.rb +6 -6
  74. data/test/id3v2_unknown_frames_test.rb +30 -0
  75. data/test/id3v2_write_test.rb +10 -13
  76. data/test/mp4_file_test.rb +33 -4
  77. data/test/mp4_file_write_test.rb +5 -5
  78. data/test/mp4_items_test.rb +83 -29
  79. data/test/mpeg_file_test.rb +120 -7
  80. data/test/vorbis_file_test.rb +2 -2
  81. data/test/vorbis_tag_test.rb +61 -7
  82. data/test/wav_examples_test.rb +42 -0
  83. data/test/wav_file_test.rb +108 -0
  84. data/test/wav_file_write_test.rb +113 -0
  85. metadata +86 -56
@@ -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
@@ -22,10 +22,11 @@ module TagLib::MP4
22
22
  end
23
23
  end
24
24
 
25
- class ItemListMap
25
+ class ItemMap
26
26
  alias :clear :_clear
27
27
  alias :insert :_insert
28
28
  alias :[] :fetch
29
+ alias :[]= :insert
29
30
  remove_method :_clear
30
31
  remove_method :_insert
31
32
 
@@ -1,7 +1,7 @@
1
1
  module TagLib
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 6
3
+ MAJOR = 1
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -0,0 +1,11 @@
1
+ require 'taglib_wav'
2
+
3
+ module TagLib::RIFF::WAV
4
+
5
+ FORMAT_UNKNOWN = 0x0000
6
+ FORMAT_PCM = 0x0001
7
+
8
+ class File
9
+ extend ::TagLib::FileOpenable
10
+ end
11
+ 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"]
@@ -23,11 +23,12 @@ DESC
23
23
  s.require_paths = ["lib"]
24
24
  s.requirements = ["taglib (libtag1-dev in Debian/Ubuntu, taglib-devel in Fedora/RHEL)"]
25
25
 
26
- s.add_development_dependency 'bundler', '~> 1.2'
27
- s.add_development_dependency 'rake-compiler', '~> 0.8'
26
+ s.add_development_dependency 'bundler', '>= 1.2', '< 3'
27
+ s.add_development_dependency 'rake-compiler', '~> 0.9'
28
28
  s.add_development_dependency 'shoulda-context', '~> 1.0'
29
- s.add_development_dependency 'yard', '~> 0.7'
30
- s.add_development_dependency 'kramdown', '~> 1.0'
29
+ s.add_development_dependency 'yard', '~> 0.9.26'
30
+ s.add_development_dependency 'kramdown', '~> 2.3.0'
31
+ s.add_development_dependency 'test-unit', '~> 3.1'
31
32
 
32
33
  s.extensions = [
33
34
  "ext/taglib_base/extconf.rb",
@@ -37,22 +38,26 @@ DESC
37
38
  "ext/taglib_ogg/extconf.rb",
38
39
  "ext/taglib_vorbis/extconf.rb",
39
40
  "ext/taglib_flac/extconf.rb",
41
+ "ext/taglib_flac_picture/extconf.rb",
40
42
  "ext/taglib_mp4/extconf.rb",
43
+ "ext/taglib_aiff/extconf.rb",
44
+ "ext/taglib_wav/extconf.rb",
41
45
  ]
42
46
  s.extra_rdoc_files = [
43
- "CHANGES.md",
47
+ "CHANGELOG.md",
44
48
  "LICENSE.txt",
45
49
  "README.md",
46
50
  ]
47
51
  s.files = [
48
52
  ".yardopts",
49
- "CHANGES.md",
53
+ "CHANGELOG.md",
50
54
  "Gemfile",
51
55
  "Guardfile",
52
56
  "LICENSE.txt",
53
57
  "README.md",
54
58
  "Rakefile",
55
59
  "docs/default/fulldoc/html/css/common.css",
60
+ "docs/taglib/aiff.rb",
56
61
  "docs/taglib/base.rb",
57
62
  "docs/taglib/flac.rb",
58
63
  "docs/taglib/id3v1.rb",
@@ -60,8 +65,13 @@ DESC
60
65
  "docs/taglib/mp4.rb",
61
66
  "docs/taglib/mpeg.rb",
62
67
  "docs/taglib/ogg.rb",
68
+ "docs/taglib/riff.rb",
63
69
  "docs/taglib/vorbis.rb",
70
+ "docs/taglib/wav.rb",
64
71
  "ext/extconf_common.rb",
72
+ "ext/taglib_aiff/extconf.rb",
73
+ "ext/taglib_aiff/taglib_aiff.i",
74
+ "ext/taglib_aiff/taglib_aiff_wrap.cxx",
65
75
  "ext/taglib_base/extconf.rb",
66
76
  "ext/taglib_base/includes.i",
67
77
  "ext/taglib_base/taglib_base.i",
@@ -69,6 +79,10 @@ DESC
69
79
  "ext/taglib_flac/extconf.rb",
70
80
  "ext/taglib_flac/taglib_flac.i",
71
81
  "ext/taglib_flac/taglib_flac_wrap.cxx",
82
+ "ext/taglib_flac_picture/extconf.rb",
83
+ "ext/taglib_flac_picture/includes.i",
84
+ "ext/taglib_flac_picture/taglib_flac_picture.i",
85
+ "ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx",
72
86
  "ext/taglib_id3v1/extconf.rb",
73
87
  "ext/taglib_id3v1/taglib_id3v1.i",
74
88
  "ext/taglib_id3v1/taglib_id3v1_wrap.cxx",
@@ -88,9 +102,13 @@ DESC
88
102
  "ext/taglib_vorbis/extconf.rb",
89
103
  "ext/taglib_vorbis/taglib_vorbis.i",
90
104
  "ext/taglib_vorbis/taglib_vorbis_wrap.cxx",
105
+ "ext/taglib_wav/extconf.rb",
106
+ "ext/taglib_wav/taglib_wav.i",
107
+ "ext/taglib_wav/taglib_wav_wrap.cxx",
91
108
  "ext/valgrind-suppressions.txt",
92
109
  "ext/win.cmake",
93
110
  "lib/taglib.rb",
111
+ "lib/taglib/aiff.rb",
94
112
  "lib/taglib/base.rb",
95
113
  "lib/taglib/flac.rb",
96
114
  "lib/taglib/id3v1.rb",
@@ -100,17 +118,23 @@ DESC
100
118
  "lib/taglib/ogg.rb",
101
119
  "lib/taglib/version.rb",
102
120
  "lib/taglib/vorbis.rb",
121
+ "lib/taglib/wav.rb",
103
122
  "taglib-ruby.gemspec",
104
123
  "tasks/docs_coverage.rake",
105
124
  "tasks/ext.rake",
106
125
  "tasks/gemspec_check.rake",
107
126
  "tasks/swig.rake",
127
+ "test/aiff_examples_test.rb",
128
+ "test/aiff_file_test.rb",
129
+ "test/aiff_file_write_test.rb",
108
130
  "test/base_test.rb",
109
131
  "test/data/Makefile",
110
132
  "test/data/add-relative-volume.cpp",
133
+ "test/data/aiff-sample.aiff",
111
134
  "test/data/crash.mp3",
112
135
  "test/data/flac-create.cpp",
113
136
  "test/data/flac.flac",
137
+ "test/data/flac_nopic.flac",
114
138
  "test/data/get_picture_data.cpp",
115
139
  "test/data/globe_east_540.jpg",
116
140
  "test/data/globe_east_90.jpg",
@@ -123,12 +147,18 @@ DESC
123
147
  "test/data/unicode.mp3",
124
148
  "test/data/vorbis-create.cpp",
125
149
  "test/data/vorbis.oga",
126
- "test/helper.rb",
150
+ "test/data/wav-create.cpp",
151
+ "test/data/wav-dump.cpp",
152
+ "test/data/wav-sample.wav",
153
+ "test/file_test.rb",
127
154
  "test/fileref_open_test.rb",
128
155
  "test/fileref_properties_test.rb",
129
156
  "test/fileref_write_test.rb",
130
157
  "test/flac_file_test.rb",
131
158
  "test/flac_file_write_test.rb",
159
+ "test/flac_picture_memory_test.rb",
160
+ "test/helper.rb",
161
+ "test/id3v1_genres_test.rb",
132
162
  "test/id3v1_tag_test.rb",
133
163
  "test/id3v2_frames_test.rb",
134
164
  "test/id3v2_header_test.rb",
@@ -136,6 +166,7 @@ DESC
136
166
  "test/id3v2_relative_volume_test.rb",
137
167
  "test/id3v2_tag_test.rb",
138
168
  "test/id3v2_unicode_test.rb",
169
+ "test/id3v2_unknown_frames_test.rb",
139
170
  "test/id3v2_write_test.rb",
140
171
  "test/mp4_file_test.rb",
141
172
  "test/mp4_file_write_test.rb",
@@ -145,5 +176,8 @@ DESC
145
176
  "test/unicode_filename_test.rb",
146
177
  "test/vorbis_file_test.rb",
147
178
  "test/vorbis_tag_test.rb",
179
+ "test/wav_examples_test.rb",
180
+ "test/wav_file_test.rb",
181
+ "test/wav_file_write_test.rb"
148
182
  ]
149
183
  end
@@ -1,23 +1,32 @@
1
1
  # Extension tasks and cross-compiling
2
2
 
3
3
  host = 'i686-w64-mingw32'
4
- plat = 'x86-mingw32'
4
+ $plat = ENV['PLATFORM'] || 'i386-mingw32'
5
5
 
6
- tmp = "#{Dir.pwd}/tmp/#{plat}"
6
+
7
+ taglib_version = ENV['TAGLIB_VERSION'] || '1.9.1'
8
+ taglib = "taglib-#{taglib_version}"
9
+
10
+ tmp = "#{Dir.pwd}/tmp"
11
+ tmp_arch = "#{tmp}/#{$plat}"
7
12
  toolchain_file = "#{Dir.pwd}/ext/win.cmake"
8
- install_dir = "#{tmp}/install"
13
+ install_dir = "#{tmp_arch}/#{taglib}"
9
14
  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}")]
15
+ install_so = "#{install_dir}/lib/libtag.so"
16
+ $cross_config_options = ["--with-opt-dir=#{install_dir}"]
12
17
 
13
- taglib_version = '1.8'
14
- taglib = "taglib-#{taglib_version}"
15
- taglib_url = "http://cloud.github.com/downloads/taglib/taglib/#{taglib}.tar.gz"
16
- # WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8
17
- taglib_options = "-DCMAKE_BUILD_TYPE=Release -DWITH_MP4=ON -DWITH_ASF=ON"
18
+ taglib_url = "https://github.com/taglib/taglib/archive/v#{taglib_version}.tar.gz"
19
+ taglib_options = [ "-DCMAKE_BUILD_TYPE=Release",
20
+ "-DBUILD_EXAMPLES=OFF",
21
+ "-DBUILD_TESTS=OFF",
22
+ "-DBUILD_BINDINGS=OFF", # 1.11 builds bindings by default
23
+ "-DBUILD_SHARED_LIBS=ON", # 1.11 builds static by default
24
+ "-DWITH_MP4=ON",# WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8
25
+ "-DWITH_ASF=ON"].join(' ')
18
26
 
19
27
  def configure_cross_compile(ext)
20
28
  ext.cross_compile = true
29
+ ext.cross_platform = $plat
21
30
  ext.cross_config_options.concat($cross_config_options)
22
31
  ext.cross_compiling do |gem|
23
32
  gem.files << "lib/libtag.dll"
@@ -43,30 +52,52 @@ end
43
52
  Rake::ExtensionTask.new("taglib_vorbis", $gemspec) do |ext|
44
53
  configure_cross_compile(ext)
45
54
  end
55
+ Rake::ExtensionTask.new("taglib_flac_picture", $gemspec) do |ext|
56
+ configure_cross_compile(ext)
57
+ end
46
58
  Rake::ExtensionTask.new("taglib_flac", $gemspec) do |ext|
47
59
  configure_cross_compile(ext)
48
60
  end
49
61
  Rake::ExtensionTask.new("taglib_mp4", $gemspec) do |ext|
50
62
  configure_cross_compile(ext)
51
63
  end
64
+ Rake::ExtensionTask.new("taglib_aiff", $gemspec) do |ext|
65
+ configure_cross_compile(ext)
66
+ end
67
+ Rake::ExtensionTask.new("taglib_wav", $gemspec) do |ext|
68
+ configure_cross_compile(ext)
69
+ end
52
70
 
53
- task :cross => [:taglib] do
71
+ task :cross do
54
72
  # Mkmf just uses "g++" as C++ compiler, despite what's in rbconfig.rb.
55
73
  # So, we need to hack around it by setting CXX to the cross compiler.
56
74
  ENV["CXX"] = "#{host}-g++"
57
- install install_dll, "lib/"
58
75
  end
59
76
 
60
- task :taglib => [install_dll]
77
+ file "#{tmp_arch}/stage/lib/libtag.dll" => [install_dll] do |f|
78
+ install install_dll, f
79
+ end
61
80
 
62
81
  file install_dll => ["#{tmp}/#{taglib}"] do
63
82
  chdir "#{tmp}/#{taglib}" do
64
- sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} -DCMAKE_SHARED_LINKER_FLAGS="#{ldflags}" #{taglib_options})
83
+ sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} #{taglib_options})
65
84
  sh "make VERBOSE=1"
66
85
  sh "make install"
67
86
  end
68
87
  end
69
88
 
89
+ task :vendor => [install_so]
90
+
91
+ file install_so => ["#{tmp_arch}/#{taglib}", "#{tmp_arch}/#{taglib}-build", "#{tmp}/#{taglib}"] do
92
+ chdir "#{tmp_arch}/#{taglib}-build" do
93
+ sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} #{taglib_options} #{tmp}/#{taglib})
94
+ sh "make install VERBOSE=1"
95
+ end
96
+ end
97
+
98
+ directory "#{tmp_arch}/#{taglib}"
99
+ directory "#{tmp_arch}/#{taglib}-build"
100
+
70
101
  file "#{tmp}/#{taglib}" => ["#{tmp}/#{taglib}.tar.gz"] do
71
102
  chdir tmp do
72
103
  sh "tar xzf #{taglib}.tar.gz"
@@ -76,12 +107,9 @@ end
76
107
  file "#{tmp}/#{taglib}.tar.gz" => [tmp] do |t|
77
108
  require 'open-uri'
78
109
  puts "Downloading #{taglib_url}"
79
- data = open(taglib_url).read()
80
- break if data == nil
81
- chdir tmp do
82
- open(File.basename(t.name), 'wb') do |f|
83
- f.write(data)
84
- end
110
+
111
+ File.open(t.name, 'wb') do |f|
112
+ IO.copy_stream(open(taglib_url), f)
85
113
  end
86
114
  end
87
115
 
@@ -1,6 +1,6 @@
1
1
  desc "Checks file list in .gemspec against files tracked in Git"
2
2
  task :gemspec_check do |t|
3
- exclude = ['.gitignore', '.travis.yml']
3
+ exclude = ['.gitignore', '.github/workflows/ci.yml']
4
4
  git_files = `git ls-files`.split("\n") - exclude
5
5
  gemspec_files = $gemspec.files
6
6
 
@@ -1,11 +1,30 @@
1
1
  # Tasks for generating SWIG wrappers in ext
2
2
 
3
+ # Execute SWIG for the specified extension.
4
+ # Arguments:
5
+ # mod:: The name of the SWIG wrapper to process.
6
+ #
7
+ # If the TAGLIB_DIR environment variable points to a directory,
8
+ # $TAGLIB_DIR/include will be searched first for taglib headers.
3
9
  def run_swig(mod)
4
10
  swig = `which swig`.chomp
5
11
  if swig.empty?
6
12
  swig = `which swig2.0`.chomp
7
13
  end
8
- sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/local/include -I/usr/include #{mod}.i"
14
+
15
+ # Standard search location for headers
16
+ include_args = %w{-I/usr/local/include -I/usr/include}
17
+
18
+ if ENV.has_key?('TAGLIB_DIR')
19
+ unless File.directory?(ENV['TAGLIB_DIR'])
20
+ abort "When defined, the TAGLIB_DIR environment variable must point to a valid directory."
21
+ end
22
+
23
+ # Push it in front to get it searched first.
24
+ include_args.unshift('-I' + ENV['TAGLIB_DIR'] + '/include')
25
+ end
26
+
27
+ sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} #{include_args.join(' ')} #{mod}.i"
9
28
  end
10
29
 
11
30
  task :swig =>
@@ -15,8 +34,11 @@ task :swig =>
15
34
  'ext/taglib_id3v2/taglib_id3v2_wrap.cxx',
16
35
  'ext/taglib_ogg/taglib_ogg_wrap.cxx',
17
36
  'ext/taglib_vorbis/taglib_vorbis_wrap.cxx',
37
+ 'ext/taglib_flac/taglib_flac_picture_wrap.cxx',
18
38
  'ext/taglib_flac/taglib_flac_wrap.cxx',
19
39
  'ext/taglib_mp4/taglib_mp4_wrap.cxx',
40
+ 'ext/taglib_aiff/taglib_aiff_wrap.cxx',
41
+ 'ext/taglib_wav/taglib_wav_wrap.cxx',
20
42
  ]
21
43
 
22
44
  base_dependencies = ['ext/taglib_base/taglib_base.i', 'ext/taglib_base/includes.i']
@@ -45,10 +67,22 @@ file 'ext/taglib_vorbis/taglib_vorbis_wrap.cxx' => ['ext/taglib_vorbis/taglib_vo
45
67
  run_swig('taglib_vorbis')
46
68
  end
47
69
 
48
- file 'ext/taglib_flac/taglib_flac_wrap.cxx' => ['ext/taglib_flac/taglib_flac.i'] + base_dependencies do
70
+ file 'ext/taglib_flac/taglib_flac_picture_wrap.cxx' => ['ext/taglib_flac_picture/taglib_flac_picture.i'] + base_dependencies do
71
+ run_swig('taglib_flac_picture')
72
+ end
73
+
74
+ file 'ext/taglib_flac/taglib_flac_wrap.cxx' => ['ext/taglib_flac/taglib_flac.i', 'ext/taglib_flac_picture/taglib_flac_picture.i'] + base_dependencies do
49
75
  run_swig('taglib_flac')
50
76
  end
51
77
 
52
78
  file 'ext/taglib_mp4/taglib_mp4_wrap.cxx' => ['ext/taglib_mp4/taglib_mp4.i'] + base_dependencies do
53
79
  run_swig('taglib_mp4')
54
80
  end
81
+
82
+ file 'ext/taglib_aiff/taglib_aiff_wrap.cxx' => ['ext/taglib_aiff/taglib_aiff.i'] + base_dependencies do
83
+ run_swig('taglib_aiff')
84
+ end
85
+
86
+ file 'ext/taglib_wav/taglib_wav_wrap.cxx' => ['ext/taglib_wav/taglib_wav.i'] + base_dependencies do
87
+ run_swig('taglib_wav')
88
+ 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.bits_per_sample #=> 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,103 @@
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 @file.id3v2_tag?
19
+ refute_nil @tag
20
+ assert_equal TagLib::ID3v2::Tag, @tag.class
21
+ end
22
+
23
+ should "contain basic tag information" do
24
+ assert_equal "AIFF Dummy Track Title - ID3v2.4", @tag.title
25
+ assert_equal "AIFF Dummy Artist Name", @tag.artist
26
+ assert_equal "AIFF Dummy Album Title", @tag.album
27
+ assert_equal "AIFF Dummy Comment", @tag.comment
28
+ assert_equal "Jazz", @tag.genre
29
+ assert_equal 2014, @tag.year
30
+ assert_equal 3, @tag.track
31
+ assert_equal false, @tag.empty?
32
+ end
33
+
34
+ context "APIC frame" do
35
+ setup do
36
+ @apic = @tag.frame_list('APIC').first
37
+ end
38
+
39
+ should "exist" do
40
+ assert_not_nil @apic
41
+ assert_equal TagLib::ID3v2::AttachedPictureFrame, @apic.class
42
+ end
43
+
44
+ should "have a type" do
45
+ assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
46
+ end
47
+
48
+ should "have a mime type" do
49
+ assert_equal "image/jpeg", @apic.mime_type
50
+ end
51
+
52
+ should "have picture bytes" do
53
+ assert_equal 61649, @apic.picture.size
54
+ assert_equal @picture_data, @apic.picture
55
+ end
56
+ end
57
+
58
+ context "audio properties" do
59
+ setup do
60
+ @properties = @file.audio_properties
61
+ end
62
+
63
+ should "exist" do
64
+ assert_not_nil @properties
65
+ end
66
+
67
+ should "contain basic information" do
68
+ assert_equal 2, @properties.length_in_seconds
69
+ assert_equal 2937, @properties.length_in_milliseconds
70
+ assert_equal 256, @properties.bitrate
71
+ assert_equal 8000, @properties.sample_rate
72
+ assert_equal 2, @properties.channels
73
+ end
74
+
75
+ should "contain AIFF-specific information" do
76
+ assert_equal 16, @properties.bits_per_sample
77
+ assert_equal 23493, @properties.sample_frames
78
+ end
79
+
80
+ should "do not contain AIFF-C information" do
81
+ refute @properties.aiff_c?
82
+ assert_equal "", @properties.compression_type
83
+ assert_equal "", @properties.compression_name
84
+ end
85
+ end
86
+
87
+ teardown do
88
+ @file.close
89
+ @file = nil
90
+ end
91
+ end
92
+
93
+ context "TagLib::RIFF::AIFF::File.open" do
94
+ should "have open method" do
95
+ title = nil
96
+ TagLib::RIFF::AIFF::File.open(SAMPLE_FILE, false) do |file|
97
+ title = file.tag.title
98
+ end
99
+ assert_equal "AIFF Dummy Track Title - ID3v2.4", title
100
+ end
101
+ end
102
+
103
+ end