Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better error handling. version bump to 0.0.6

  • Loading branch information...
commit 6f67214644b9168b83312f7f3816ea6ad115fdbb 1 parent abf59a6
Diego Buthay authored
View
2  VERSION
@@ -1 +1 @@
-0.0.5
+0.0.6
View
BIN  indextank-0.0.4.gem
Binary file not shown
View
BIN  indextank-0.0.5.gem
Binary file not shown
View
4 indextank.gemspec
@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{indextank}
- s.version = "0.0.5"
+ s.version = "0.0.6"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Santiago Perez", "Terence Lee"]
- s.date = %q{2010-08-24}
+ s.date = %q{2011-01-04}
s.description = %q{Ruby Client for the IndexTank API}
s.email = ["santip@santip.com.ar", "hone02@gmail.com"]
s.files = ["lib/indextank.rb", "lib/indextank/client.rb", "lib/indextank/document.rb", "lib/indextank/exceptions.rb", "lib/indextank/function.rb", "lib/indextank/index.rb", "spec/lib/indextank/client_spec.rb", "spec/lib/indextank/document_spec.rb", "spec/lib/indextank/function_spec.rb", "spec/lib/indextank/index_spec.rb", "spec/spec_helper.rb"]
View
2  lib/indextank.rb
@@ -5,7 +5,7 @@
require File.join(directory, 'indextank', 'client')
module IndexTank
- VERSION = "0.0.5"
+ VERSION = "0.0.6"
def self.setup_connection(url, &block)
@conn = Faraday::Connection.new(:url => url) do |builder|
View
19 lib/indextank/document.rb
@@ -7,7 +7,7 @@ class Document
def initialize(document_url, docid)
@docid = docid
- builder = Proc.new { |builder| builder.use ResponseDocument }
+ builder = Proc.new { |builder| builder.use DocumentResponseMiddleware }
@conn = IndexTank.setup_connection(document_url, &builder)
end
@@ -59,22 +59,9 @@ def update_categories(categories, options = {} )
resp.status
end
- #private
- # Handles standard returns status. All methods on documents should return HTTP 200,
- # and the errors are 'common' for any other value
- #def handle_return_status(status)
- # case status
- # when 400
- # raise InvalidArgument
- # when 409
- # raise IndexInitializing
- # when 404
- # raise IndexNotFound
- # end
- #end
end
- class ResponseDocument < Faraday::Response::Middleware
+ class DocumentResponseMiddleware < Faraday::Response::Middleware
def self.register_on_complete(env)
env[:response].on_complete do |finished_env|
case finished_env[:status]
@@ -85,7 +72,7 @@ def self.register_on_complete(env)
when 404
raise NonExistentIndex
when 400
- raise InvalidArgument
+ raise InvalidArgument, finished_env[:body]
end
end
end
View
24 lib/indextank/function.rb
@@ -8,7 +8,8 @@ def initialize(function_url, index, definition)
@uri = "#{function_url}/#{index}"
@index = index
@definition = definition
- builder = Proc.new { |builder| builder.use ResponseDocument }
+ # Function and Document have the same Response statuses .. so borrow DocumentResponseMiddleware
+ builder = Proc.new { |builder| builder.use IndexTank::DocumentResponseMiddleware }
@conn = IndexTank.setup_connection(@uri, &builder)
end
@@ -35,25 +36,4 @@ def ==(other)
self.definition == other.definition
end
end
- class ResponseDocument < Faraday::Response::Middleware
- def self.register_on_complete(env)
- env[:response].on_complete do |finished_env|
- case finished_env[:status]
- when 401
- raise InvalidApiKey
- when 409
- raise IndexInitializing
- when 404
- raise NonExistentIndex
- when 400
- raise InvalidArgument
- end
- end
- end
-
- def initialize(app)
- super
- @parser = nil
- end
- end
end
Please sign in to comment.
Something went wrong with that request. Please try again.