merge with master
This commit is contained in:
commit
e486a962e1
4
.gitignore
vendored
4
.gitignore
vendored
@ -39,3 +39,7 @@ test.db
|
||||
|
||||
# For those who install gems locally to a vendor dir
|
||||
/vendor
|
||||
|
||||
# Don't checkin Gemfile.lock
|
||||
# See: http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
|
||||
Gemfile.lock
|
||||
|
||||
117
Gemfile.lock
117
Gemfile.lock
@ -1,117 +0,0 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
fast_jsonapi (1.1.0)
|
||||
activesupport (>= 4.2)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionpack (5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
active_model_serializers (0.10.7)
|
||||
actionpack (>= 4.1, < 6)
|
||||
activemodel (>= 4.1, < 6)
|
||||
case_transform (>= 0.2)
|
||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||
activemodel (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activerecord (5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.4)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (8.0.0)
|
||||
benchmark-perf (0.2.1)
|
||||
builder (3.2.3)
|
||||
byebug (9.1.0)
|
||||
case_transform (0.2)
|
||||
activesupport
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.3)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.7.0)
|
||||
i18n (0.9.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jsonapi-deserializable (0.2.0)
|
||||
jsonapi-rb (0.5.0)
|
||||
jsonapi-deserializable (~> 0.2.0)
|
||||
jsonapi-serializable (~> 0.3.0)
|
||||
jsonapi-renderer (0.2.0)
|
||||
jsonapi-serializable (0.3.0)
|
||||
jsonapi-renderer (~> 0.2.0)
|
||||
jsonapi-serializers (1.0.0)
|
||||
activesupport
|
||||
loofah (2.1.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
nokogiri (1.8.1)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
oj (3.4.0)
|
||||
rack (2.0.3)
|
||||
rack-test (0.8.2)
|
||||
rack (>= 1.0, < 3)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
rspec (3.5.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
rspec-mocks (~> 3.5.0)
|
||||
rspec-benchmark (0.3.0)
|
||||
benchmark-perf (~> 0.2.0)
|
||||
rspec (>= 3.0.0, < 4.0.0)
|
||||
rspec-core (3.5.4)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-expectations (3.5.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-mocks (3.5.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-support (3.5.0)
|
||||
skylight (1.5.0)
|
||||
activesupport (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.4)
|
||||
thread_safe (~> 0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
active_model_serializers (~> 0.10.7)
|
||||
activerecord (>= 4.2)
|
||||
bundler (~> 1.0)
|
||||
byebug
|
||||
fast_jsonapi!
|
||||
jsonapi-rb (~> 0.5.0)
|
||||
jsonapi-serializers (~> 1.0.0)
|
||||
oj (~> 3.3)
|
||||
rspec (~> 3.5.0)
|
||||
rspec-benchmark (~> 0.3.0)
|
||||
skylight (~> 1.3)
|
||||
sqlite3 (~> 1.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |gem|
|
||||
gem.name = "fast_jsonapi"
|
||||
gem.version = "1.1.0"
|
||||
gem.version = "1.1.1"
|
||||
|
||||
gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
|
||||
gem.metadata = { "allowed_push_host" => "https://rubygems.org" } if gem.respond_to? :metadata=
|
||||
|
||||
@ -12,7 +12,12 @@ module FastJsonapi
|
||||
# e.g. https://github.com/github/github-ds/blob/fbda5389711edfb4c10b6c6bad19311dfcb1bac1/lib/github/result.rb
|
||||
class Result
|
||||
def initialize(*rescued_exceptions)
|
||||
rescued_exceptions = [StandardError] if rescued_exceptions.empty?
|
||||
@rescued_exceptions = if rescued_exceptions.empty?
|
||||
[StandardError]
|
||||
else
|
||||
rescued_exceptions
|
||||
end
|
||||
|
||||
@value = yield
|
||||
@error = nil
|
||||
rescue *rescued_exceptions => e
|
||||
@ -33,7 +38,8 @@ module FastJsonapi
|
||||
|
||||
def rescue
|
||||
return self if ok?
|
||||
Result.new { yield(@error) }
|
||||
|
||||
Result.new(*@rescued_exceptions) { yield(@error) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
21
spec/lib/multi_to_json/result_spec.rb
Normal file
21
spec/lib/multi_to_json/result_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module FastJsonapi
|
||||
module MultiToJson
|
||||
describe Result do
|
||||
it 'supports chaining of rescues' do
|
||||
expect do
|
||||
Result.new(LoadError) do
|
||||
require '1'
|
||||
end.rescue do
|
||||
require '2'
|
||||
end.rescue do
|
||||
require '3'
|
||||
end.rescue do
|
||||
'4'
|
||||
end
|
||||
end.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user