ruby-ogginfo 0.6.13 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ require "yaml"
2
+ require "tempfile"
3
+
4
+ def load_fixtures
5
+ fixtures = YAML::load_file(File.join(File.dirname(__FILE__), "fixtures.yml"))
6
+ fixtures.each_with_object({}) do |(codec, content), hash|
7
+ f = File.join(Dir.tmpdir, "/test.ruby-ogginfo.#{codec}")
8
+ File.binwrite(f, content)
9
+ hash[codec] = f
10
+ end
11
+ end
@@ -7,136 +7,38 @@ require "test/unit"
7
7
  require "ogginfo"
8
8
  require "fileutils"
9
9
  require "tempfile"
10
-
11
- VALID_OGG = <<EOF
12
- T2dnUwACAAAAAAAAAADjoIphAAAAAIDpYLkBHgF2b3JiaXMAAAAAAkSsAAAA
13
- AAAAAPoAAAAAAAC4AU9nZ1MAAAAAAAAAAAAA46CKYQEAAACKbpIfEC3/////
14
- /////////////8EDdm9yYmlzHQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIw
15
- MDcwNjIyAAAAAAEFdm9yYmlzIUJDVgEAAAEAGGNUKUaZUtJKiRlzlDFGmWKS
16
- SomlhBZCSJ1zFFOpOdeca6y5tSCEEBpTUCkFmVKOUmkZY5ApBZlSEEtJJXQS
17
- OiedYxBbScHWmGuLQbYchA2aUkwpxJRSikIIGVOMKcWUUkpCByV0DjrmHFOO
18
- SihBuJxzq7WWlmOLqXSSSuckZExCSCmFkkoHpVNOQkg1ltZSKR1zUlJqQegg
19
- hBBCtiCEDYLQkFUAAAEAwEAQGrIKAFAAABCKoRiKAoSGrAIAMgAABKAojuIo
20
- jiM5kmNJFhAasgoAAAIAEAAAwHAUSZEUybEkS9IsS9NEUVV91TZVVfZ1Xdd1
21
- Xdd1IDRkFQAAAQBASKeZpRogwgxkGAgNWQUAIAAAAEYowhADQkNWAQAAAQAA
22
- Yig5iCa05nxzjoNmOWgqxeZ0cCLV5kluKubmnHPOOSebc8Y455xzinJmMWgm
23
- tOaccxKDZiloJrTmnH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wAAqMABACDARpHNCUaCCg1ZCQCkAgAYHMeyNE3TPE8UNUnS
74
- NM/zPFE0TU2yNM3zPE8UTZPneZ4oiqJpqirP8zxRFEXTVFWuK4qmaZqqqqpk
75
- WRRF0TRVVXVhmqapqqrqujBNUVRV1XVdyLJpqqrryjJs2zRV1XVlGaiqqsqu
76
- LAPXVVXXlWUBAOAJDgBABTasjnBSNBZYaMhKACADAIAgBCGlFEJKKYSUUggp
77
- pRASAAAw4AAAEGBCGSg0ZEUAECcAACAkpYJOSiWhlFJKKaWUUkoppZRSSiml
78
- lFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSiml
79
- lFJKKaWUUkoppZNSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSiml
80
- lFJKKaWUUkoppZSSUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkkp
81
- pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
82
- pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
83
- pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
84
- pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
85
- pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
86
- pZRSSimllAoA0I1wANB9MKEMFBqyEgBIBQAAjFGKMQipxVYhxJhzElprrUKI
87
- MecktJRiz5hzEEppLbaeMccglJJai72UzklJrbUYeyodo5JSSzH23kspJaXY
88
- Yuy9p5BCji3G2HvPMaUWW6ux915jSrHVGGPvvfcYY6ux1t577zG2VmuOBQBg
89
- NjgAQCTYsDrCSdFYYKEhKwGAkAAAwhilGGPMOeecc05KyRhzzkEIIYQQSikZ
90
- Y8w5CCGEEEIpJWPOOQchhFBCKKVkzDnoIIRQQiillM45Bx2EEEIJpZSSMecg
91
- hBBCCaWUUjrnIIQQQiilhFRKKZ2DEEIoIYRSSkkphBBCCKGEUFIpKYUQQggh
92
- hFBCSiWlEEIIIYQQSkilpJRSCCGEEEIIpZSUUgollBBCKKGkkkoppYQQSgih
93
- pFRSKqmUEkIIJYSSSkoplVRKKCGEUgAAwIEDAECAEXSSUWURNppw4QEoNGQl
94
- ABAFAAAZBx2UlhuAkHLUWocchBRbC5FDDFqMnXKMQUopZJAxxqSVkkLHGKTU
95
- YkuhgxR7z7mV1AIAACAIAAgwAQQGCAq+EAJiDABAECIzREJhFSwwKIMGh3kA
96
- 8AARIREAJCYo0i4uoMsAF3Rx14EQghCEIBYHUEACDk644Yk3POEGJ+gUlToQ
97
- AAAAAIAFAHgAAEAogIiIZq7C4gIjQ2ODo8PjA0QAAAAAALAA4AMAAAkBIiKa
98
- uQqLC4wMjQ2ODo8PkAAAQAABAAAAABBAAAICAgAAAAAAAQAAAAICT2dnUwAE
99
- AAAAAAAAAADjoIphAgAAAIr86XUBAQA=
100
- ====
101
- EOF
10
+ require File.join(File.dirname(__FILE__), "test_helper")
102
11
 
