rtaglib 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +84 -9
  3. data/README.txt +0 -0
  4. data/Rakefile +30 -27
  5. data/{test/data → data}/440Hz-5sec.flac +0 -0
  6. data/{test/data → data}/440Hz-5sec.mp3 +0 -0
  7. data/{test/data → data}/440Hz-5sec.mpc +0 -0
  8. data/{test/data → data}/440Hz-5sec.ogg +0 -0
  9. data/{test/data → data}/440Hz-5sec.wv +0 -0
  10. data/data/test_jason.mp3 +0 -0
  11. data/data/test_jason.ogg +0 -0
  12. data/ext/Rakefile +10 -0
  13. data/ext/tagfile/Rakefile.rb +42 -0
  14. data/ext/tagfile/rake_ext_conf.rb +29 -0
  15. data/ext/tagfile/tagfile.c +11 -7
  16. data/ext/taglib/Rakefile.rb +48 -0
  17. data/ext/taglib/rake_ext_conf.rb +33 -0
  18. data/ext/taglib/taglib-mswin32/bin/tag.dll +0 -0
  19. data/ext/taglib/taglib-mswin32/bin/tag_c.dll +0 -0
  20. data/ext/taglib/taglib-mswin32/bin/tag_cd.dll +0 -0
  21. data/ext/taglib/taglib-mswin32/bin/tagd.dll +0 -0
  22. data/ext/taglib/taglib-mswin32/bin/taglib-config +55 -0
  23. data/ext/taglib/taglib-mswin32/include/taglib/apefooter.h +173 -0
  24. data/ext/taglib/taglib-mswin32/include/taglib/apeitem.h +204 -0
  25. data/ext/taglib/taglib-mswin32/include/taglib/apetag.h +162 -0
  26. data/ext/taglib/taglib-mswin32/include/taglib/attachedpictureframe.h +220 -0
  27. data/ext/taglib/taglib-mswin32/include/taglib/audioproperties.h +110 -0
  28. data/ext/taglib/taglib-mswin32/include/taglib/commentsframe.h +168 -0
  29. data/ext/taglib/taglib-mswin32/include/taglib/fileref.h +262 -0
  30. data/ext/taglib/taglib-mswin32/include/taglib/flacfile.h +201 -0
  31. data/ext/taglib/taglib-mswin32/include/taglib/flacproperties.h +92 -0
  32. data/ext/taglib/taglib-mswin32/include/taglib/generalencapsulatedobjectframe.h +174 -0
  33. data/ext/taglib/taglib-mswin32/include/taglib/id3v1genres.h +66 -0
  34. data/ext/taglib/taglib-mswin32/include/taglib/id3v1tag.h +180 -0
  35. data/ext/taglib/taglib-mswin32/include/taglib/id3v2extendedheader.h +93 -0
  36. data/ext/taglib/taglib-mswin32/include/taglib/id3v2footer.h +82 -0
  37. data/ext/taglib/taglib-mswin32/include/taglib/id3v2frame.h +414 -0
  38. data/ext/taglib/taglib-mswin32/include/taglib/id3v2framefactory.h +167 -0
  39. data/ext/taglib/taglib-mswin32/include/taglib/id3v2header.h +175 -0
  40. data/ext/taglib/taglib-mswin32/include/taglib/id3v2synchdata.h +70 -0
  41. data/ext/taglib/taglib-mswin32/include/taglib/id3v2tag.h +300 -0
  42. data/ext/taglib/taglib-mswin32/include/taglib/mpcfile.h +175 -0
  43. data/ext/taglib/taglib-mswin32/include/taglib/mpcproperties.h +85 -0
  44. data/ext/taglib/taglib-mswin32/include/taglib/mpegfile.h +277 -0
  45. data/ext/taglib/taglib-mswin32/include/taglib/mpegheader.h +166 -0
  46. data/ext/taglib/taglib-mswin32/include/taglib/mpegproperties.h +118 -0
  47. data/ext/taglib/taglib-mswin32/include/taglib/oggfile.h +112 -0
  48. data/ext/taglib/taglib-mswin32/include/taglib/oggflacfile.h +118 -0
  49. data/ext/taglib/taglib-mswin32/include/taglib/oggpage.h +203 -0
  50. data/ext/taglib/taglib-mswin32/include/taglib/oggpageheader.h +232 -0
  51. data/ext/taglib/taglib-mswin32/include/taglib/relativevolumeframe.h +274 -0
  52. data/ext/taglib/taglib-mswin32/include/taglib/speexfile.h +99 -0
  53. data/ext/taglib/taglib-mswin32/include/taglib/speexproperties.h +89 -0
  54. data/ext/taglib/taglib-mswin32/include/taglib/tag.h +173 -0
  55. data/ext/taglib/taglib-mswin32/include/taglib/tag_c.h +288 -0
  56. data/ext/taglib/taglib-mswin32/include/taglib/taglib.h +177 -0
  57. data/ext/taglib/taglib-mswin32/include/taglib/taglib_export.h +39 -0
  58. data/ext/taglib/taglib-mswin32/include/taglib/tbytevector.h +409 -0
  59. data/ext/taglib/taglib-mswin32/include/taglib/tbytevectorlist.h +91 -0
  60. data/ext/taglib/taglib-mswin32/include/taglib/textidentificationframe.h +258 -0
  61. data/ext/taglib/taglib-mswin32/include/taglib/tfile.h +271 -0
  62. data/ext/taglib/taglib-mswin32/include/taglib/tlist.h +252 -0
  63. data/ext/taglib/taglib-mswin32/include/taglib/tlist.tcc +316 -0
  64. data/ext/taglib/taglib-mswin32/include/taglib/tmap.h +200 -0
  65. data/ext/taglib/taglib-mswin32/include/taglib/tmap.tcc +196 -0
  66. data/ext/taglib/taglib-mswin32/include/taglib/trueaudiofile.h +180 -0
  67. data/ext/taglib/taglib-mswin32/include/taglib/trueaudioproperties.h +93 -0
  68. data/ext/taglib/taglib-mswin32/include/taglib/tstring.h +456 -0
  69. data/ext/taglib/taglib-mswin32/include/taglib/tstringlist.h +115 -0
  70. data/ext/taglib/taglib-mswin32/include/taglib/uniquefileidentifierframe.h +113 -0
  71. data/ext/taglib/taglib-mswin32/include/taglib/unknownframe.h +79 -0
  72. data/ext/taglib/taglib-mswin32/include/taglib/unsynchronizedlyricsframe.h +157 -0
  73. data/ext/taglib/taglib-mswin32/include/taglib/urllinkframe.h +172 -0
  74. data/ext/taglib/taglib-mswin32/include/taglib/vorbisfile.h +118 -0
  75. data/ext/taglib/taglib-mswin32/include/taglib/vorbisproperties.h +125 -0
  76. data/ext/taglib/taglib-mswin32/include/taglib/wavpackfile.h +164 -0
  77. data/ext/taglib/taglib-mswin32/include/taglib/wavpackproperties.h +94 -0
  78. data/ext/taglib/taglib-mswin32/include/taglib/xingheader.h +100 -0
  79. data/ext/taglib/taglib-mswin32/include/taglib/xiphcomment.h +202 -0
  80. data/ext/taglib/taglib-mswin32/lib/pkgconfig/taglib_c.pc +12 -0
  81. data/ext/taglib/taglib-mswin32/lib/tag.lib +0 -0
  82. data/ext/taglib/taglib-mswin32/lib/tag_c.lib +0 -0
  83. data/ext/taglib/taglib_i386-mingw32.source +22645 -0
  84. data/ext/taglib/taglib_i386-mswin32.source +22645 -0
  85. data/ext/taglib/{taglib.cxx → taglib_x86_64-linux.source} +508 -75
  86. data/lib/TagLib.rb +3 -2
  87. data/lib/TagLib_doc.rb +1532 -1526
  88. data/lib/rtaglib_mswin32.rb +4 -0
  89. data/lib/tagfile.rb +6 -0
  90. data/swig/Doxyfile +0 -0
  91. data/swig/Rakefile +44 -19
  92. data/swig/TagLib_doc.rb +2755 -0
  93. data/swig/make_doc.rb +5 -4
  94. data/swig/process_cxx.rb +2 -2
  95. data/swig/rake_ext_conf.rb +33 -0
  96. data/swig/taglib.i +8 -5
  97. data/swig/test.rb +47 -39
  98. data/test/test_read.rb +4 -3
  99. data/test/test_taglib.rb +47 -39
  100. data/test/test_write.rb +4 -3
  101. metadata +96 -20
  102. data/ext/tagfile/extconf.rb +0 -14
  103. data/ext/taglib/extconf.rb +0 -22
  104. data/swig/extconf.rb +0 -22
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/ruby
2
2
  #### Make docs
