id3lib-ruby 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. data/CHANGES +9 -1
  2. data/README +5 -1
  3. data/Rakefile +24 -13
  4. data/TODO +0 -1
  5. data/lib/id3lib.rb +7 -5
  6. data/lib/id3lib/info.rb +157 -21
  7. metadata +35 -34
data/CHANGES CHANGED
@@ -1,8 +1,16 @@
1
1
  = id3lib-ruby changes
2
2
 
3
+ === 0.3.0 (r29)
4
+
5
+ * Added generation of mswin32 binary gem. This means that
6
+ installing on Windows is a piece of cake. No dependencies, no
7
+ compiling, just a gem installation.
8
+ * Changed Info.frame to use hash access instead of find -> faster.
9
+
3
10
  === 0.2.1 (r23)
4
11
 
5
- * Fixed extconf.rb to print a message and abort if id3lib can't be found.
12
+ * Fixed extconf.rb to print a message and abort if id3lib can't be
13
+ found.
6
14
 
7
15
  === 0.2.0 (r21)
8
16
 
data/README CHANGED
@@ -15,6 +15,7 @@ The class documentation starts at ID3Lib::Tag.
15
15
  * Custom data frames like attached picture (APIC)
16
16
  * Pretty complete coverage of id3lib's features
17
17
  * UTF-16 support
18
+ * Windows binary gem available
18
19
 
19
20
  See TODO for planned features.
20
21
 
@@ -28,7 +29,10 @@ The home of id3lib-ruby is http://id3lib-ruby.rubyforge.org
28
29
 
29
30
  == Installation
30
31
 
31
- Installation through Rubygems:
32
+ Note that id3lib has to be installed before running any of the following
33
+ commands, unless you use the Windows binary gem.
34
+
35
+ Installation through RubyGems:
32
36
 
33
37
  gem install id3lib-ruby
34
38
 
data/Rakefile CHANGED
@@ -10,12 +10,10 @@ require 'rake/testtask'
10
10
  require 'rake/rdoctask'
11
11
 
12
12
 
13
- PKG_VERSION = '0.2.1'
13
+ PKG_VERSION = '0.3.0'
14
14
 