103
12
  class OggInfoTest < Test::Unit::TestCase
104
-
105
- TEMP_FILE = File.join(Dir.tmpdir, "test_ogginfo.ogg")
106
-
107
13
  def setup
108
- valid_ogg_file = VALID_OGG.unpack("m*").first
109
- File.open(TEMP_FILE, "w") { |f| f.write(valid_ogg_file) }
14
+ @tempfile = load_fixtures[:ogg]
110
15
  end
111
16
 
112
17
  def teardown
113
- FileUtils.rm_f(TEMP_FILE)
18
+ FileUtils.rm_f(@tempfile)
114
19
  end
115
20
 
116
21
  def test_infos
117
- OggInfo.open(TEMP_FILE) do |ogg|
22
+ OggInfo.open(@tempfile) do |ogg|
118
23
  assert_equal 64000, ogg.nominal_bitrate
119
24
  assert_equal 2, ogg.channels
120
25
  assert_equal 44100, ogg.samplerate
121
- assert_in_delta(0.5, ogg.length, 1)
122
- #average_bitrate
26
+ assert_in_delta(3, ogg.length, 0.5)
123
27
  end
124
28
  end
125
29
 
126
30
  def test_length
127
- tf = generate_ogg
128
- OggInfo.open(tf.path) do |ogg|
129
- assert_in_delta(17.0, ogg.length, 1, "length has not been correctly guessed")
130
- assert_in_delta(67000.0, ogg.bitrate, 2000, "bitrate has not been correctly guessed")
31
+ OggInfo.open(@tempfile) do |ogg|
32
+ assert_in_delta(3, ogg.length, 0.3, "length has not been correctly guessed")
33
+ assert_in_delta(64000.0, ogg.bitrate, 10000, "bitrate has not been correctly guessed")
131
34
  end
132
35
  end
133
36
 
134
37
  def test_writing_to_spedial_filenames
135
- tf = generate_ogg
136
38
  filename = "fichier éé.ogg"
137
- FileUtils.cp(tf.path, filename)
39
+ FileUtils.cp(@tempfile, filename)
138
40
  begin
139
- OggInfo.open(tf.path) do |ogg|
41
+ OggInfo.open(@tempfile) do |ogg|
140
42
  ogg.tag.title = "a"*200
141
43
  end
142
44
  #system("ls", "-l", filename)
@@ -162,9 +64,8 @@ class OggInfoTest < Test::Unit::TestCase
162
64
  end
163
65
 
164
66
  def test_should_not_fail_when_input_is_truncated
165
- valid_ogg = generate_ogg
166
67
  ogg_length = nil
167
- OggInfo.open(valid_ogg.path) do |ogg|
68
+ OggInfo.open(@tempfile) do |ogg|
168
69
  ogg_length = ogg.length
169
70
  end
170
71
 
@@ -191,43 +92,61 @@ class OggInfoTest < Test::Unit::TestCase
191
92
  end
192
93
  end
193
94
 
194
- protected
195
-
196
- def generate_ogg
197
- generated_ogg_file_path = File.join(File.dirname(__FILE__), "test.ogg")
198
- unless test(?f, generated_ogg_file_path)
199
- system("dd if=/dev/urandom bs=1024 count=3000 | oggenc -q0 --raw -o #{generated_ogg_file_path} -") or
200
- flunk("cannot generate \"#{generated_ogg_file_path}\", tests cannot be fully performed")
201
- end
202
- tf = Tempfile.new("ruby-ogginfo")
95
+ def test_picture
96
+ tf = Tempfile.new(["ruby-ogginfo", ".jpg"])
97
+ jpg_content = (0...1000).collect { rand(256).chr }.join("")
98
+ tf.write(jpg_content)
203
99
  tf.close
