taglib-ruby 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/CHANGES.md +7 -0
  2. data/Gemfile +1 -2
  3. data/Gemfile.lock +9 -8
  4. data/README.md +22 -7
  5. data/Rakefile +9 -15
  6. data/docs/taglib/base.rb +31 -8
  7. data/docs/taglib/id3v1.rb +5 -0
  8. data/docs/taglib/mpeg.rb +8 -0
  9. data/docs/taglib/ogg.rb +77 -0
  10. data/docs/taglib/vorbis.rb +43 -0
  11. data/ext/taglib_base/includes.i +25 -1
  12. data/ext/taglib_base/taglib_base.i +46 -2
  13. data/ext/taglib_base/taglib_base_wrap.cxx +176 -185
  14. data/ext/taglib_id3v1/extconf.rb +4 -0
  15. data/ext/taglib_id3v1/taglib_id3v1.i +11 -0
  16. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +3092 -0
  17. data/ext/taglib_id3v2/taglib_id3v2.i +0 -8
  18. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +194 -248
  19. data/ext/taglib_mpeg/taglib_mpeg.i +16 -2
  20. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +157 -149
  21. data/ext/taglib_ogg/extconf.rb +4 -0
  22. data/ext/taglib_ogg/taglib_ogg.i +36 -0
  23. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +3613 -0
  24. data/ext/taglib_vorbis/extconf.rb +4 -0
  25. data/ext/taglib_vorbis/taglib_vorbis.i +48 -0
  26. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +3056 -0
  27. data/ext/win.cmake +6 -0
  28. data/lib/taglib/id3v1.rb +1 -0
  29. data/lib/taglib/ogg.rb +1 -0
  30. data/lib/taglib/version.rb +2 -2
  31. data/lib/taglib/vorbis.rb +1 -0
  32. data/lib/taglib.rb +10 -0
  33. data/taglib-ruby.gemspec +35 -11
  34. data/tasks/ext.rake +79 -0
  35. data/tasks/swig.rake +43 -0
  36. data/test/data/Makefile +15 -0
  37. data/test/data/id3v1-create.cpp +31 -0
  38. data/test/data/id3v1.mp3 +0 -0
  39. data/test/data/vorbis-create.cpp +42 -0
  40. data/test/data/vorbis.oga +0 -0
  41. data/test/test_fileref_write.rb +38 -0
  42. data/test/test_id3v1_tag.rb +36 -0
  43. data/test/test_id3v2_frames.rb +5 -0
  44. data/test/test_id3v2_memory.rb +23 -0
  45. data/test/test_id3v2_relative_volume.rb +5 -0
  46. data/test/test_id3v2_tag.rb +5 -0
  47. data/test/test_id3v2_unicode.rb +5 -0
  48. data/test/test_id3v2_write.rb +6 -1
  49. data/test/test_mpeg_file.rb +18 -1
  50. data/test/test_vorbis_file.rb +44 -0
  51. data/test/test_vorbis_tag.rb +79 -0
  52. metadata +113 -137
  53. data/ext/Rakefile +0 -32
data/ext/win.cmake ADDED
@@ -0,0 +1,6 @@
1
+ SET(CMAKE_SYSTEM_NAME Windows)
2
+ SET(CMAKE_BUILD_TYPE Release)
3
+
4
+ SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
5
+ SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
6
+ SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
@@ -0,0 +1 @@
1
+ require 'taglib_id3v1'
data/lib/taglib/ogg.rb ADDED
@@ -0,0 +1 @@
1
+ require 'taglib_ogg'
@@ -1,8 +1,8 @@
1
1
  module TagLib
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 1
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -0,0 +1 @@
1
+ require 'taglib_vorbis'
data/lib/taglib.rb CHANGED
@@ -1,4 +1,14 @@
1
+ platform = RUBY_PLATFORM.split("-")[1]
2
+ if platform == 'mingw32'
3
+ # Enable loading of pre-compiled libtag.dll
4
+ lib = File.expand_path(File.dirname(__FILE__))
5
+ ENV['PATH'] += (File::PATH_SEPARATOR + lib)
6
+ end
7
+
1
8
  require 'taglib/version'
