oni 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2JlMGI4N2NhZDZmMDdmYTVjNWY0ZjExY2E5YzlmNGVlOWQ0Y2FjNg==
4
+ MTRkYjE1M2NkYjFkZjRjNzliMTRlNzMyNzgxYTY4ZGM4MjMwNWI2MA==
5
5
  data.tar.gz: !binary |-
6
- NjAyMmEwMDA0YzYwZjQ1ZWQzNWNjYjVmNGI5N2YxYmY1NTJmYjhjZg==
6
+ YzAwOWVlYzI1NDg3Y2ZhMzNlOWRhZmMxYTYyNTcwNzIyZTdjZGJhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODZjNTI3ZjlkZjZlOTNkZmU5YmQ4YzE1Zjc2N2FjMzMxMjI3M2ZlNjFlNWRl
10
- OGYzMDQ0YTgwMTFkYjE3MzJlOTQ5MGU2NGRmZDljMDk3NmU4YTYzM2Q4NTY4
11
- MWJkZjM1ZDliOTEzMDM3ZDk0YzBkMTZjMjg1OGJjNmZhMjIxMDY=
9
+ NGI3ODc5Mzc3MGRjOTRiNDAzYTJkNzM2M2UzYTYxMmY4N2VlODBkMzEwNWNj
10
+ MTRiYzM3N2QzODg5OGJlZjZjNmYzNWJjNWEyMGM1N2VlZWE2ZDJlNjc4Yjg5
11
+ YmRkNjE4ZDJlNTk2YTM5MjU4NGQ0YjJhNjk0ZmYxNmFkMGJlZTg=
12
12
  data.tar.gz: !binary |-
13
- MDI0MjdmMTE2MGE4ZDA3ZGE0NWJlYzAyNjliYmQxMjIzZjQ1ZjlhOGU2MmIy
14
- ZTljNjNkNDkzNTYyZWRmZDU5YzE2YTk4NWNmZmVlODZhY2IyMjFjYTA4Y2Uy
15
- OWQ1MzY1YzdmNDUzM2U3YTBmODEzZTA5MDYzMjNlNjBkNzc0OGM=
13
+ M2E2NTZmZjY3MDI3OTA2ZDQ2ZjkzN2I0NmY3Mjg5MGI5NDdiYmVhNGY2NmNj
14
+ MjRiOGY1MGEzODY0MzYwNzNkMDc4ZmMyNTBhMzY2MTE3YjkwMWU2MTQ0MThi
15
+ Yjc0YzAyZDAwNWQ3Y2JlZjhiOWY0MTNmMTY5ZDhhMmE2OGJkNmY=
@@ -1,6 +1,11 @@
1
1
  # @title Changelog
2
2
  # Changelog
3
3
 
4
+ ## 3.1.0 - December 17th, 2013
5
+
6
+ Added the `Oni::WrappedError` class that can be used to wrap existing error
7
+ classes within workers.
8
+
4
9
  ## 3.0.0 - December 17th, 2013
5
10
 
6
11
  This release reverts the changes of version 2.0.0 and 2.0.1 as they proved to
data/lib/oni.rb CHANGED
@@ -6,3 +6,4 @@ require_relative 'oni/configurable'
6
6
  require_relative 'oni/mapper'
7
7
  require_relative 'oni/worker'
8
8
  require_relative 'oni/daemon'
9
+ require_relative 'oni/wrapped_error'
@@ -1,3 +1,3 @@
1
1
  module Oni
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end # Oni
@@ -0,0 +1,43 @@
1
+ module Oni
2
+ ##
3
+ # Error class that can be used to wrap existing errors and attach extra data
4
+ # to them. This class is primarily intended to be used within workers to
5
+ # attach the input to the error.
6
+ #
7
+ # @!attribute [r] original_error
8
+ # @return [StandardError]
9
+ #
10
+ # @!attribute [r] parameters
11
+ # @return [Mixed]
12
+ #
13
+ class WrappedError < StandardError
14
+ attr_reader :original_error, :parameters
15
+
16
+ ##
17
+ # Wraps an existing error.
18
+ #
19
+ # @param [StandardError] error
20
+ # @param [Mixed] parameters
21
+ # @return [FeedbackDaemon::WorkerError]
22
+ #
23
+ def self.from(error, parameters = nil)
24
+ return new(
25
+ error.message,
26
+ :original_error => error,
27
+ :parameters => parameters
28
+ )
29
+ end
30
+
31
+ ##
32
+ # @param [String] message
33
+ # @param [Hash] options
34
+ #
35
+ def initialize(message = nil, options = {})
36
+ super(message)
37
+
38
+ options.each do |key, value|
39
+ instance_variable_set("@#{key}", value) if respond_to?(key)
40
+ end
41
+ end
42
+ end # WrappedError
43
+ end # Oni
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Oni::WrappedError do
4
+ before do
5
+ @original_error = StandardError.new('Hello world')
6
+ @parameters = {:foo => :bar}
7
+ end
8
+
9
+ context 'manually creating instances' do
10
+ example 'set the message' do
11
+ Oni::WrappedError.new('foo').message.should == 'foo'
12
+ end
13
+
14
+ example 'set the original error' do
15
+ error = Oni::WrappedError.new('foo', :original_error => @original_error)
16
+
17
+ error.original_error.should == @original_error
18
+ end
19
+
20
+ example 'set the parameters' do
21
+ error = Oni::WrappedError.new('foo', :parameters => @parameters)
22
+
23
+ error.parameters.should == @parameters
24
+ end
25
+ end
26
+
27
+ context 'creating instances from other errors' do
28
+ before do
29
+ @error = Oni::WrappedError.from(@original_error, @parameters)
30
+ end
31
+
32
+ example 'set the message' do
33
+ @error.message.should == @original_error.message
34
+ end
35
+
36
+ example 'set the original error' do
37
+ @error.original_error.should == @original_error
38
+ end
39
+
40
+ example 'set the parameters' do
41
+ @error.parameters.should == @parameters
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oni
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yorick Peterse
@@ -147,12 +147,14 @@ files:
147
147
  - lib/oni/mapper.rb
148
148
  - lib/oni/version.rb
149
149
  - lib/oni/worker.rb
150
+ - lib/oni/wrapped_error.rb
150
151
  - oni.gemspec
151
152
  - spec/oni/configurable_spec.rb
152
153
  - spec/oni/daemon_spec.rb
153
154
  - spec/oni/daemons/sqs_spec.rb
154
155
  - spec/oni/mapper_spec.rb
155
156
  - spec/oni/worker_spec.rb
157
+ - spec/oni/wrapped_error_spec.rb
156
158
  - spec/spec_helper.rb
157
159
  - spec/support/simplecov.rb
158
160
  - task/coverage.rake
@@ -190,6 +192,7 @@ test_files:
190
192
  - spec/oni/daemons/sqs_spec.rb
191
193
  - spec/oni/mapper_spec.rb
192
194
  - spec/oni/worker_spec.rb
195
+ - spec/oni/wrapped_error_spec.rb
193
196
  - spec/spec_helper.rb
194
197
  - spec/support/simplecov.rb
195
198
  has_rdoc: yard