204
- FileUtils.cp(generated_ogg_file_path, tf.path)
205
- tf
100
+ OggInfo.open(@tempfile) do |ogg|
101
+ ogg.picture = tf.path
102
+ end
103
+ OggInfo.open(@tempfile) do |ogg|
104
+ assert ogg.tag.has_key?("metadata_block_picture")
105
+
106
+ type, # picture type
107
+ _, # mime_type size
108
+ mime_type,
109
+ _, # description size
110
+ description,
111
+ _, # width
112
+ _, # height
113
+ _, # color depth
114
+ _, # number of color used
115
+ file_content_size,
116
+ file_content = ogg.tag["metadata_block_picture"].unpack("m*").first.unpack("NNa10Na10NNNNNa*")
117
+ assert_equal 3, type
118
+ assert_equal "image/jpeg", mime_type
119
+ assert_equal "folder.jpg", description
120
+ assert_equal jpg_content.size, file_content_size
121
+ assert_equal jpg_content, file_content
122
+
123
+ assert_equal [".jpg", jpg_content], ogg.picture
124
+ end
206
125
  end
207
126
 
127
+ protected
128
+
208
129
  def generate_truncated_ogg
209
- valid_ogg = generate_ogg
210
130
  tf = Tempfile.new("ruby-ogginfo")
211
- data = File.read(valid_ogg.path, File.size(valid_ogg.path) - 10000)
131
+ s = File.size(@tempfile)
132
+ data = File.read(@tempfile, (s - s*0.75).to_i)
212
133
  tf.write(data)
213
134
  tf.close
214
135
  tf
215
136
  end
216
137
 
217
138
  def tag_test(test_name, tag)
218
- tf = generate_ogg
219
-
220
- OggInfo.open(tf.path) do |ogg|
139
+ OggInfo.open(@tempfile) do |ogg|
221
140
  tag.each { |k,v| ogg.tag[k] = v }
222
141
  end
223
142
 
224
- OggInfo.open(tf.path) do |ogg|
143
+ OggInfo.open(@tempfile) do |ogg|
225
144
  assert_equal tag, ogg.tag
226
145
  end
227
- system("cp #{tf.path} /tmp/test_#{RUBY_VERSION}_#{test_name}.ogg")
146
+ system("cp #{@tempfile} /tmp/test_#{RUBY_VERSION}_#{test_name}.ogg")
228
147
  test_length
229
148
  assert_nothing_raised do
230
- io = open(tf.path)
149
+ io = open(@tempfile)
231
150
  reader = Ogg::Reader.new(io)
232
151
  reader.each_pages do |page|
233
152
  page
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift("lib/")
4
+
5
+ require "test/unit"
6
+ require "ogginfo"
7
+ require "fileutils"
8
+ require "tempfile"
9
+ require File.join(File.dirname(__FILE__), "test_helper")
10
+
11
+ class OtherCodecsInfoTest < Test::Unit::TestCase
12
+ CODECS = [:speex, :opus]
13
+
14
+ def setup
15
+ @fixtures = load_fixtures
16
+ end
17
+
18
+ def test_generated_info
19
+ CODECS.each do |codec|
20
+ OggInfo.open(@fixtures[codec]) do |ogg|
21
+ assert_equal 2, ogg.channels
22
+ assert_equal 48000, ogg.samplerate
23
+ case codec
24
+ when :speex
25
+ assert_equal "spxinfotest", ogg.tag.author
26
+ when :opus
27
+ assert_in_delta(3, ogg.length, 0.2, "length has not been correctly guessed for codec \"#{codec}\"")
28
+ assert_in_delta 64000, ogg.bitrate, 2000
29
+ assert_equal "artist", ogg.tag.artist
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_tag_writing
36
+ CODECS.each do |codec|
37
+ tag = {"title" => "mytitle", "test" => "myartist" }
38
+ OggInfo.open(@fixtures[codec]) do |ogg|
39
+ ogg.tag.clear
40
+ tag.each { |k,v| ogg.tag[k] = v }
41
+ end
42
+
43
+ OggInfo.open(@fixtures[codec]) do |ogg|
44
+ assert_equal tag, ogg.tag
45
+ end
46
+ end
47
+ end
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ogginfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Pierronnet
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-25 00:00:00.000000000 Z
12
+ date: 2013-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -56,6 +56,7 @@ dependencies:
56
56
  description: |-
57
57
  ruby-ogginfo gives you access to low level information on ogg files
58
58
  (bitrate, length, samplerate, encoder, etc... ), as well as tag.
59
+ Supported codecs are: vorbis, speex and opus.
59
60
  It is written in pure ruby.
