sndfile 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/sndfile/error.rb +18 -0
- data/lib/sndfile/file.rb +3 -4
- data/lib/sndfile/version.rb +1 -1
- data/spec/error_spec.rb +12 -0
- data/spec/file_spec.rb +5 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd96cbf94b2f2f9e759f54814c6061deae1ed50
|
4
|
+
data.tar.gz: 20db0e672753f0d6193835988fb9f5422ba6d6c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f73cb61634147e7a84183df61626223379ec1a1803d3736ad4191bef87d1d973f68ce053ca337a44080e3c731e67cf48f868c00165d2a892002c914b37a884
|
7
|
+
data.tar.gz: 7b725f1b747d1f5919f679d14855def31b4339c6116c18eac555ffd86c13e83442f0a6744511872de43de1d144c6c926fb747d2cf9c1c039731672be2f9cdafd
|
data/README.md
CHANGED
@@ -64,6 +64,7 @@ History
|
|
64
64
|
|
65
65
|
Release notes:
|
66
66
|
|
67
|
+
* 1.1.0 - Add detail fields to Sndfile::Error
|
67
68
|
* 1.0.0 - Add Sndfile::Info. Deprecate individual accessors. No longer support ruby 1.8.7
|
68
69
|
* 0.2.0 - Support ruby 1.8.7. Thanks to [youpy](https://github.com/youpy)
|
69
70
|
* 0.1.3 - Back to ruby-gsl-ng: memory leaks fixed
|
data/lib/sndfile/error.rb
CHANGED
@@ -4,5 +4,23 @@ module Sndfile
|
|
4
4
|
# contains the libsndfile error message.
|
5
5
|
#
|
6
6
|
class Error < RuntimeError
|
7
|
+
attr_reader :description
|
8
|
+
attr_reader :code
|
9
|
+
attr_reader :file
|
10
|
+
def initialize(args)
|
11
|
+
args = args.keyword_args(:description, :code, :file)
|
12
|
+
@description = args.description
|
13
|
+
@code = args.code
|
14
|
+
@file = args.file
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
s = ""
|
19
|
+
s << @description if @description
|
20
|
+
s << " (#{@code})" if @code
|
21
|
+
s << " [#{@file}]" if @file
|
22
|
+
s
|
23
|
+
end
|
24
|
+
|
7
25
|
end
|
8
26
|
end
|
data/lib/sndfile/file.rb
CHANGED
@@ -125,10 +125,9 @@ module Sndfile
|
|
125
125
|
def check_error(code = nil)
|
126
126
|
code ||= sf_error(@sfpointer.null? ? nil : @sfpointer)
|
127
127
|
if code != 0
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
raise Sndfile::Error, msg
|
128
|
+
raise Sndfile::Error.new(:description => sf_strerror(@sfpointer.null? ? nil : @sfpointer),
|
129
|
+
:code => ErrorCode[code],
|
130
|
+
:file => @path)
|
132
131
|
end
|
133
132
|
end
|
134
133
|
|
data/lib/sndfile/version.rb
CHANGED
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sndfile::Error do
|
4
|
+
|
5
|
+
it "inludes all info in to_s" do
|
6
|
+
error = Sndfile::Error.new(:description => 'ABCDEF', :code => 'GHIJKL', :file => 'MNOPQR')
|
7
|
+
error.to_s.should =~ /\bABCDEF\b/
|
8
|
+
error.to_s.should =~ /\bGHIJKL\b/
|
9
|
+
error.to_s.should =~ /\bMNOPQR\b/
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
data/spec/file_spec.rb
CHANGED
@@ -33,7 +33,11 @@ describe Sndfile::File do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "raises an error when it can't open the file" do
|
36
|
-
expect { Sndfile::File.open("/no/such/file") }.to raise_error
|
36
|
+
expect { Sndfile::File.open("/no/such/file") }.to raise_error(Sndfile::Error) { |error|
|
37
|
+
error.description.should =~ /No such file/
|
38
|
+
error.code.should == :SF_ERR_SYSTEM
|
39
|
+
error.file.should == "/no/such/file"
|
40
|
+
}
|
37
41
|
end
|
38
42
|
|
39
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sndfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/sndfile/sndfile_api.rb
|
160
160
|
- lib/sndfile/version.rb
|
161
161
|
- sndfile.gemspec
|
162
|
+
- spec/error_spec.rb
|
162
163
|
- spec/file_spec.rb
|
163
164
|
- spec/inputs/ComputerMagic.wav
|
164
165
|
- spec/inputs/Flute3.wav
|
@@ -192,6 +193,7 @@ specification_version: 4
|
|
192
193
|
summary: Ruby wrapper for libsndfile. Reads/writes data as GSL matrices, to allow
|
193
194
|
fast processing.
|
194
195
|
test_files:
|
196
|
+
- spec/error_spec.rb
|
195
197
|
- spec/file_spec.rb
|
196
198
|
- spec/inputs/ComputerMagic.wav
|
197
199
|
- spec/inputs/Flute3.wav
|