From bb3448c2e77dd71f0a6e2044168f443c26a2d4ae Mon Sep 17 00:00:00 2001 From: Nirmit Patel Date: Tue, 19 Apr 2011 10:26:15 -0700 Subject: [PATCH 1/2] Added fix for .blank? checks on objects which used to be set via another project. This approach doesn't allow other projects to use it as a self contained gem. --- lib/right_http_connection.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb index 7db1378..35f37bf 100644 --- a/lib/right_http_connection.rb +++ b/lib/right_http_connection.rb @@ -227,7 +227,7 @@ def eof_time # Returns true if we are receiving EOFs during last @params[:http_connection_retry_delay] seconds # and there were no successful response from server def raise_on_eof_exception? - @@eof[@server].blank? ? false : ((Time.now.to_i-@params[:http_connection_retry_delay]) > @@eof[@server].last.to_i) + blank?(@@eof[@server]) ? false : ((Time.now.to_i-@params[:http_connection_retry_delay]) > @@eof[@server].last.to_i) end # Reset a list of EOFs for this server. @@ -302,6 +302,16 @@ def start(request_params) @http.start end + def blank?(var) + if var.respond_to?(:empty?) && var.respond_to?(:strip) + var.empty? or var.strip.empty? + elsif var.respond_to?(:empty?) + var.empty? + else + !var + end + end + public =begin rdoc @@ -406,7 +416,7 @@ def request(request_params, &block) def finish(reason = '') if @http && @http.started? - reason = ", reason: '#{reason}'" unless reason.blank? + reason = ", reason: '#{reason}'" unless blank?(reason) @logger.info("Closing #{@http.use_ssl? ? 'HTTPS' : 'HTTP'} connection to #{@http.address}:#{@http.port}#{reason}") @http.finish end From b6e2f48a19bb5b601d6700657defd930851f7121 Mon Sep 17 00:00:00 2001 From: Nirmit Patel Date: Tue, 19 Apr 2011 10:32:10 -0700 Subject: [PATCH 2/2] Added change to allow blank check to use an inherited blank method check if available. --- lib/right_http_connection.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb index 35f37bf..428f631 100644 --- a/lib/right_http_connection.rb +++ b/lib/right_http_connection.rb @@ -303,7 +303,9 @@ def start(request_params) end def blank?(var) - if var.respond_to?(:empty?) && var.respond_to?(:strip) + if var.respond_to?(:blank?) + var.blank? + elsif var.respond_to?(:empty?) && var.respond_to?(:strip) var.empty? or var.strip.empty? elsif var.respond_to?(:empty?) var.empty?