solr-ruby 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,7 +37,7 @@ class Solr::Document
37
37
  case fields
38
38
  when Hash
39
39
  fields.each_pair do |name,value|
40
- if value.respond_to?(:each)
40
+ if value.respond_to?(:each) && !value.is_a?(String)
41
41
  value.each {|v| @fields << Solr::Field.new(name => v)}
42
42
  else
43
43
  @fields << Solr::Field.new(name => value)
@@ -25,7 +25,7 @@ class Solr::Importer::Mapper
25
25
  when String
26
26
  field_mapping
27
27
  when Proc
28
- field_mapping.call(orig_data)
28
+ field_mapping.call(orig_data) # TODO pass in more context, like self or a function for field_data, etc
29
29
  when Symbol
30
30
  field_data(orig_data, @options[:stringify_symbols] ? field_mapping.to_s : field_mapping)
31
31
  when Enumerable
@@ -19,7 +19,7 @@ class Solr::Request::Dismax < Solr::Request::Standard
19
19
  @alternate_query = params.delete(:alternate_query)
20
20
  @sort_values = params.delete(:sort)
21
21
 
22
- super(params)
22
+ super
23
23
 
24
24
  @query_type = "dismax"
25
25
  end
@@ -16,4 +16,7 @@ class Solr::Request::IndexInfo < Solr::Request::Select
16
16
  'admin/luke'
17
17
  end
18
18
 
19
+ def to_hash
20
+ {:numTerms => 0}.merge(super.to_hash)
21
+ end
19
22
  end
@@ -12,6 +12,6 @@
12
12
 
13
13
  class Solr::Response::AddDocument < Solr::Response::Xml
14
14
  def initialize(xml)
15
- super(xml)
15
+ super
16
16
  end
17
17
  end
@@ -12,7 +12,7 @@
12
12
 
13
13
  class Solr::Response::IndexInfo < Solr::Response::Ruby
14
14
  def initialize(ruby_code)
15
- super(ruby_code)
15
+ super
16
16
  end
17
17
 
18
18
  def num_docs
@@ -15,7 +15,7 @@ require 'rexml/xpath'
15
15
  class Solr::Response::Ping < Solr::Response::Xml
16
16
 
17
17
  def initialize(xml)
18
- super(xml)
18
+ super
19
19
  @ok = REXML::XPath.first(@doc, './solr/ping') ? true : false
20
20
  end
21
21
 
@@ -14,7 +14,7 @@ class Solr::Response::Ruby < Solr::Response::Base
14
14
  attr_reader :data
15
15
 
16
16
  def initialize(ruby_code)
17
- super(ruby_code)
17
+ super
18
18
  begin
19
19
  #TODO: what about pulling up data/header/response to ResponseBase,
20
20
  # or maybe a new middle class like SelectResponseBase since
@@ -15,7 +15,7 @@ class Solr::Response::Standard < Solr::Response::Ruby
15
15
  include Enumerable
16
16
 
17
17
  def initialize(ruby_code)
18
- super(ruby_code)
18
+ super
19
19
  @response = @data['response']
20
20
  raise "response section missing" unless @response.kind_of? Hash
21
21
  end
@@ -17,7 +17,7 @@ class Solr::Response::Xml < Solr::Response::Base
17
17
  attr_reader :doc, :status_code, :status_message
18
18
 
19
19
  def initialize(xml)
20
- super(xml)
20
+ super
21
21
  # parse the xml
22
22
  @doc = REXML::Document.new(xml)
23
23
 
@@ -22,13 +22,7 @@ class Solr::Util
22
22
 
23
23
  # paired_array_to_hash([key1,value1,key2,value2]) => {key1 => value1, key2, value2}
24
24
  def self.paired_array_to_hash(a)
25
- h = {}
26
-
27
- paired_array_each(a) do |key,value|
28
- h[key] = value
29
- end
30
-
31
- h
25
+ Hash[*a]
32
26
  end
33
27
 
34
28
  end
@@ -62,4 +62,8 @@ class DocumentTest < Test::Unit::TestCase
62
62
  assert_match(/<doc boost=['"]300.28['"]>[\s]*<field name=['"]name['"]>McGrump<\/field>[\s]*<\/doc>/, doc.to_xml.to_s)
63
63
  end
64
64
 
65
+ def test_string_values
66
+ doc = Solr::Document.new :name => "multi\nline"
67
+ assert_match(/<doc>[\s]*<field name=['"]name['"]>multi\nline<\/field>[\s]*<\/doc>/, doc.to_xml.to_s)
68
+ end
65
69
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: solr-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-05-22 00:00:00 -04:00
6
+ version: 0.0.4
7
+ date: 2007-08-16 00:00:00 -04:00
8
8
  summary: Ruby library for working with Apache Solr
9
9
  require_paths:
10
10
  - lib