sndfile 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c232895c9482256a13565c57f1b26856ac2ccd9c
4
- data.tar.gz: bb4388474d9bfbab60c29f1eb8e42881bd96d44a
3
+ metadata.gz: 7bd96cbf94b2f2f9e759f54814c6061deae1ed50
4
+ data.tar.gz: 20db0e672753f0d6193835988fb9f5422ba6d6c1
5
5
  SHA512:
6
- metadata.gz: ea60311ff4bbe116e07ffb3f4ea6f29e8d72e9429090223594a0ce8773b9222645815433bd25b1c1a897b9bcbef49f70a1e16d736de9516d70b5a729524a79b0
7
- data.tar.gz: 7c173364cdf387773e3896c8a1cc6b526af6751e67f90510561cd0d251c7867b93587b1017dda8c1e6cbdccc579997c78651075217a1e2c7382488c9e0645ef8
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
@@ -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
@@ -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
- msg = sf_strerror(@sfpointer.null? ? nil : @sfpointer)
129
- msg += " (#{ErrorCode[code]})" if ErrorCode[code]
130
- msg += " [#{@path}]"
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
 
@@ -1,3 +1,3 @@
1
1
  module Sndfile
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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
@@ -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 Sndfile::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.0.0
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