diff --git a/client/ruby/flare/lib/solr.rb b/client/ruby/flare/lib/solr.rb deleted file mode 100755 index 8ecd326bc23..00000000000 --- a/client/ruby/flare/lib/solr.rb +++ /dev/null @@ -1,15 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require 'solr/request' -require 'solr/connection' -require 'solr/response' \ No newline at end of file diff --git a/client/ruby/flare/lib/solr/connection.rb b/client/ruby/flare/lib/solr/connection.rb deleted file mode 100755 index be5fa139a76..00000000000 --- a/client/ruby/flare/lib/solr/connection.rb +++ /dev/null @@ -1,33 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require 'net/http' - -module Solr - class Connection - attr_reader :url - - def initialize(url) - @url = URI.parse(url) - end - - def send(request) - post = Net::HTTP::Post.new(request.url_path) - post.body = request.to_http_body - post.content_type = 'application/x-www-form-urlencoded; charset=utf-8' - response = Net::HTTP.start(@url.host, @url.port) do |http| - http.request(post) - end - return request.response_format == :ruby ? RubyResponse.new(response.body) : XmlResponse.new(response.body) - end - end -end diff --git a/client/ruby/flare/lib/solr/request.rb b/client/ruby/flare/lib/solr/request.rb deleted file mode 100755 index 9b34d484d40..00000000000 --- a/client/ruby/flare/lib/solr/request.rb +++ /dev/null @@ -1,132 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require "erb" -include ERB::Util - -module Solr - class Request - attr_reader :url_path - attr_reader :response_format - - def initialize - @url_path = "/solr/select" - end - end - - class UpdateRequest < Request - # sent to /solr/update with XML body - def initialize(body) - @body = body.to_s - @url_path = "/solr/update" - @response_format = :xml - end - - def to_http_body - @body - end - end - - class AddDocumentRequest < UpdateRequest - def initialize(doc_hash) - xml = REXML::Element.new('add') - - doc = REXML::Element.new('doc') - - doc_hash.each do |key,value| - #TODO: add handling of array values - doc.add_element field(key.to_s, value) - end - - xml.add_element doc - super(xml.to_s) - end - - private - def field(name, value) - field = REXML::Element.new("field") - field.add_attribute("name", name) - field.add_text(value) - - field - end - end - - class SelectRequest < Request - # sent to /solr/select, with url query string parameters in the body - - def initialize - @response_format = :ruby - super - end - - def to_http_body - raw_params = self.to_hash - - http_params = [] - raw_params.each do |key,value| - #TODO: Add array value handling - http_params << "#{key}=#{url_encode(value)}" if value - end - - http_params.join("&") - end - - def to_hash - {:wt => "ruby"} - end - end - - class CommonRequestBase < SelectRequest - # supported by both standard and dismax request handlers - # start - # rows - # filter query (multiple) - # field list - attr_accessor :start - attr_accessor :rows - attr_accessor :filter_queries - attr_accessor :field_list - - # debug - # explainOther - - def to_hash - {:start => @start, - :rows => @rows, - :fq => @filter_queries, - :fl => @field_list}.merge(super) - end - end - - class StandardRequest < CommonRequestBase - # sort - # default field - # query - # query operator (AND/OR) - attr_accessor :sort - attr_accessor :default_field - attr_accessor :query - attr_accessor :operator - - def to_hash - {:df => @default_field, - :q => @sort ? "#{@query};#{@sort}" : @query, - :op => @operator}.merge(super) - end - end - -end - -#s = Solr::Request.new("http://localhost:8983") -#s.add({:title => "foo"}) - diff --git a/client/ruby/flare/lib/solr/response.rb b/client/ruby/flare/lib/solr/response.rb deleted file mode 100755 index ac235a7525f..00000000000 --- a/client/ruby/flare/lib/solr/response.rb +++ /dev/null @@ -1,35 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -module Solr - class Response - attr_reader :header, :raw_response, :data - def initialize(body) - @raw_response = body - end - end - - class RubyResponse < Response - def initialize(body) - super(body) - parsed_response = eval(body) - @header = parsed_response['responseHeader'] - @data = parsed_response['response'] - end - end - - class XmlResponse < Response - def initialize(body) - super(body) - end - end -end diff --git a/client/ruby/flare/test/unit/connection_test.rb b/client/ruby/flare/test/unit/connection_test.rb deleted file mode 100755 index 0b554e52d74..00000000000 --- a/client/ruby/flare/test/unit/connection_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require File.dirname(__FILE__) + '/../test_helper' - -class ConnectionTest < Test::Unit::TestCase - def test_connection_initialize - request = Solr::UpdateRequest.new("") - connection = Solr::Connection.new("http://localhost:8983") - assert_equal("localhost", connection.url.host) - assert_equal(8983, connection.url.port) - end -end diff --git a/client/ruby/flare/test/unit/request_test.rb b/client/ruby/flare/test/unit/request_test.rb deleted file mode 100755 index 4661c921a4b..00000000000 --- a/client/ruby/flare/test/unit/request_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require File.dirname(__FILE__) + '/../test_helper' - -class RequestTest < Test::Unit::TestCase - def test_basic_params - request = Solr::StandardRequest.new - assert_equal("/solr/select", request.url_path) - - request.query = "term" - assert_equal "term", request.to_hash[:q] - end - - def test_update_request - request = Solr::UpdateRequest.new("") - assert_equal("/solr/update", request.url_path) - end - - def test_add_doc_request - request = Solr::AddDocumentRequest.new({:title => "title"}) - assert_equal("title", request.to_http_body) - end -end