15
- PKG_FILES = FileList[
15
+ PKG_COMMON = FileList[
16
16
  'lib/**/*.rb',
17
- 'ext/extconf.rb',
18
- 'ext/*.cxx',
19
17
  'test/test_*.rb',
20
18
  'test/data/*.mp3',
21
19
  'test/data/cover.jpg',
@@ -24,16 +22,18 @@ PKG_FILES = FileList[
24
22
  ]
25
23
 
26
24
 
27
- desc 'Default task is to build extension.'
28
- task :default => [:ext]
29
-
30
-
31
25
  desc "Build extension."
32
26
  task :ext do
33
27
  sh "cd ext && rake"
34
28
  puts "(end)"
35
29
  end
36
30
 
31
+ desc "Build mswin32 extension."
32
+ task :ext_mswin32 do
33
+ sh 'cd ext/mswin32; rake'
34
+ puts "(end)"
35
+ end
36
+
37
37
 
38
38
  Rake::TestTask.new do |t|
39
39
  t.libs = ['lib', 'ext']
@@ -63,7 +63,7 @@ if defined? Gem
63
63
  'id3lib-ruby provides a Ruby interface to the id3lib C++ library for ' +
64
64
  'easily editing ID3 tags (v1 and v2) like with pyid3lib.'
65
65
  s.requirements << 'id3lib C++ library'
66
- s.files = PKG_FILES
66
+ s.files = PKG_COMMON + FileList['ext/extconf.rb', 'ext/*.cxx']
67
67
  s.extensions = ['ext/extconf.rb']
68
68
  s.test_files = FileList['test/test_*.rb']
69
69
  s.has_rdoc = true
@@ -79,7 +79,21 @@ if defined? Gem
79
79
  pkg.need_tar_gz = true
80
80
  pkg.need_zip = true
81
81
  end
82
- end
82
+
83
+ spec_mswin32 = spec.clone
84
+ spec_mswin32.files = PKG_COMMON + FileList['ext/mswin32/id3lib_api.so']
85
+ spec_mswin32.extensions = []
86
+ spec_mswin32.require_paths = ['lib', 'ext/mswin32']
87
+ spec_mswin32.platform = Gem::Platform::WIN32
88
+
89
+ desc "Build mswin32 gem."
90
+ task :gem_mswin32 => [:ext_mswin32] do
91
+ Gem::Builder.new(spec_mswin32).build
92
+ mkdir_p "pkg"
93
+ mv "id3lib-ruby-#{PKG_VERSION}-mswin32.gem", "pkg/"
94
+ end
95
+
96
+ end # defined? Gem
83
97
 
84
98
 
85
99
  task :web => [:web_doc] do
@@ -97,12 +111,9 @@ Rake::RDocTask.new :web_doc do |rdoc|
97
111
  rdoc.rdoc_files.include('lib/**/*.rb')
98
112
  end
99
113
 
100
-
101
114
  task :usage_html do
102
115
  require 'syntax/convertors/html'
103
-
104
116
  convertor = Syntax::Convertors::HTML.for_syntax('ruby')
105
117
  html = convertor.convert(File.read('usage.rb'))
106
-
107
118
  puts html
108
119
  end
data/TODO CHANGED
@@ -1,5 +1,4 @@
1
1
  = id3lib-ruby to-do list
2
2
 
3
- * Create Windows binary gem (id3lib.dll included).
4
3
  * Evaluate a more object-oriented way to handle frames, instead of hashes.
5
4
  * Add UTF-8 support if id3lib can handle it.
data/lib/id3lib.rb CHANGED
@@ -327,7 +327,7 @@ module ID3Lib
327
327
 
328
328
  def self.read(libframe)
329
329
  frame = {}
330
- info = Info.frame(libframe.num)
330
+ info = Info.frame_num(libframe.num)
331
331
  frame[:id] = info[ID]
332
332
  if info[FIELDS].include?(:textenc)
333
333
  textenc = field(libframe, :textenc).integer
@@ -350,16 +350,18 @@ module ID3Lib
350
350
  end
351
351
 
352
352
  def self.write(frame, libframe)
353
- textenc = frame[:textenc]
354
- field(libframe, :textenc).set_integer(textenc) if textenc
353
+ if textenc = frame[:textenc]
354
+ field(libframe, :textenc).set_integer(textenc)
355
+ end
355
356
  frame.each do |field_id, value|
357
+ next if field_id == :textenc
356
358
  unless Info.frame(frame[:id])[FIELDS].include?(field_id)
357
- # TODO: Add method to check if frames are valid.
359
+ # Ignore invalid fields
358
360
  next
359
361
  end
360
- next if field_id == :textenc
361
362
  libfield = field(libframe, field_id)
362
363
  if textenc and textenc > 0
364
+ # Special treatment for Unicode
363
365
  libfield.set_encoding(textenc)
364
366
  libfield.set_unicode(value)
365
367
  else
data/lib/id3lib/info.rb CHANGED
@@ -55,33 +55,39 @@ module ID3Lib
55
55
  #
56
56
  module Info
57
57
 
58
+ #
59
+ # Please note that these frames are not fully supported by id3lib:
60
+ # AENC, ASPI, COMR, EQUA, ETCO, LINK, MLLT,
61
+ # OWNE, POSS, RBUF, RVA2, RVAD, RVRB, SEEK
62
+ #
58
63
  Frames = [
59
64
  # Special frames
60
- [1, :AENC, "Audio encryption", [:owner, :data]], # not fully supported by id3lib
65
+ [0, :____, "No known frame", []],
66
+ [1, :AENC, "Audio encryption", [:owner, :data]],
61
67
  [2, :APIC, "Attached picture", [:textenc, :mimetype, :picturetype, :description, :data]],
62
- [3, :ASPI, "Audio seek point index", [:data]], # not fully supported by id3lib
68
+ [3, :ASPI, "Audio seek point index", [:data]],
63
69
  [4, :COMM, "Comments", [:textenc, :language, :description, :text]],
64
- [5, :COMR, "Commercial frame", [:data]], # not fully supported by id3lib
70
+ [5, :COMR, "Commercial frame", [:data]],
65
71
  [6, :ENCR, "Encryption method registration", [:owner, :id, :data]],
66
72
  [7, :EQU2, "Equalisation (2)", [:id, :text]],
67
- [8, :EQUA, "Equalization", [:data]], # not fully supported by id3lib
68
- [9, :ETCO, "Event timing codes", [:data]], # not fully supported by id3lib
73
+ [8, :EQUA, "Equalization", [:data]],
74
+ [9, :ETCO, "Event timing codes", [:data]],
69
75
  [10, :GEOB, "General encapsulated object", [:textenc, :mimetype, :filename, :description, :data]],
70
76
  [11, :GRID, "Group identification registration", [:owner, :id, :data]],
71
77
  [12, :IPLS, "Involved people list", [:textenc, :text]],
72
- [13, :LINK, "Linked information", [:data]], # not fully supported by id3lib
78
+ [13, :LINK, "Linked information", [:data]],
73
79
  [14, :MCDI, "Music CD identifier", [:data]],
74
- [15, :MLLT, "MPEG location lookup table", [:data]], # not fully supported by id3lib
75
- [16, :OWNE, "Ownership frame", [:data]], # not fully supported by id3lib
80
+ [15, :MLLT, "MPEG location lookup table", [:data]],
81
+ [16, :OWNE, "Ownership frame", [:data]],
76
82
  [17, :PRIV, "Private frame", [:owner, :data]],
77
83
  [18, :PCNT, "Play counter", [:counter]],
78
84
  [19, :POPM, "Popularimeter", [:email, :rating, :counter]],
79
- [20, :POSS, "Position synchronisation frame", [:data]], # not fully supported by id3lib
80
- [21, :RBUF, "Recommended buffer size", [:data]], # not fully supported by id3lib
81
- [22, :RVA2, "Relative volume adjustment (2)", [:data]], # not fully supported by id3lib
82
- [23, :RVAD, "Relative volume adjustment", [:data]], # not fully supported by id3lib
83
- [24, :RVRB, "Reverb", [:data]], # not fully supported by id3lib
84
- [25, :SEEK, "Seek frame", [:data]], # not fully supported by id3lib
85
+ [20, :POSS, "Position synchronisation frame", [:data]],
86
+ [21, :RBUF, "Recommended buffer size", [:data]],
87
+ [22, :RVA2, "Relative volume adjustment (2)", [:data]],
88
+ [23, :RVAD, "Relative volume adjustment", [:data]],
89
+ [24, :RVRB, "Reverb", [:data]],
90
+ [25, :SEEK, "Seek frame", [:data]],
85
91
  [26, :SIGN, "Signature frame", [:id, :data]],
86
92
  [27, :SYLT, "Synchronized lyric/text", [:textenc, :language, :timestampformat, :contenttype, :description, :data]],
87
93
  [28, :SYTC, "Synchronized tempo codes", [:timestampformat, :data]],
@@ -151,8 +157,104 @@ module ID3Lib
151
157
  [89, :WORS, "Official internet radio station homepage", [:text]],
152
158
  [90, :WPAY, "Payment", [:text]],
153
159
  [91, :WPUB, "Official publisher webpage", [:text]],
154
- [92, :WXXX, "User defined URL link", [:textenc, :description, :url]]
160
+ [92, :WXXX, "User defined URL link", [:textenc, :description, :url]],
155
161
  ]
162
+
163
+ FramesByID = {
164
+ :____ => Frames[0],
165
+ :AENC => Frames[1],
166
+ :APIC => Frames[2],
167
+ :ASPI => Frames[3],
168
+ :COMM => Frames[4],
169
+ :COMR => Frames[5],
170
+ :ENCR => Frames[6],
171
+ :EQU2 => Frames[7],
172
+ :EQUA => Frames[8],
173
+ :ETCO => Frames[9],
174
+ :GEOB => Frames[10],
175
+ :GRID => Frames[11],
176
+ :IPLS => Frames[12],
177
+ :LINK => Frames[13],
178
+ :MCDI => Frames[14],
179
+ :MLLT => Frames[15],
180
+ :OWNE => Frames[16],
181
+ :PRIV => Frames[17],
182
+ :PCNT => Frames[18],
183
+ :POPM => Frames[19],
184
+ :POSS => Frames[20],
185
+ :RBUF => Frames[21],
186
+ :RVA2 => Frames[22],
187
+ :RVAD => Frames[23],
188
+ :RVRB => Frames[24],
189
+ :SEEK => Frames[25],
190
+ :SIGN => Frames[26],
191
+ :SYLT => Frames[27],
192
+ :SYTC => Frames[28],
193
+ :TALB => Frames[29],
194
+ :TBPM => Frames[30],
195
+ :TCOM => Frames[31],
196
+ :TCON => Frames[32],
197
+ :TCOP => Frames[33],
198
+ :TDAT => Frames[34],
199
+ :TDEN => Frames[35],
200
+ :TDLY => Frames[36],
201
+ :TDOR => Frames[37],
202
+ :TDRC => Frames[38],
203
+ :TDRL => Frames[39],
204
+ :TDTG => Frames[40],
205
+ :TIPL => Frames[41],
206
+ :TENC => Frames[42],
207
+ :TEXT => Frames[43],
208
+ :TFLT => Frames[44],
209
+ :TIME => Frames[45],
210
+ :TIT1 => Frames[46],
211
+ :TIT2 => Frames[47],
212
+ :TIT3 => Frames[48],
213
+ :TKEY => Frames[49],
214
+ :TLAN => Frames[50],
215
+ :TLEN => Frames[51],
216
+ :TMCL => Frames[52],
217
+ :TMED => Frames[53],
218
+ :TMOO => Frames[54],
219
+ :TOAL => Frames[55],
220
+ :TOFN => Frames[56],
221
+ :TOLY => Frames[57],
222
+ :TOPE => Frames[58],
223
+ :TORY => Frames[59],
224
+ :TOWN => Frames[60],
225
+ :TPE1 => Frames[61],
226
+ :TPE2 => Frames[62],
227
+ :TPE3 => Frames[63],
228
+ :TPE4 => Frames[64],
229
+ :TPOS => Frames[65],
230
+ :TPRO => Frames[66],
231
+ :TPUB => Frames[67],
232
+ :TRCK => Frames[68],
233
+ :TRDA => Frames[69],
234
+ :TRSN => Frames[70],
235
+ :TRSO => Frames[71],
236
+ :TSIZ => Frames[72],
237
+ :TSOA => Frames[73],
238
+ :TSOP => Frames[74],
239
+ :TSOT => Frames[75],
240
+ :TSRC => Frames[76],
241
+ :TSSE => Frames[77],
242
+ :TSST => Frames[78],
243
+ :TXXX => Frames[79],
244
+ :TYER => Frames[80],
245
+ :UFID => Frames[81],
246
+ :USER => Frames[82],
247
+ :USLT => Frames[83],
248
+ :WCOM => Frames[84],
249
+ :WCOP => Frames[85],
250
+ :WOAF => Frames[86],
251
+ :WOAR => Frames[87],
252
+ :WOAS => Frames[88],
253
+ :WORS => Frames[89],
254
+ :WPAY => Frames[90],
255
+ :WPUB => Frames[91],
256
+ :WXXX => Frames[92],
257
+ }
156
258
 
157
259
  Fields = [
158
260
  [0, :nofield, "No field"],
@@ -180,7 +282,34 @@ module ID3Lib
180
282
  [22, :timestampformat, "SYLT Timestamp Format"],
181
283
  [23, :contenttype, "SYLT content type"]
182
284
  ]
183
-
285
+
286
+ FieldsByID = {
287
+ :nofield => Fields[0],
288
+ :textenc => Fields[1],
289
+ :text => Fields[2],
290
+ :url => Fields[3],
291
+ :data => Fields[4],
292
+ :description => Fields[5],
293
+ :owner => Fields[6],
294
+ :email => Fields[7],
295
+ :rating => Fields[8],
296
+ :filename => Fields[9],
297
+ :language => Fields[10],
298
+ :picturetype => Fields[11],
299
+ :imageformat => Fields[12],
300
+ :mimetype => Fields[13],
301
+ :counter => Fields[14],
302
+ :id => Fields[15],
303
+ :volumeadj => Fields[16],
304
+ :numbits => Fields[17],
305
+ :volchgright => Fields[18],
306
+ :volchgleft => Fields[19],
307
+ :peakvolright => Fields[20],
308
+ :peakvolleft => Fields[21],
309
+ :timestampformat => Fields[22],
310
+ :contenttype => Fields[23],
311
+ }
312
+
184
313
  FieldType = {
185
314
  0 => :integer,
186
315
  1 => :binary,
@@ -225,8 +354,9 @@ module ID3Lib
225
354
  "Britpop", "Negerpunk", "Polsk Punk", "Beat",
226
355
  "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover",
227
356
  "Contemporary Christian", "Christian Rock ", "Merengue", "Salsa",
228
- "Trash Metal", "Anime", "JPop", "Synthpop"
357
+ "Trash Metal", "Anime", "JPop", "Synthpop",
229
358
  ]
359
+
230
360
 
231
361
  #
232
362
  # Get information of frame specified by _id_.
@@ -234,8 +364,11 @@ module ID3Lib
234
364
  # ID3Lib::Info.frame(:TIT2) #=> [47, :TIT2, "Title/songname/content description", [:textenc, :text]]
235
365
  #
236
366
  def self.frame(id)
237
- index = id.is_a?(Integer) ? NUM : ID
238
- Frames.find{ |f| f[index] == id }
367
+ FramesByID[id]
368
+ end
369
+
370
+ def self.frame_num(num)
371
+ Frames[num]
239
372
  end
240
373
 
241
374
  #
@@ -244,8 +377,11 @@ module ID3Lib
244
377
  # ID3Lib::Info.field(:text) #=> [2, :text, "Text field"]
245
378
  #
246
379
  def self.field(id)
247
- index = id.is_a?(Integer) ? NUM : ID
248
- Fields.find{ |f| f[index] == id }
380
+ FieldsByID[id]
381
+ end
382
+
383
+ def self.field_num(num)
384
+ Fields[num]
249
385
  end
250
386
 
251
387
  end
metadata CHANGED
@@ -3,11 +3,11 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: id3lib-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2006-05-19 00:00:00 +02:00
6
+ version: 0.3.0
7
+ date: 2006-05-28 00:00:00 +02:00
8
8
  summary: id3lib-ruby provides a Ruby interface to the id3lib C++ library for easily editing ID3 tags (v1 and v2) like with pyid3lib.
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: robinstocker@rubyforge.org
12
12
  homepage: http://id3lib-ruby.rubyforge.org
13
13
  rubyforge_project: id3lib-ruby
@@ -18,46 +18,47 @@ bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
27
26
  signing_key:
28
27
  cert_chain:
29
28
  authors:
30
- - Robin Stocker
29
+ - Robin Stocker
31
30
  files:
32
- - lib/id3lib.rb
33
- - lib/id3lib/accessors.rb
34
- - lib/id3lib/info.rb
35
- - ext/extconf.rb
36
- - ext/id3lib_api_wrap.cxx
37
- - test/test_reading.rb
38
- - test/test_writing.rb
39
- - test/data/sample.mp3
40
- - test/data/unicode.mp3
41
- - test/data/cover.jpg
42
- - Rakefile
43
- - setup.rb
44
- - README
45
- - CHANGES
46
- - TODO
31
+ - lib/id3lib.rb
32
+ - lib/id3lib/accessors.rb
33
+ - lib/id3lib/info.rb
34
+ - test/test_writing.rb
35
+ - test/test_reading.rb
36
+ - test/data/sample.mp3
37
+ - test/data/unicode.mp3
38
+ - test/data/cover.jpg
39
+ - Rakefile
40
+ - setup.rb
41
+ - ext/extconf.rb
42
+ - ext/id3lib_api_wrap.cxx
43
+ - README
44
+ - CHANGES
45
+ - TODO
47
46
  test_files:
48
- - test/test_reading.rb
49
- - test/test_writing.rb
47
+ - test/test_writing.rb
48
+ - test/test_reading.rb
50
49
  rdoc_options:
51
- - "--line-numbers"
52
- - "--main"
53
- - README
50
+ - --line-numbers
51
+ - --main
52
+ - README
54
53
  extra_rdoc_files:
55
- - README
56
- - CHANGES
57
- - TODO
54
+ - README
55
+ - CHANGES
56
+ - TODO
58
57
  executables: []
58
+
59
59
  extensions:
60
- - ext/extconf.rb
60
+ - ext/extconf.rb
61
61
  requirements:
62
- - id3lib C++ library
63
- dependencies: []
62
+ - id3lib C++ library
63
+ dependencies: []
64
+