2
9
  require 'taglib/base'
3
10
  require 'taglib/mpeg'
11
+ require 'taglib/id3v1'
4
12
  require 'taglib/id3v2'
13
+ require 'taglib/ogg'
14
+ require 'taglib/vorbis'
data/taglib-ruby.gemspec CHANGED
@@ -5,15 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "taglib-ruby"
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robin Stocker"]
12
- s.date = "2011-11-05"
12
+ s.date = "2012-01-02"
13
13
  s.description = "Ruby interface for the taglib C++ library.\n\nIn contrast to other libraries, this one wraps the C++ API using SWIG,\nnot only the minimal C API. This means that all tags can be accessed.\n"
14
14
  s.email = "robin@nibor.org"
15
- s.extensions = ["ext/taglib_base/extconf.rb", "ext/taglib_mpeg/extconf.rb", "ext/taglib_id3v2/extconf.rb"]
15
+ s.extensions = ["ext/taglib_base/extconf.rb", "ext/taglib_mpeg/extconf.rb", "ext/taglib_id3v1/extconf.rb", "ext/taglib_id3v2/extconf.rb", "ext/taglib_ogg/extconf.rb", "ext/taglib_vorbis/extconf.rb"]
16
16
  s.extra_rdoc_files = [
17
+ "CHANGES.md",
17
18
  "LICENSE.txt",
18
19
  "README.md"
19
20
  ]
@@ -28,14 +29,19 @@ Gem::Specification.new do |s|
28
29
  "Rakefile",
29
30
  "docs/default/fulldoc/html/css/common.css",
30
31
  "docs/taglib/base.rb",
32
+ "docs/taglib/id3v1.rb",
31
33
  "docs/taglib/id3v2.rb",
32
34
  "docs/taglib/mpeg.rb",
33
- "ext/Rakefile",
35
+ "docs/taglib/ogg.rb",
36
+ "docs/taglib/vorbis.rb",
34
37
  "ext/extconf_common.rb",
35
38
  "ext/taglib_base/extconf.rb",
36
39
  "ext/taglib_base/includes.i",
37
40
  "ext/taglib_base/taglib_base.i",
38
41
  "ext/taglib_base/taglib_base_wrap.cxx",
42
+ "ext/taglib_id3v1/extconf.rb",
43
+ "ext/taglib_id3v1/taglib_id3v1.i",
44
+ "ext/taglib_id3v1/taglib_id3v1_wrap.cxx",
39
45
  "ext/taglib_id3v2/extconf.rb",
40
46
  "ext/taglib_id3v2/relativevolumeframe.i",
41
47
  "ext/taglib_id3v2/taglib_id3v2.i",
@@ -43,22 +49,41 @@ Gem::Specification.new do |s|
43
49
  "ext/taglib_mpeg/extconf.rb",
44
50
  "ext/taglib_mpeg/taglib_mpeg.i",
45
51
  "ext/taglib_mpeg/taglib_mpeg_wrap.cxx",
52
+ "ext/taglib_ogg/extconf.rb",
53
+ "ext/taglib_ogg/taglib_ogg.i",
54
+ "ext/taglib_ogg/taglib_ogg_wrap.cxx",
55
+ "ext/taglib_vorbis/extconf.rb",
56
+ "ext/taglib_vorbis/taglib_vorbis.i",
57
+ "ext/taglib_vorbis/taglib_vorbis_wrap.cxx",
46
58
  "ext/valgrind-suppressions.txt",
59
+ "ext/win.cmake",
47
60
  "lib/taglib.rb",
48
61
  "lib/taglib/base.rb",