3
+ require '../lib/rtaglib_mswin32'
4
+
3
5
  require 'rexml/document'
4
6
  require 'TagLib'
5
7
  require 'rbconfig'
@@ -9,6 +11,7 @@ if !fm.nil?
9
11
  brief_desc=fm[:brief_desc].gsub(/\s+/im,"").size>0 ? "<b>#{fm[:brief_desc]}</b>\n":""
10
12
  desc=(" # "+brief_desc+fm[:long_desc]+"\n").gsub("\n","\n # ")+"\n"
11
13
  params=fm[:param].join(",")
14
+ #p params
12
15
  else
13
16
  desc=""
14
17
  params=""
@@ -30,7 +33,6 @@ def print_methods(klass,functions,indent)
30
33
  methods=klass.instance_methods-Object.instance_methods
31
34
  methods.each{|m|
32
35
  dm=data_method(functions[m])
33
-
34
36
  out << dm[:desc]+indent+"def #{m}(#{dm[:params]})\n"+indent+"end\n"
35
37
  }
36
38
  out
@@ -53,11 +55,10 @@ def get_doxygen_description(xml_file)
53
55
 
54
56
  param=[]
55
57
  func.elements.each("param") {|xpar|
56
- type=xpar.elements["type"].to_s.gsub(/<.+?>|const|\*|String|StringList|&amp;/,"").chomp
57
58
  if xpar.elements["defval"]
58
- param.push(type+" "+xpar.elements["declname"].text+" = "+xpar.elements["defval"].to_s.gsub(/<.+?>/,""))
59
+ param.push(xpar.elements["declname"].text+" = "+xpar.elements["defval"].to_s.gsub(/<.+?>/,""))
59
60
  else
60
- param.push(type+" "+xpar.elements["declname"].text)
61
+ param.push(xpar.elements["declname"].text)
61
62
  end
62
63
  }
