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
@@ -106,5 +106,10 @@ class TestID3v2Frames < Test::Unit::TestCase
106
106
  assert_equal ["MusicBrainz Album Id", "992dc19a-5631-40f5-b252-fbfedbc328a9"], @txxx_frame.field_list
107
107
  end
108
108
  end
109
+
110
+ teardown do
111
+ @file.close
112
+ @file = nil
113
+ end
109
114
  end
110
115
  end
@@ -50,5 +50,28 @@ class TestID3v2Memory < Test::Unit::TestCase
50
50
  raise "GC did not delete file, unsure if test was successful."
51
51
  end
52
52
  end
53
+
54
+ should "not segfault when audio properties are deleted along with file" do
55
+ file = TagLib::MPEG::File.new("test/data/crash.mp3", true)
56
+ properties = file.audio_properties
57
+ file.close
58
+ begin
59
+ N.times do
60
+ GC.start
61
+ properties.bitrate
62
+ end
63
+ rescue => e
64
+ assert_equal "ObjectPreviouslyDeleted", e.class.to_s
65
+ else
66
+ raise "GC did not delete file, unsure if test was successful."
67
+ end
68
+ end
69
+
70
+ teardown do
71
+ if @file
72
+ @file.close
73
+ @file = nil
74
+ end
75
+ end
53
76
  end
54
77
  end
@@ -53,5 +53,10 @@ class TestID3v2RelativeVolumeFrame < Test::Unit::TestCase
53
53
  assert_equal 6, pv2.bits_representing_peak
54
54
  assert_equal 0b110111.chr, pv2.peak_volume
55
55
  end
56
+
57
+ teardown do
58
+ @file.close
59
+ @file = nil
60
+ end
56
61
  end
57
62
  end
@@ -27,6 +27,11 @@ class TestID3v2Tag < Test::Unit::TestCase
27
27
  assert_equal false, @tag.empty?
28
28
  end
29
29
  end
30
+
31
+ teardown do
32
+ @file.close
33
+ @file = nil
34
+ end
30
35
  end
31
36
 
32
37
  context "A new ID3v2::Tag" do
@@ -38,5 +38,10 @@ class TestID3v2Unicode < Test::Unit::TestCase
38
38
  end
39
39
  end
40
40
  end
41
+
42
+ teardown do
43
+ @file.close
44
+ @file = nil
45
+ end
41
46
  end
42
47
  end
@@ -50,6 +50,7 @@ class TestID3v2Write < Test::Unit::TestCase
50
50
 
51
51
  success = @file.save
52
52
  assert success
53
+ @file.close
53
54
  @file = nil
54
55
 
55
56
  written_file = TagLib::MPEG::File.new(OUTPUT_FILE, false)
@@ -57,6 +58,7 @@ class TestID3v2Write < Test::Unit::TestCase
57
58
  assert_equal "image/jpeg", written_apic.mime_type
58
59
  assert_equal "desc", written_apic.description
59
60
  assert_equal picture_data, written_apic.picture
61
+ written_file.close
60
62
  end
61
63
 
62
64
  should "be able to set field_list" do
@@ -88,7 +90,10 @@ class TestID3v2Write < Test::Unit::TestCase
88
90
  end
89
91
 
90
92
  teardown do
91
- @file = nil
93
+ if @file
94
+ @file.close
95
+ @file = nil
96
+ end
92
97
  FileUtils.rm OUTPUT_FILE
93
98
  end
94
99
  end
@@ -7,6 +7,18 @@ class TestMPEGFile < Test::Unit::TestCase
7
7
  @file = TagLib::MPEG::File.new("test/data/crash.mp3", read_properties)
8
8
  end
9
9
 
10
+ should "have a basic tag" do
11
+ tag = @file.tag
12
+ assert_not_nil tag
13
+ assert_equal TagLib::Tag, tag.class
14
+ end
15
+
16
+ should "have an ID3v2 tag" do
17
+ tag = @file.id3v2_tag(false)
18
+ assert_not_nil tag
19
+ assert_equal TagLib::ID3v2::Tag, tag.class
20
+ end
21
+
10
22
  context "audio properties" do
11
23
  setup do
12
24
  @properties = @file.audio_properties
@@ -39,11 +51,16 @@ class TestMPEGFile < Test::Unit::TestCase
39
51
  end
40
52
 
41
53
  should "contain information" do
42
- assert_true @xing_header.valid?
54
+ assert @xing_header.valid?
43
55
  assert_equal 88, @xing_header.total_frames
44
56
  assert_equal 45140, @xing_header.total_size
45
57
  end
46
58
  end
47
59
  end
60
+
61
+ teardown do
62
+ @file.close
63
+ @file = nil
64
+ end
48
65
  end
49
66
  end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ class TestVorbisFile < Test::Unit::TestCase
