lib/inquisitio/search_url_builder.rb in inquisitio-1.3.0 vs lib/inquisitio/search_url_builder.rb in inquisitio-1.3.1

- old
+ new

@@ -22,11 +22,11 @@ components << return_fields_query_string components << arguments components << "&size=#{@size}" unless @arguments[:size] components << "&start=#{@start}" unless @arguments[:start] || @start == 0 || @start == '0' components << '&sort=' + @sort.map {|k,v| "#{k}%20#{v}"}.join(',') unless @sort.empty? - components.join("") + components.join('') end private def simple_query "q=#{URI.encode(sanitise(@query.first)).gsub('&', '%26')}" @@ -48,11 +48,11 @@ if value.is_a?(String) "#{sanitise(key)}:'#{sanitise(value)}'" elsif value.is_a?(Array) "(or #{value.map {|v| "#{sanitise(key)}:'#{sanitise(v)}'" }.join(" ")})" else - raise InquisitioError.new("Filter values must be strings or arrays.") + raise InquisitioError.new('Filter values must be strings or arrays.') end end if Inquisitio.config.api_version == '2011-02-01' "bq=#{URI.encode("(and #{query_blocks.join(' ')})").gsub('&', '%26')}" @@ -64,19 +64,19 @@ def sanitise(value) value.to_s.gsub('\'','') end def return_fields_query_string - return "" if @return_fields.nil? + return '' if @return_fields.nil? if Inquisitio.config.api_version == '2011-02-01' "&return-fields=#{URI::encode(@return_fields.join(',').gsub('\'',''))}" elsif Inquisitio.config.api_version == '2013-01-01' "&return=#{URI::encode(@return_fields.join(',').gsub('\'',''))}" end end def arguments - return "" if @arguments.nil? + return '' if @arguments.nil? @arguments.map{|key,value| "&#{key.to_s.gsub('\'','')}=#{value.to_s.gsub('\'','')}"}.join("") end def url_root "#{Inquisitio.config.search_endpoint}/#{Inquisitio.config.api_version}/search?"