62
+ "lib/taglib/id3v1.rb",
49
63
  "lib/taglib/id3v2.rb",
50
64
  "lib/taglib/mpeg.rb",
65
+ "lib/taglib/ogg.rb",
51
66
  "lib/taglib/version.rb",
67
+ "lib/taglib/vorbis.rb",
52
68
  "taglib-ruby.gemspec",
53
69
  "tasks/docs_coverage.rake",
70
+ "tasks/ext.rake",
71
+ "tasks/swig.rake",
72
+ "test/data/Makefile",
54
73
  "test/data/add-relative-volume.cpp",
55
74
  "test/data/crash.mp3",
56
75
  "test/data/globe_east_540.jpg",
76
+ "test/data/id3v1-create.cpp",
77
+ "test/data/id3v1.mp3",
57
78
  "test/data/relative-volume.mp3",
58
79
  "test/data/sample.mp3",
59
80
  "test/data/unicode.mp3",
81
+ "test/data/vorbis-create.cpp",
82
+ "test/data/vorbis.oga",
60
83
  "test/helper.rb",
61
84
  "test/test_fileref_properties.rb",
85
+ "test/test_fileref_write.rb",
86
+ "test/test_id3v1_tag.rb",
62
87
  "test/test_id3v2_frames.rb",
63
88
  "test/test_id3v2_memory.rb",
64
89
  "test/test_id3v2_relative_volume.rb",
@@ -66,7 +91,9 @@ Gem::Specification.new do |s|
66
91
  "test/test_id3v2_unicode.rb",
67
92
  "test/test_id3v2_write.rb",
68
93
  "test/test_mpeg_file.rb",
69
- "test/test_tag.rb"
94
+ "test/test_tag.rb",
95
+ "test/test_vorbis_file.rb",
96
+ "test/test_vorbis_tag.rb"
70
97
  ]
71
98
  s.homepage = "http://github.com/robinst/taglib-ruby"
72
99
  s.licenses = ["MIT"]
@@ -83,18 +110,16 @@ Gem::Specification.new do |s|
83
110
  s.add_development_dependency(%q<shoulda>, ["~> 2.11"])
84
111
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
85
112
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
86
- s.add_development_dependency(%q<rcov>, [">= 0"])
87
113
  s.add_development_dependency(%q<yard>, ["~> 0.7"])
88
- s.add_development_dependency(%q<redcarpet>, [">= 0"])
114
+ s.add_development_dependency(%q<redcarpet>, ["~> 1.0"])
89
115
  s.add_development_dependency(%q<guard-test>, ["~> 0.4.0"])
90
116
  else
91
117
  s.add_dependency(%q<rake-compiler>, ["~> 0.7"])
92
118
  s.add_dependency(%q<shoulda>, ["~> 2.11"])
93
119
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
94
120
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
95
- s.add_dependency(%q<rcov>, [">= 0"])
96
121
  s.add_dependency(%q<yard>, ["~> 0.7"])
97
- s.add_dependency(%q<redcarpet>, [">= 0"])
122
+ s.add_dependency(%q<redcarpet>, ["~> 1.0"])
98
123
  s.add_dependency(%q<guard-test>, ["~> 0.4.0"])
99
124
  end
100
125
  else
@@ -102,9 +127,8 @@ Gem::Specification.new do |s|
102
127
  s.add_dependency(%q<shoulda>, ["~> 2.11"])
103
128
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
104
129
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
105
- s.add_dependency(%q<rcov>, [">= 0"])
106
130
  s.add_dependency(%q<yard>, ["~> 0.7"])
107
- s.add_dependency(%q<redcarpet>, [">= 0"])
131
+ s.add_dependency(%q<redcarpet>, ["~> 1.0"])
108
132
  s.add_dependency(%q<guard-test>, ["~> 0.4.0"])
109
133
  end
110
134
  end