4
+ context "The vorbis.oga file" do
5
+ setup do
6
+ @file = TagLib::Ogg::Vorbis::File.new("test/data/vorbis.oga")
7
+ end
8
+
9
+ should "have a tag" do
10
+ tag = @file.tag
11
+ assert_not_nil tag
12
+ assert_equal TagLib::Ogg::XiphComment, tag.class
13
+ end
14
+
15
+ context "audio properties" do
16
+ setup do
17
+ @properties = @file.audio_properties
18
+ end
19
+
20
+ should "exist" do
21
+ assert_not_nil @properties
22
+ end
23
+
24
+ should "contain basic information" do
25
+ assert_equal 0, @properties.length # file is short
26
+ assert_equal 64, @properties.bitrate
27
+ assert_equal 44100, @properties.sample_rate
28
+ assert_equal 2, @properties.channels
29
+ end
30
+
31
+ should "contain vorbis-specific information" do
32
+ assert_equal 0, @properties.vorbis_version
33
+ assert_equal 0, @properties.bitrate_maximum
34
+ assert_equal 64000, @properties.bitrate_nominal
35
+ assert_equal 0, @properties.bitrate_minimum
36
+ end
37
+ end
38
+
39
+ teardown do
40
+ @file.close
41
+ @file = nil
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,79 @@
1
+ require 'helper'
2
+
3
+ class TestVorbisTag < Test::Unit::TestCase
4
+ context "The vorbis.oga file tag" do
5
+ setup do
6
+ @file = TagLib::Ogg::Vorbis::File.new("test/data/vorbis.oga")
7
+ @tag = @file.tag
8
+ end
9
+
10
+ should "contain basic tag information" do
11
+ assert_equal "Title", @tag.title
12
+ assert_equal "Artist", @tag.artist
13
+ assert_equal "Album", @tag.album
14
+ assert_equal "Test file", @tag.comment
15
+ assert_equal "Pop", @tag.genre
16
+ assert_equal 2011, @tag.year
17
+ assert_equal 7, @tag.track
18
+ assert_equal false, @tag.empty?
19
+ end
20
+
21
+ should "have contains? method" do
22
+ assert @tag.contains?('TITLE')
23
+ assert !@tag.contains?('DOESNTEXIST')
24
+ end
25
+
26
+ should "have field_count" do
27
+ assert_equal 16, @tag.field_count
28
+ end
29
+
30
+ should "have vendor_id" do
31
+ assert_equal "Xiph.Org libVorbis I 20101101 (Schaufenugget)", @tag.vendor_id
32
+ end
33
+
34
+ context "fields" do
35
+ setup do
36
+ @fields = @tag.field_list_map
37
+ end
38
+
39
+ should "exist" do
40
+ assert_not_nil @fields
41
+ end
42
+
43
+ should "be usable as a Hash" do
44
+ assert_equal ["Title"], @fields['TITLE']
45
+ assert_nil @fields['DOESNTEXIST']
46
+ end
47
+
48
+ should "be able to return more than one value for a key" do
49
+ assert_equal ["A", "B"], @fields['MULTIPLE']
50
+ end
51
+ end
52
+
53
+ should "support add_field with replace" do
54
+ @tag.add_field('TITLE', "New Title")
55
+ assert_equal ["New Title"], @tag.field_list_map['TITLE']
56
+ end
57
+
58
+ should "support add_field without replace" do
59
+ replace = false
60
+ @tag.add_field('TITLE', "Additional Title", replace)
61
+ assert_equal ["Title", "Additional Title"], @tag.field_list_map['TITLE']
62
+ end
63
+
64
+ should "support remove_field with value" do
65
+ @tag.remove_field('MULTIPLE', "A")
66
+ assert_equal ["B"], @tag.field_list_map['MULTIPLE']
67
+ end
68
+
69
+ should "support remove_field without value" do
70
+ @tag.remove_field('MULTIPLE')
71
+ assert !@tag.contains?('MULTIPLE')
72
+ end
73
+
74
+ teardown do
75
+ @file.close
76
+ @file = nil
77
+ end
78
+ end
79
+ end
metadata CHANGED
@@ -1,160 +1,115 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: taglib-ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Robin Stocker
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-05 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake-compiler
16
+ requirement: &18528240 !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
18
+ requirements:
24
19
  - - ~>
25
- - !ruby/object:Gem::Version
26
- hash: 5
27
- segments:
28
- - 0
29
- - 7
30
- version: "0.7"
31
- version_requirements: *id001
32
- name: rake-compiler
33
- prerelease: false
20
+ - !ruby/object:Gem::Version
21
+ version: '0.7'
34
22
  type: :development
35
- - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *18528240
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &18527040 !ruby/object:Gem::Requirement
37
28
  none: false
38
- requirements:
29
+ requirements:
39
30
  - - ~>