60
61
  email:
61
62
  - guillaume.pierronnet@gmail.com
@@ -74,14 +75,17 @@ files:
74
75
  - lib/ogg/codecs/comments.rb
75
76
  - lib/ogg/codecs/speex.rb
76
77
  - lib/ogg/codecs/vorbis.rb
78
+ - lib/ogg/codecs/opus.rb
77
79
  - lib/ogg/page.rb
78
80
  - lib/ogg/reader.rb
79
81
  - lib/ogg/writer.rb
80
82
  - lib/ogg.rb
81
83
  - lib/ogginfo.rb
82
84
  - setup.rb
85
+ - test/fixtures.yml
86
+ - test/test_helper.rb
83
87
  - test/test_ruby-ogginfo.rb
84
- - test/test_ruby-spxinfo.rb
88
+ - test/test_ruby-othercodecs.rb
85
89
  - .gemtest
86
90
  homepage: http://ruby-ogginfo.rubyforge.org/
87
91
  licenses: []
@@ -110,5 +114,6 @@ specification_version: 4
110
114
  summary: ruby-ogginfo gives you access to low level information on ogg files (bitrate,
111
115
  length, samplerate, encoder, etc..
112
116
  test_files:
117
+ - test/test_ruby-othercodecs.rb
113
118
  - test/test_ruby-ogginfo.rb
114
- - test/test_ruby-spxinfo.rb
119
+ - test/test_helper.rb
@@ -1,110 +0,0 @@
1
- #!/usr/bin/ruby -w
2
-
3
- $:.unshift("lib/")
4
-
5
- require "test/unit"
6
- require "ogginfo"
7
- require "fileutils"
8
- require "tempfile"
9
-
10
- VALID_SPX = <<EOF
11
- T2dnUwACAAAAAAAAAACqcIpSAAAAACW1TjsBUFNwZWV4ICAgMS4ycmMxAAAAAAAAAAAAAAAAAAAB
12
- AAAAUAAAAAB9AAACAAAABAAAAAEAAAD/////gAIAAAAAAAABAAAAAAAAAAAAAAAAAAAAT2dnUwAA
13
- AAAAAAAAAACqcIpSAQAAAAaUXjQBSxkAAABFb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O
54
- WkL94EdrPdfVa/z/+dBw1ckmuSfIiSzOJ3NxJmvqrelDG7swgEl06/gJSrjtaUTt1NC9qxvaurq6
55
- uTv3X00=
56
- EOF
57
-
58
- class SpxInfoTest < Test::Unit::TestCase
59
-
60
- TEMP_FILE = File.join(Dir.tmpdir, "test.spxinfo.spx")
61
- GEN_FILE = File.join(Dir.tmpdir,"test.spxgen.spx")
62
-
63
- def setup
64
- valid_spx_file = VALID_SPX.unpack("m*").first
65
- File.open(TEMP_FILE, "w") { |f| f.write(valid_spx_file) }
66
- end
67
-
68
- def teardown
69
- FileUtils.rm_f(TEMP_FILE)
70
- end
71
-
72
- def test_infos
73
- OggInfo.open(TEMP_FILE) do |spx|
74
- assert_equal 1, spx.channels
75
- assert_equal 32000, spx.samplerate
76
- assert_in_delta(0.5, spx.length, 1)
77
- assert_equal "cityrail",spx.tag["author"]
78
- end
79
- end
80
-
81
- def test_generated_info
82
- generate_spx
83
- OggInfo.open("test.spx") do |spx|
84
- assert_equal 2, spx.channels
85
- assert_equal 44100, spx.samplerate
86
- assert_equal "spxinfotest", spx.tag.author
87
- end
88
- end
89
-
90
- def test_tag_writing
91
- generate_spx
92
- FileUtils.cp("test.spx",GEN_FILE)
93
- tag = {"title" => "mytitle", "test" => "myartist" }
94
- OggInfo.open(GEN_FILE) do |spx|
95
- spx.tag.clear
96
- tag.each { |k,v| spx.tag[k] = v }
97
- end
98
-
99
- OggInfo.open(GEN_FILE) do |spx|
100
- assert_equal tag, spx.tag
101
- end
102
- end
103
-
104
- def generate_spx
105
- unless test(?f, "test.spx")
106
- system("dd if=/dev/urandom bs=1024 count=3000 | speexenc --rate 44100 --stereo --author spxinfotest --title SpxInfoTest --comment test=\"hello\303\251\" - test.spx") or
107
- flunk("cannot generate \"test.spx\", tests cannot be fully performed")
108
- end
109
- end
110
- end