data/tasks/ext.rake ADDED
@@ -0,0 +1,79 @@
1
+ # Extension tasks and cross-compiling
2
+
3
+ host = 'i686-w64-mingw32'
4
+ plat = 'x86-mingw32'
5
+
6
+ tmp = "#{Dir.pwd}/tmp/#{plat}"
7
+ toolchain_file = "#{Dir.pwd}/ext/win.cmake"
8
+ install_dir = "#{tmp}/install"
9
+ install_dll = "#{install_dir}/bin/libtag.dll"
10
+ $cross_config_options = ["--with-opt-dir=#{install_dir}"]
11
+
12
+ taglib_version = '1.7'
13
+ taglib = "taglib-#{taglib_version}"
14
+ taglib_url = "http://developer.kde.org/~wheeler/files/src/#{taglib}.tar.gz"
15
+
16
+ def configure_cross_compile(ext)
17
+ ext.cross_compile = true
18
+ ext.cross_config_options.concat($cross_config_options)
19
+ ext.cross_compiling do |gem|
20
+ gem.files << "lib/libtag.dll"
21
+ end
22
+ end
23
+
24
+ require 'rake/extensiontask'
25
+ Rake::ExtensionTask.new("taglib_base", $gemspec) do |ext|
26
+ configure_cross_compile(ext)
27
+ end
28
+ Rake::ExtensionTask.new("taglib_mpeg", $gemspec) do |ext|
29
+ configure_cross_compile(ext)
30
+ end
31
+ Rake::ExtensionTask.new("taglib_id3v1", $gemspec) do |ext|
32
+ configure_cross_compile(ext)
33
+ end
34
+ Rake::ExtensionTask.new("taglib_id3v2", $gemspec) do |ext|
35
+ configure_cross_compile(ext)
36
+ end
37
+ Rake::ExtensionTask.new("taglib_ogg", $gemspec) do |ext|
38
+ configure_cross_compile(ext)
39
+ end
40
+ Rake::ExtensionTask.new("taglib_vorbis", $gemspec) do |ext|
41
+ configure_cross_compile(ext)
42
+ end
43
+
44
+ task :cross => [:taglib] do
45
+ # Mkmf just uses "g++" as C++ compiler, despite what's in rbconfig.rb.
46
+ # So, we need to hack around it by setting CXX to the cross compiler.
47
+ ENV["CXX"] = "#{host}-g++"
48
+ install install_dll, "lib/"
49
+ end
50
+
51
+ task :taglib => [install_dll]
52
+
53
+ file install_dll => ["#{tmp}/#{taglib}"] do
54
+ chdir "#{tmp}/#{taglib}" do
55
+ sh "cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file}"
56
+ sh "make"
57
+ sh "make install"
58
+ end
59
+ end
60
+
61
+ file "#{tmp}/#{taglib}" => ["#{tmp}/#{taglib}.tar.gz"] do
62
+ chdir tmp do
63
+ sh "tar xzf #{taglib}.tar.gz"
64
+ end
65
+ end
66
+
67
+ file "#{tmp}/#{taglib}.tar.gz" => [tmp] do |t|
68
+ require 'open-uri'
69
+ puts "Downloading #{taglib_url}"
70
+ data = open(taglib_url).read()
71
+ break if data == nil
72
+ chdir tmp do
73
+ open(File.basename(t.name), 'wb') do |f|
74
+ f.write(data)
75
+ end
76
+ end
77
+ end
78
+
79
+ directory tmp
data/tasks/swig.rake ADDED
@@ -0,0 +1,43 @@
1
+ # Tasks for generating SWIG wrappers in ext
2
+
3
+ def run_swig(mod)
4
+ swig = `which swig`.chomp
5
+ if swig.empty?
6
+ swig = `which swig2.0`.chomp
7
+ end
8
+ sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/include #{mod}.i"
9
+ end
10
+
11
+ task :swig =>
12
+ ['ext/taglib_base/taglib_base_wrap.cxx',
13
+ 'ext/taglib_mpeg/taglib_mpeg_wrap.cxx',
14
+ 'ext/taglib_id3v1/taglib_id3v1_wrap.cxx',
15
+ 'ext/taglib_id3v2/taglib_id3v2_wrap.cxx',
16
+ 'ext/taglib_ogg/taglib_ogg_wrap.cxx',
17
+ 'ext/taglib_vorbis/taglib_vorbis_wrap.cxx']
18
+
19
+ base_dependencies = ['ext/taglib_base/taglib_base.i', 'ext/taglib_base/includes.i']
20
+
21
+ file 'ext/taglib_base/taglib_base_wrap.cxx' => base_dependencies do
22
+ run_swig('taglib_base')
23
+ end
24
+
25
+ file 'ext/taglib_mpeg/taglib_mpeg_wrap.cxx' => ['ext/taglib_mpeg/taglib_mpeg.i'] + base_dependencies do
26
+ run_swig('taglib_mpeg')
27
+ end
28
+
29
+ file 'ext/taglib_id3v1/taglib_id3v1_wrap.cxx' => ['ext/taglib_id3v1/taglib_id3v1.i'] + base_dependencies do
30
+ run_swig('taglib_id3v1')
31
+ end
32
+
33
+ file 'ext/taglib_id3v2/taglib_id3v2_wrap.cxx' => ['ext/taglib_id3v2/taglib_id3v2.i'] + base_dependencies do
34
+ run_swig('taglib_id3v2')
35
+ end
36
+
37
+ file 'ext/taglib_ogg/taglib_ogg_wrap.cxx' => ['ext/taglib_ogg/taglib_ogg.i'] + base_dependencies do
38
+ run_swig('taglib_ogg')
39
+ end
40
+
41
+ file 'ext/taglib_vorbis/taglib_vorbis_wrap.cxx' => ['ext/taglib_vorbis/taglib_vorbis.i'] + base_dependencies do
42
+ run_swig('taglib_vorbis')
43
+ end
@@ -0,0 +1,15 @@
1
+ .PHONY: all clean
2
+
3
+ all:: add-relative-volume id3v1-create vorbis-create
4
+
5
+ add-relative-volume: add-relative-volume.cpp
6
+ g++ -o $@ $< -ltag -I/usr/include/taglib
7
+
8
+ id3v1-create: id3v1-create.cpp
9
+ g++ -o $@ $< -ltag -I/usr/include/taglib
10
+
11
+ vorbis-create: vorbis-create.cpp
12
+ g++ -o $@ $< -ltag -I/usr/include/taglib
13
+
14
+ clean::
15
+ -rm add-relative-volume id3v1-create
@@ -0,0 +1,31 @@
1
+ #include <iostream>
2
+ #include <stdlib.h>
3
+
4
+ #include <taglib/taglib.h>
5
+ #include <taglib/mpegfile.h>
6
+ #include <taglib/id3v1tag.h>
7
+
8
+ using namespace TagLib;
9
+
10
+ int main(int argc, char **argv) {
11
+ if (argc != 2) {
12
+ std::cout << "usage: " << argv[0] << " file.mp3" << std::endl;
13
+ exit(1);
14
+ }
15
+ char *filename = argv[1];
16
+
17
+ MPEG::File file(filename);
18
+ ID3v1::Tag *tag = file.ID3v1Tag(true);
19
+
20
+ tag->setTitle("Title");
21
+ tag->setArtist("Artist");
22
+ tag->setAlbum("Album");
23
+ tag->setComment("Comment");
24
+ tag->setGenre("Pop");
25
+ tag->setYear(2011);
26
+ tag->setTrack(7);
27
+
28
+ file.save(MPEG::File::ID3v1);
29
+ }
30
+
31
+ // vim: set filetype=cpp sw=2 ts=2 expandtab:
Binary file
@@ -0,0 +1,42 @@
1
+ #include <iostream>
2
+ #include <stdlib.h>
3
+
4
+ #include <taglib/taglib.h>
5
+ #include <taglib/vorbisfile.h>
6
+
7
+ using namespace TagLib;
8
+
9
+ int main(int argc, char **argv) {
10
+ if (argc != 2) {
11
+ std::cout << "usage: " << argv[0] << " file.mp3" << std::endl;
12
+ exit(1);
13
+ }
14
+ char *filename = argv[1];
15
+
16
+ Vorbis::File file(filename);
17
+ Ogg::XiphComment *tag = file.tag();
18
+
19
+ tag->setTitle("Title");
20
+ tag->setArtist("Artist");
21
+ tag->setAlbum("Album");
22
+ tag->setComment("Comment");
23
+ tag->setGenre("Pop");
24
+ tag->setYear(2011);
25
+ tag->setTrack(7);
26
+
27
+ tag->addField("VERSION", "original");
28
+ tag->addField("PERFORMER", "Performer");
29
+ tag->addField("COPYRIGHT", "2011 Me, myself and I");
30
+ tag->addField("LICENSE", "Any Use Permitted");
31
+ tag->addField("ORGANIZATION", "Organization");
32
+ tag->addField("DESCRIPTION", "Test file");
33
+ tag->addField("LOCATION", "Earth");
34
+ tag->addField("CONTACT", "Contact");
35
+
36
+ tag->addField("MULTIPLE", "A");
37
+ tag->addField("MULTIPLE", "B", false);
38
+
39
+ file.save();
40
+ }
41
+
42
+ // vim: set filetype=cpp sw=2 ts=2 expandtab:
Binary file
@@ -0,0 +1,38 @@
1
+ require 'helper'
2
+
3
+ require 'fileutils'
4
+
5
+ class TestFileRefWrite < Test::Unit::TestCase
6
+
7
+ SAMPLE_FILE = "test/data/sample.mp3"
8
+ OUTPUT_FILE = "test/data/output.mp3"
9
+
10
+ context "TagLib::FileRef" do
11
+ setup do
12
+ FileUtils.cp SAMPLE_FILE, OUTPUT_FILE
13
+ @file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
14
+ end
15
+
16
+ should "be able to save the title" do
17
+ tag = @file.tag
18
+ assert_not_nil tag
19
+ tag.title = "New Title"
20
+ success = @file.save
21
+ assert success
22
+ @file.close
23
+ @file = nil
24
+
25
+ written_file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
26
+ assert_equal "New Title", written_file.tag.title
27
+ written_file.close
28
+ end
29
+
30
+ teardown do
31
+ if @file
32
+ @file.close
33
+ @file = nil
34
+ end
35
+ FileUtils.rm OUTPUT_FILE
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ class TestID3v1Tag < Test::Unit::TestCase
4
+ context "The id3v1.mp3 file" do
5
+ setup do
6
+ read_properties = false
7
+ @file = TagLib::MPEG::File.new("test/data/id3v1.mp3", read_properties)
8
+ end
9
+
10
+ should "have an ID3v1 tag" do
11
+ assert_not_nil @file.id3v1_tag
12
+ end
13
+
14
+ context "ID3v1 tag" do
15
+ setup do
16
+ @tag = @file.id3v1_tag
17
+ end
18
+
19
+ should "have basic properties" do
20
+ assert_equal 'Title', @tag.title
21
+ assert_equal 'Artist', @tag.artist
22
+ assert_equal 'Album', @tag.album
23
+ assert_equal 'Comment', @tag.comment
24
+ assert_equal 'Pop', @tag.genre
25
+ assert_equal 2011, @tag.year
26
+ assert_equal 7, @tag.track
27
+ assert_equal false, @tag.empty?
28
+ end
29
+ end
30
+
31
+ teardown do
32
+ @file.close
33
+ @file = nil
34
+ end
35
+ end
36
+ end