40
- - !ruby/object:Gem::Version
41
- hash: 21
42
- segments:
43
- - 2
44
- - 11
45
- version: "2.11"
46
- version_requirements: *id002
47
- name: shoulda
48
- prerelease: false
31
+ - !ruby/object:Gem::Version
32
+ version: '2.11'
49
33
  type: :development
50
- - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ version_requirements: *18527040
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &18525980 !ruby/object:Gem::Requirement
52
39
  none: false
53
- requirements:
40
+ requirements:
54
41
  - - ~>
55
- - !ruby/object:Gem::Version
56
- hash: 23
57
- segments:
58
- - 1
59
- - 0
60
- - 0
42
+ - !ruby/object:Gem::Version
61
43
  version: 1.0.0
62
- version_requirements: *id003
63
- name: bundler
64
- prerelease: false
65
44
  type: :development
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
45
+ prerelease: false
46
+ version_requirements: *18525980
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &18525180 !ruby/object:Gem::Requirement
68
50
  none: false
69
- requirements:
51
+ requirements:
70
52
  - - ~>
71
- - !ruby/object:Gem::Version
72
- hash: 7
73
- segments:
74
- - 1
75
- - 6
76
- - 4
53
+ - !ruby/object:Gem::Version
77
54
  version: 1.6.4
78
- version_requirements: *id004
79
- name: jeweler
80
- prerelease: false
81
55
  type: :development
82
- - !ruby/object:Gem::Dependency
83
- requirement: &id005 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
92
- version_requirements: *id005
93
- name: rcov
94
56
  prerelease: false
95
- type: :development
96
- - !ruby/object:Gem::Dependency
97
- requirement: &id006 !ruby/object:Gem::Requirement
57
+ version_requirements: *18525180
58
+ - !ruby/object:Gem::Dependency
59
+ name: yard
60
+ requirement: &18524140 !ruby/object:Gem::Requirement
98
61
  none: false
99
- requirements:
62
+ requirements:
100
63
  - - ~>
101
- - !ruby/object:Gem::Version
102
- hash: 5
103
- segments:
104
- - 0
105
- - 7
106
- version: "0.7"
107
- version_requirements: *id006
108
- name: yard
109
- prerelease: false
64
+ - !ruby/object:Gem::Version
65
+ version: '0.7'
110
66
  type: :development
111
- - !ruby/object:Gem::Dependency
112
- requirement: &id007 !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
119
- - 0
120
- version: "0"
121
- version_requirements: *id007
122
- name: redcarpet
123
67
  prerelease: false
68
+ version_requirements: *18524140
69
+ - !ruby/object:Gem::Dependency
70
+ name: redcarpet
71
+ requirement: &18523500 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.0'
124
77
  type: :development
125
- - !ruby/object:Gem::Dependency
126
- requirement: &id008 !ruby/object:Gem::Requirement
78
+ prerelease: false
79
+ version_requirements: *18523500
80
+ - !ruby/object:Gem::Dependency
81
+ name: guard-test
82
+ requirement: &18522720 !ruby/object:Gem::Requirement
127
83
  none: false
128
- requirements:
84
+ requirements:
129
85
  - - ~>
130
- - !ruby/object:Gem::Version
131
- hash: 15
132
- segments:
133
- - 0
134
- - 4
135
- - 0
86
+ - !ruby/object:Gem::Version
136
87
  version: 0.4.0
137
- version_requirements: *id008
138
- name: guard-test
139
- prerelease: false
140
88
  type: :development
141
- description: |
142
- Ruby interface for the taglib C++ library.
143
-
89
+ prerelease: false
90
+ version_requirements: *18522720
91
+ description: ! 'Ruby interface for the taglib C++ library.
92
+
93
+
144
94
  In contrast to other libraries, this one wraps the C++ API using SWIG,
95
+
145
96
  not only the minimal C API. This means that all tags can be accessed.
146
97
 
98
+ '
147
99
  email: robin@nibor.org
148
100
  executables: []
149
-
150
- extensions:
101
+ extensions:
151
102
  - ext/taglib_base/extconf.rb
152
103
  - ext/taglib_mpeg/extconf.rb
104
+ - ext/taglib_id3v1/extconf.rb
153
105
  - ext/taglib_id3v2/extconf.rb
154
- extra_rdoc_files:
106
+ - ext/taglib_ogg/extconf.rb
107
+ - ext/taglib_vorbis/extconf.rb
108
+ extra_rdoc_files:
109
+ - CHANGES.md
155
110
  - LICENSE.txt
156
111
  - README.md
157
- files:
112
+ files:
158
113
  - .yardopts
159
114
  - CHANGES.md
160
115
  - Gemfile
@@ -165,14 +120,19 @@ files:
165
120
  - Rakefile
166
121
  - docs/default/fulldoc/html/css/common.css