63
64
  funcs[name]={:param=>param,:brief_desc=>brief,:long_desc=>long}
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby
2
2
  require 'fileutils'
3
- file="pre_taglib"
4
- out="taglib.cxx"
3
+ file="pre_taglib_#{PLATFORM}"
4
+ out="taglib_#{PLATFORM}.cxx"
5
5
  fo=File.open(out,"wb")
6
6
  swig_p={}
7
7
  File.open(file,"r") {|f| f.each_line {|l|
@@ -0,0 +1,33 @@
1
+ require 'mkmf'
2
+ if(PLATFORM=~/mswin32/)
3
+ if(File.expand_path(File.dirname(__FILE__))=~/swig/)
4
+ package_dir=File.expand_path(File.dirname(__FILE__)+"/..")
5
+ prefix=package_dir+"/ext/taglib/taglib-mswin32"
6
+ else
7
+ prefix="./taglib-mswin32"
8
+ end
9
+ puts "Building for MsWin32"
10
+ $CFLAGS+= " -I\"#{prefix}\\include\" -I\"#{prefix}\\include\\taglib\""
11
+ $LDFLAGS += " -link -libpath:\"#{prefix}\\lib\" "
12
+
13
+ elsif(PLATFORM=~/mingw/)
14
+ puts "Building for MinGW"
15
+ $libs = append_library($libs, "stdc++")
16
+ $libs = append_library($libs, "supc++")
17
+ $CFLAGS= " -I/mingw/include/taglib"
18
+ else
19
+ puts "Building for other architecture"
20
+ taglib_config = find_executable("taglib-config")
21
+ if taglib_config
22
+ prefix = `#{taglib_config} --prefix`.strip
23
+ $CFLAGS += " -I#{prefix}/include"
24
+ $LDFLAGS += " -L#{prefix}/lib"
25
+ else
26
+ prefix = "/usr"
27
+ end
28
+ $libs = append_library($libs, "supc++")
29
+ $CFLAGS += " -I#{prefix}/include/taglib"
30
+ end
31
+ if have_library("tag")
32
+ create_makefile("TagLib")
33
+ end
@@ -198,11 +198,11 @@ namespace TagLib {
198
198
  %typemap(out) String {
199
199
  $result = String2Ruby(&$1);
200
200
  };
201
-
201
+ /**
202
202
  %typemap(in) String {
203
- $1=new TagLib::String(StringValuePtr($input));
203
+ $1=new TagLib::String(StringValuePtr($input), TagLib::String::UTF8);
204
204
  };
205
-
205
+ */
206
206
 
207
207
  %apply String {String &, const String &};
208
208
  %typemap(in) ByteVector {
@@ -233,12 +233,12 @@ class AudioProperties {
233
233
  PROPERTIES_VIRTUALS()
234
234
  };
235
235
  class String {
236
-
236
+ public:
237
237
  enum Type {
238
238
  Latin1 = 0, UTF16 = 1, UTF16BE = 2, UTF8 = 3,
239
239
  UTF16LE = 4
240
240
  };
241
- public:
241
+
242
242
  String();
243
243
  String(const char *s, Type t=Latin1);
244
244
  ~String();
@@ -739,6 +739,9 @@ class File {
739
739
 
740
740
  const FrameListMap& frameListMap() const;
741
741
  const FrameList& frameList() const;
742
+ void removeFrame(Frame * frame, bool del = true);
743
+
744
+
742
745
  };
743
746
  };
744
747
 
@@ -1,17 +1,12 @@
1
1
  #!/usr/bin/ruby
2
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
3
+ require 'TagLib'
2
4
  require 'tmpdir'
3
- if File.exists? File.dirname(__FILE__)+"/TagLib.so"
4
- require File.dirname(__FILE__)+'/TagLib'
5
- BASE_DATA=File.dirname(__FILE__)+"/../test/data/"
6
- else
7
- require File.dirname(__FILE__)+'/../ext/taglib/TagLib'
8
- BASE_DATA=File.dirname(__FILE__)+"/data/"
9
- end
10
5
  require 'fileutils'
11
6
  require 'test/unit'
12
7
  class RtaglibReadTestCase < Test::Unit::TestCase
13
8
  def setup
14
- @data_dir=BASE_DATA
9
+ @data_dir=File.dirname(__FILE__)+"/../data/"
15
10
  @temp_dir=Dir::tmpdir+"/rtaglib"
16
11
  FileUtils.mkdir(@temp_dir) if !File.exists? @temp_dir
17
12
  FileUtils.chmod(0777, @temp_dir)
@@ -80,7 +75,6 @@ class RtaglibReadTestCase < Test::Unit::TestCase
80
75
  # - audioproperties: bitrate,channels,sampleRate and channels
81
76
  # - isNull (null?)
82
77
  def test_fileref
83
-
84
78
  assert_equal(%w{ogg flac oga mp3 mpc wv spx tta}, TagLib::FileRef.defaultFileExtensions())
85
79
  bitrate={'flac'=>168,'wv'=>235,'mp3'=>48,'mpc'=>41,'ogg'=>80}
86
80
  channels={'flac'=>1,'wv'=>1,'mp3'=>1,'mpc'=>2,'ogg'=>1}
@@ -107,17 +101,17 @@ class RtaglibReadTestCase < Test::Unit::TestCase
107
101
  mp3=@data_dir+"440Hz-5sec.mp3"
108
102
  copy=get_copy(mp3)
109
103
  fr2=TagLib::FileRef.new(copy)
110
- fr2.tag().title="new title";
111
- fr2.tag().artist="new artist";
112
- fr2.tag().album="new album";
104
+ fr2.tag().title=TagLib::String.new("new title");
105
+ fr2.tag().artist=TagLib::String.new("new artist");
106
+ fr2.tag().album=TagLib::String.new("new album");
113
107
  fr2.tag().year=2000;
114
108
  fr2.tag().track=10;
115
- fr2.tag().genre="Rock";
116
- fr2.tag().comment="new comment";
109
+ fr2.tag().genre=TagLib::String.new("Rock");
110
+ fr2.tag().comment=TagLib::String.new("new comment");
117
111
 
118
112
  fr2.save()
119
113
  copy2=get_copy(copy)
120
- fr2.tag().title="sfsd"
114
+ fr2.tag().title=TagLib::String.new("sfsd")
121
115
  fr2.save()
122
116
  fr3=TagLib::FileRef.new(copy2)
123
117
  assert_equal("new title",fr3.tag.title)
@@ -139,7 +133,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
139
133
  fr=TagLib::FileRef.new(copy)
140
134
  utf8_string="大塚愛"
141
135
  expected="\345\244\247\345\241\232\346\204\233"
142
- fr.tag().title=utf8_string
136
+ fr.tag().title=TagLib::String.new(utf8_string)
143
137
  fr.save
144
138
  fr=nil
145
139
  fr=TagLib::FileRef.new(copy)
@@ -149,18 +143,25 @@ class RtaglibReadTestCase < Test::Unit::TestCase
149
143
  s=get_copy(mp3)
150
144
  d=get_copy(mp3)
151
145
  s_tag=TagLib::FileRef.new(s)
152
- d_tag=TagLib::FileRef.new(d)
146
+ d_tag=TagLib::MPEG::File.new(d)
153
147
  artist="大塚愛"
154
148
  # puts "artist = #{artist} => #{artist.inspect}"
155
149
  assert_equal(artist,s_tag.tag.artist)
156
- assert_equal(artist,d_tag.tag.artist)
157
- d_tag.tag.artist=s_tag.tag.artist
158
- assert_equal(d_tag.tag.artist, s_tag.tag.artist)
150
+ assert_equal(artist,d_tag.ID3v2Tag.artist)
151
+ d_tag.ID3v2Tag.artist=TagLib::String.new(s_tag.tag.artist)
152
+ assert_equal(d_tag.ID3v2Tag.artist, s_tag.tag.artist)
159
153
  d_tag.save
154
+ d_tag=nil
160
155
  d_tag=TagLib::FileRef.new(d)
156
+ assert_equal(artist, d_tag.tag.artist)
161
157
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
162
-
163
-
158
+ =begin
159
+ if(`which id3info`)
160
+ `id3info #{s}` =~ /^=== TPE1.+: (.+)$/
161
+ vc_out=$1
162
+ assert_equal(artist,vc_out,"id3info output (#{vc_out}) not equal to #{artist}")
163
+ end
164
+ =end
164
165
 
165
166
  ogg=@data_dir+"test_jason.ogg"
166
167
  s=get_copy(ogg)
@@ -168,15 +169,22 @@ class RtaglibReadTestCase < Test::Unit::TestCase
168
169
  s_tag=TagLib::FileRef.new(s)
169
170
  d_tag=TagLib::FileRef.new(d)
170
171
  artist="大塚愛"
171
- # puts "artist = #{artist} => #{artist.inspect}"
172
172
  assert_equal(artist,s_tag.tag.artist)
173
173
  assert_equal(artist,d_tag.tag.artist)
174
- d_tag.tag.artist=s_tag.tag.artist
174
+ d_tag.tag.artist=TagLib::String.new(s_tag.tag.artist,TagLib::String::UTF8)
175
175
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
176
176
  d_tag.save
177
177
  d_tag=TagLib::FileRef.new(d)
178
178
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
179
-
179
+ if PLATFORM=~/mswin/
180
+ else
181
+ if(`which vorbiscomment`)
182
+ `vorbiscomment #{d}` =~ /^ARTIST=(.+)$/
183
+ vc_out=$1
184
+ assert_equal(artist,vc_out,"vorbiscomment output (#{vc_out}) not equal to #{artist}")
185
+ end
186
+ end
187
+
180
188
  end
181
189
  def test_flac
182
190
  original=@data_dir+"440Hz-5sec.flac"
@@ -199,7 +207,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
199
207
  assert_equal(16,ap.sampleWidth)
200
208
  # comments
201
209
  xiph=flac_xiph.xiphComment()
202
- xiph.setTitle("xiph")
210
+ xiph.setTitle(TagLib::String.new("xiph"))
203
211
  flac_xiph.save()
204
212
  assert_equal("xiph",flac_xiph.tag().title)
205
213
  assert_nil(flac_xiph.ID3v1Tag())
@@ -207,7 +215,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
207
215
 
208
216
  id1=flac_id1.ID3v1Tag(true)
209
217
 
210
- id1.setTitle("id1")
218
+ id1.setTitle(TagLib::String.new("id1"))
211
219
  flac_id1.save()
212
220
  assert_equal("id1",id1.title)
213
221
 
@@ -216,7 +224,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
216
224
 
217
225
 
218
226
  id2=flac_id2.ID3v2Tag(true)
219
- id2.setTitle("id2")
227
+ id2.setTitle(TagLib::String.new("id2"))
220
228
  flac_id2.save()
221
229
  assert_equal("id2",id2.title)
222
230
 
@@ -260,14 +268,14 @@ class RtaglibReadTestCase < Test::Unit::TestCase
260
268
  original=@data_dir+"440Hz-5sec.mpc"
261
269
  copy=get_copy(original)
262
270
  fr=TagLib::FileRef.new(copy)
263
- fr.tag.title="440Hz Sine Wave"
271
+ fr.tag.title=TagLib::String.new("440Hz Sine Wave")
264
272
  fr.save
265
273
  mpc=TagLib::MPC::File.new(copy)
266
274
  %w{tag APETag}.each {|f|
267
275
  assert_equal("440Hz Sine Wave",mpc.send(f).title, "#{f} tag")
268
276
  }
269
277
  mpc=TagLib::MPC::File.new(copy)
270
- mpc.ID3v1Tag(true).title="440Hz Sine Wave - id3"
278
+ mpc.ID3v1Tag(true).title=TagLib::String.new("440Hz Sine Wave - id3")
271
279
  mpc.save
272
280
  mpc=nil
273
281
  mpc=TagLib::MPC::File.new(copy)
@@ -303,10 +311,10 @@ class RtaglibReadTestCase < Test::Unit::TestCase
303
311
 
304
312
  def test_fieldmap
305
313
  fl=TagLib::FieldListMap.new()
306
- fl.insert("key",["val1","val2"])
307
- assert_equal(["val1","val2"],fl["key"])
308
- assert_nil(fl["2"])
309
- fl.insert("key2",["val3","val4"])
314
+ fl.insert(TagLib::String.new("key"),["val1","val2"])
315
+ assert_equal(["val1","val2"],fl[TagLib::String.new("key")])
316
+ assert_nil(fl[TagLib::String.new("2")])
317
+ fl.insert(TagLib::String.new("key2"),["val3","val4"])
310
318
  assert_equal({'key'=>["val1","val2"],"key2"=>["val3","val4"]}, fl.hash)
311
319
  assert_equal(fl.size,fl.length)
312
320
  end
@@ -317,13 +325,13 @@ class RtaglibReadTestCase < Test::Unit::TestCase
317
325
  xc=flac_xiph.xiphComment
318
326
  fl=xc.fieldListMap
319
327
  fl.hash.each {|k,v|
320
- xc.removeField(k)
328
+ xc.removeField(TagLib::String.new(k))
321
329
  }
322
330
  assert(xc.empty?)
323
- xc.setTitle("T")
324
- xc.setArtist("A")
325
- xc.addField("c","C1",false)
326
- xc.addField("c","C2",false)
331
+ xc.setTitle(TagLib::String.new("T"))
332
+ xc.setArtist(TagLib::String.new("A"))
333
+ xc.addField(TagLib::String.new("c"),TagLib::String.new("C1"),false)
334
+ xc.addField(TagLib::String.new("c"),TagLib::String.new("C2"),false)
327
335
  expected={"TITLE"=>["T"],"ARTIST"=>["A"],"C"=>["C1","C2"]}
328
336
  assert_equal(expected,fl.hash)
329
337
  end
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require File.dirname(__FILE__)+'/../ext/tagfile/tagfile'
2
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
3
+ $:.unshift(File.dirname(__FILE__)+"/../ext")
4
+ require 'tagfile'
4
5
  require 'test/unit'
5
6
  class RTagFileReadTestCase < Test::Unit::TestCase
6
7
  def setup
7
8
 
8
- @file=::TagFile::File.new(File.dirname(__FILE__)+"/data/440Hz-5sec.mp3")
9
+ @file=::TagFile::File.new(File.dirname(__FILE__)+"/../data/440Hz-5sec.mp3")
9
10
  end
10
11
  def test_title()
11
12
  assert_equal("440Hz Sine Wave",@file.title)
@@ -1,17 +1,12 @@
1
1
  #!/usr/bin/ruby
2
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
3
+ require 'TagLib'
2
4
  require 'tmpdir'
3
- if File.exists? File.dirname(__FILE__)+"/TagLib.so"
4
- require File.dirname(__FILE__)+'/TagLib'
5
- BASE_DATA=File.dirname(__FILE__)+"/../test/data/"
6
- else
7
- require File.dirname(__FILE__)+'/../ext/taglib/TagLib'
8
- BASE_DATA=File.dirname(__FILE__)+"/data/"
9
- end
10
5
  require 'fileutils'
11
6
  require 'test/unit'
12
7
  class RtaglibReadTestCase < Test::Unit::TestCase
13
8
  def setup
14
- @data_dir=BASE_DATA
9
+ @data_dir=File.dirname(__FILE__)+"/../data/"
15
10
  @temp_dir=Dir::tmpdir+"/rtaglib"
16
11
  FileUtils.mkdir(@temp_dir) if !File.exists? @temp_dir
17
12
  FileUtils.chmod(0777, @temp_dir)
@@ -80,7 +75,6 @@ class RtaglibReadTestCase < Test::Unit::TestCase
80
75
  # - audioproperties: bitrate,channels,sampleRate and channels
81
76
  # - isNull (null?)
82
77
  def test_fileref
83
-
84
78
  assert_equal(%w{ogg flac oga mp3 mpc wv spx tta}, TagLib::FileRef.defaultFileExtensions())
85
79
  bitrate={'flac'=>168,'wv'=>235,'mp3'=>48,'mpc'=>41,'ogg'=>80}
86
80
  channels={'flac'=>1,'wv'=>1,'mp3'=>1,'mpc'=>2,'ogg'=>1}
@@ -107,17 +101,17 @@ class RtaglibReadTestCase < Test::Unit::TestCase
107
101
  mp3=@data_dir+"440Hz-5sec.mp3"
108
102
  copy=get_copy(mp3)
109
103
  fr2=TagLib::FileRef.new(copy)
110
- fr2.tag().title="new title";
111
- fr2.tag().artist="new artist";
112
- fr2.tag().album="new album";
104
+ fr2.tag().title=TagLib::String.new("new title");
105
+ fr2.tag().artist=TagLib::String.new("new artist");
106
+ fr2.tag().album=TagLib::String.new("new album");
113
107
  fr2.tag().year=2000;
114
108
  fr2.tag().track=10;
115
- fr2.tag().genre="Rock";
116
- fr2.tag().comment="new comment";
109
+ fr2.tag().genre=TagLib::String.new("Rock");
110
+ fr2.tag().comment=TagLib::String.new("new comment");
117
111
 
118
112
  fr2.save()
119
113
  copy2=get_copy(copy)
120
- fr2.tag().title="sfsd"
114
+ fr2.tag().title=TagLib::String.new("sfsd")
121
115
  fr2.save()
122
116
  fr3=TagLib::FileRef.new(copy2)
123
117
  assert_equal("new title",fr3.tag.title)
@@ -139,7 +133,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
139
133
  fr=TagLib::FileRef.new(copy)
140
134
  utf8_string="大塚愛"
141
135
  expected="\345\244\247\345\241\232\346\204\233"
142
- fr.tag().title=utf8_string
136
+ fr.tag().title=TagLib::String.new(utf8_string)
143
137
  fr.save
144
138
  fr=nil
145
139
  fr=TagLib::FileRef.new(copy)
@@ -149,18 +143,25 @@ class RtaglibReadTestCase < Test::Unit::TestCase
149
143
  s=get_copy(mp3)
150
144
  d=get_copy(mp3)
151
145
  s_tag=TagLib::FileRef.new(s)
152
- d_tag=TagLib::FileRef.new(d)
146
+ d_tag=TagLib::MPEG::File.new(d)
153
147
  artist="大塚愛"
154
148
  # puts "artist = #{artist} => #{artist.inspect}"
155
149
  assert_equal(artist,s_tag.tag.artist)
156
- assert_equal(artist,d_tag.tag.artist)
157
- d_tag.tag.artist=s_tag.tag.artist
158
- assert_equal(d_tag.tag.artist, s_tag.tag.artist)
150
+ assert_equal(artist,d_tag.ID3v2Tag.artist)
151
+ d_tag.ID3v2Tag.artist=TagLib::String.new(s_tag.tag.artist)
152
+ assert_equal(d_tag.ID3v2Tag.artist, s_tag.tag.artist)
159
153
  d_tag.save
154
+ d_tag=nil
160
155
  d_tag=TagLib::FileRef.new(d)
156
+ assert_equal(artist, d_tag.tag.artist)
161
157
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
162
-
163
-
158
+ =begin
159
+ if(`which id3info`)
160
+ `id3info #{s}` =~ /^=== TPE1.+: (.+)$/
161
+ vc_out=$1
162
+ assert_equal(artist,vc_out,"id3info output (#{vc_out}) not equal to #{artist}")
163
+ end
164
+ =end
164
165
 
165
166
  ogg=@data_dir+"test_jason.ogg"
166
167
  s=get_copy(ogg)
@@ -168,15 +169,22 @@ class RtaglibReadTestCase < Test::Unit::TestCase
168
169
  s_tag=TagLib::FileRef.new(s)
169
170
  d_tag=TagLib::FileRef.new(d)
170
171
  artist="大塚愛"
171
- # puts "artist = #{artist} => #{artist.inspect}"
172
172
  assert_equal(artist,s_tag.tag.artist)
173
173
  assert_equal(artist,d_tag.tag.artist)
174
- d_tag.tag.artist=s_tag.tag.artist
174
+ d_tag.tag.artist=TagLib::String.new(s_tag.tag.artist,TagLib::String::UTF8)
175
175
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
176
176
  d_tag.save
177
177
  d_tag=TagLib::FileRef.new(d)
178
178
  assert_equal(d_tag.tag.artist, s_tag.tag.artist)
179
-
179
+ if PLATFORM=~/mswin/
180
+ else
181
+ if(`which vorbiscomment`)
182
+ `vorbiscomment #{d}` =~ /^ARTIST=(.+)$/
183
+ vc_out=$1
184
+ assert_equal(artist,vc_out,"vorbiscomment output (#{vc_out}) not equal to #{artist}")
185
+ end
186
+ end
187
+
180
188
  end
181
189
  def test_flac
182
190
  original=@data_dir+"440Hz-5sec.flac"
@@ -199,7 +207,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
199
207
  assert_equal(16,ap.sampleWidth)
200
208
  # comments
201
209
  xiph=flac_xiph.xiphComment()
202
- xiph.setTitle("xiph")
210
+ xiph.setTitle(TagLib::String.new("xiph"))
203
211
  flac_xiph.save()
204
212
  assert_equal("xiph",flac_xiph.tag().title)
205
213
  assert_nil(flac_xiph.ID3v1Tag())
@@ -207,7 +215,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
207
215
 
208
216
  id1=flac_id1.ID3v1Tag(true)
209
217
 
210
- id1.setTitle("id1")
218
+ id1.setTitle(TagLib::String.new("id1"))
211
219
  flac_id1.save()
212
220
  assert_equal("id1",id1.title)
213
221
 
@@ -216,7 +224,7 @@ class RtaglibReadTestCase < Test::Unit::TestCase
216
224
 
217
225
 
218
226
  id2=flac_id2.ID3v2Tag(true)
219
- id2.setTitle("id2")
227
+ id2.setTitle(TagLib::String.new("id2"))
220
228
  flac_id2.save()
221
229
  assert_equal("id2",id2.title)
222
230
 
@@ -260,14 +268,14 @@ class RtaglibReadTestCase < Test::Unit::TestCase
260
268
  original=@data_dir+"440Hz-5sec.mpc"
261
269
  copy=get_copy(original)
262
270
  fr=TagLib::FileRef.new(copy)
263
- fr.tag.title="440Hz Sine Wave"
271
+ fr.tag.title=TagLib::String.new("440Hz Sine Wave")
264
272
  fr.save
265
273
  mpc=TagLib::MPC::File.new(copy)
266
274
  %w{tag APETag}.each {|f|
267
275
  assert_equal("440Hz Sine Wave",mpc.send(f).title, "#{f} tag")
268
276
  }
269
277
  mpc=TagLib::MPC::File.new(copy)
270
- mpc.ID3v1Tag(true).title="440Hz Sine Wave - id3"
278
+ mpc.ID3v1Tag(true).title=TagLib::String.new("440Hz Sine Wave - id3")
271
279
  mpc.save
272
280
  mpc=nil
273
281
  mpc=TagLib::MPC::File.new(copy)
@@ -303,10 +311,10 @@ class RtaglibReadTestCase < Test::Unit::TestCase
303
311
 
304
312
  def test_fieldmap
305
313
  fl=TagLib::FieldListMap.new()
306
- fl.insert("key",["val1","val2"])
307
- assert_equal(["val1","val2"],fl["key"])
308
- assert_nil(fl["2"])
309
- fl.insert("key2",["val3","val4"])
314
+ fl.insert(TagLib::String.new("key"),["val1","val2"])
315
+ assert_equal(["val1","val2"],fl[TagLib::String.new("key")])
316
+ assert_nil(fl[TagLib::String.new("2")])
317
+ fl.insert(TagLib::String.new("key2"),["val3","val4"])
310
318
  assert_equal({'key'=>["val1","val2"],"key2"=>["val3","val4"]}, fl.hash)
311
319
  assert_equal(fl.size,fl.length)
312
320
  end
@@ -317,13 +325,13 @@ class RtaglibReadTestCase < Test::Unit::TestCase
317
325
  xc=flac_xiph.xiphComment
318
326
  fl=xc.fieldListMap
319
327
  fl.hash.each {|k,v|
320
- xc.removeField(k)
328
+ xc.removeField(TagLib::String.new(k))
321
329
  }
322
330
  assert(xc.empty?)
323
- xc.setTitle("T")
324
- xc.setArtist("A")
325
- xc.addField("c","C1",false)
326
- xc.addField("c","C2",false)
331
+ xc.setTitle(TagLib::String.new("T"))
332
+ xc.setArtist(TagLib::String.new("A"))
333
+ xc.addField(TagLib::String.new("c"),TagLib::String.new("C1"),false)
334
+ xc.addField(TagLib::String.new("c"),TagLib::String.new("C2"),false)
327
335
  expected={"TITLE"=>["T"],"ARTIST"=>["A"],"C"=>["C1","C2"]}
328
336
  assert_equal(expected,fl.hash)
329
337
  end