167
122
  - docs/taglib/base.rb
123
+ - docs/taglib/id3v1.rb
168
124
  - docs/taglib/id3v2.rb
169
125
  - docs/taglib/mpeg.rb
170
- - ext/Rakefile
126
+ - docs/taglib/ogg.rb
127
+ - docs/taglib/vorbis.rb
171
128
  - ext/extconf_common.rb
172
129
  - ext/taglib_base/extconf.rb
173
130
  - ext/taglib_base/includes.i
174
131
  - ext/taglib_base/taglib_base.i
175
132
  - ext/taglib_base/taglib_base_wrap.cxx
133
+ - ext/taglib_id3v1/extconf.rb
134
+ - ext/taglib_id3v1/taglib_id3v1.i
135
+ - ext/taglib_id3v1/taglib_id3v1_wrap.cxx
176
136
  - ext/taglib_id3v2/extconf.rb
177
137
  - ext/taglib_id3v2/relativevolumeframe.i
178
138
  - ext/taglib_id3v2/taglib_id3v2.i
@@ -180,22 +140,41 @@ files:
180
140
  - ext/taglib_mpeg/extconf.rb
181
141
  - ext/taglib_mpeg/taglib_mpeg.i
182
142
  - ext/taglib_mpeg/taglib_mpeg_wrap.cxx
143
+ - ext/taglib_ogg/extconf.rb
144
+ - ext/taglib_ogg/taglib_ogg.i
145
+ - ext/taglib_ogg/taglib_ogg_wrap.cxx
146
+ - ext/taglib_vorbis/extconf.rb
147
+ - ext/taglib_vorbis/taglib_vorbis.i
148
+ - ext/taglib_vorbis/taglib_vorbis_wrap.cxx
183
149
  - ext/valgrind-suppressions.txt
150
+ - ext/win.cmake
184
151
  - lib/taglib.rb
185
152
  - lib/taglib/base.rb
153
+ - lib/taglib/id3v1.rb
186
154
  - lib/taglib/id3v2.rb
187
155
  - lib/taglib/mpeg.rb
156
+ - lib/taglib/ogg.rb
188
157
  - lib/taglib/version.rb
158
+ - lib/taglib/vorbis.rb
189
159
  - taglib-ruby.gemspec
190
160
  - tasks/docs_coverage.rake
161
+ - tasks/ext.rake
162
+ - tasks/swig.rake
163
+ - test/data/Makefile
191
164
  - test/data/add-relative-volume.cpp
192
165
  - test/data/crash.mp3
193
166
  - test/data/globe_east_540.jpg
167
+ - test/data/id3v1-create.cpp
168
+ - test/data/id3v1.mp3
194
169
  - test/data/relative-volume.mp3
195
170
  - test/data/sample.mp3
196
171
  - test/data/unicode.mp3
172
+ - test/data/vorbis-create.cpp
173
+ - test/data/vorbis.oga
197
174
  - test/helper.rb
198
175
  - test/test_fileref_properties.rb
176
+ - test/test_fileref_write.rb
177
+ - test/test_id3v1_tag.rb
199
178
  - test/test_id3v2_frames.rb
200
179
  - test/test_id3v2_memory.rb
201
180
  - test/test_id3v2_relative_volume.rb
@@ -204,33 +183,31 @@ files:
204
183
  - test/test_id3v2_write.rb
205
184
  - test/test_mpeg_file.rb
206
185
  - test/test_tag.rb
186
+ - test/test_vorbis_file.rb
187
+ - test/test_vorbis_tag.rb
207
188
  homepage: http://github.com/robinst/taglib-ruby
208
- licenses:
189
+ licenses:
209
190
  - MIT
210
191
  post_install_message:
211
192
  rdoc_options: []
212
-
213
- require_paths:
193
+ require_paths:
214
194
  - lib
215
- required_ruby_version: !ruby/object:Gem::Requirement
195
+ required_ruby_version: !ruby/object:Gem::Requirement
216
196
  none: false
217
- requirements:
218
- - - ">="
219
- - !ruby/object:Gem::Version
220
- hash: 3
221
- segments:
197
+ requirements:
198
+ - - ! '>='
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ segments:
222
202
  - 0
223
- version: "0"
224
- required_rubygems_version: !ruby/object:Gem::Requirement
203
+ hash: -1593774999472274460
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
225
205
  none: false
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- hash: 3
230
- segments:
231
- - 0
232
- version: "0"
233
- requirements:
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements:
234
211
  - taglib (libtag1-dev in Debian/Ubuntu, taglib-devel in Fedora/RHEL)
235
212
  rubyforge_project:
236
213
  rubygems_version: 1.8.10
@@ -238,4 +215,3 @@ signing_key:
238
215
  specification_version: 3
239
216
  summary: Ruby interface for the taglib C++ library
240
217
  test_files: []
241
-