mwmitchell-rsolr 0.9.1 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/test/message_test.rb CHANGED
@@ -3,12 +3,16 @@ require 'helper'
3
3
 
4
4
  module MessageTestMethods
5
5
 
6
+ def builder
7
+ @builder ||= RSolr::Message::Builder.new
8
+ end
9
+
6
10
  # call all of the simple methods...
7
11
  # make sure the xml string is valid
8
12
  # ensure the class is actually Solr::XML
9
13
  def test_simple_methods
10
14
  [:optimize, :rollback, :commit].each do |meth|
11
- result = RSolr::Message.send(meth)
15
+ result = self.builder.send(meth)
12
16
  assert_equal "<#{meth}/>", result.to_s
13
17
  assert_equal String, result.class
14
18
  end
@@ -17,7 +21,7 @@ module MessageTestMethods
17
21
  def test_add_yields_doc_objects_if_block_given
18
22
  documents = [{:id=>1, :name=>'sam', :cat=>['cat 1', 'cat 2']}]
19
23
  add_attrs = {:boost=>200.00}
20
- result = RSolr::Message.add(documents, add_attrs) do |doc|
24
+ result = self.builder.add(documents, add_attrs) do |doc|
21
25
  doc.field_by_name(:name).attrs[:boost] = 10
22
26
  assert_equal 4, doc.fields.size
23
27
  assert_equal 2, doc.fields_by_name(:cat).size
@@ -38,25 +42,25 @@ module MessageTestMethods
38
42
  end
39
43
 
40
44
  def test_delete_by_id
41
- result = RSolr::Message.delete_by_id(10)
45
+ result = self.builder.delete_by_id(10)
42
46
  assert_equal String, result.class
43
47
  assert_equal '<delete><id>10</id></delete>', result.to_s
44
48
  end
45
49
 
46
50
  def test_delete_by_multiple_ids
47
- result = RSolr::Message.delete_by_id([1, 2, 3])
51
+ result = self.builder.delete_by_id([1, 2, 3])
48
52
  assert_equal String, result.class
49
53
  assert_equal '<delete><id>1</id><id>2</id><id>3</id></delete>', result.to_s
50
54
  end
51
55
 
52
56
  def test_delete_by_query
53
- result = RSolr::Message.delete_by_query('status:"LOST"')
57
+ result = self.builder.delete_by_query('status:"LOST"')
54
58
  assert_equal String, result.class
55
59
  assert_equal '<delete><query>status:"LOST"</query></delete>', result.to_s
56
60
  end
57
61
 
58
62
  def test_delete_by_multiple_queries
59
- result = RSolr::Message.delete_by_query(['status:"LOST"', 'quantity:0'])
63
+ result = self.builder.delete_by_query(['status:"LOST"', 'quantity:0'])
60
64
  assert_equal String, result.class
61
65
  assert_equal '<delete><query>status:"LOST"</query><query>quantity:0</query></delete>', result.to_s
62
66
  end
@@ -67,8 +71,8 @@ module MessageTestMethods
67
71
  :id=>1,
68
72
  :name=>'matt'
69
73
  }
70
- assert RSolr::Message.add(data).to_s =~ /<field name="name">matt<\/field>/
71
- assert RSolr::Message.add(data).to_s =~ /<field name="id">1<\/field>/
74
+ assert self.builder.add(data).to_s =~ /<field name="name">matt<\/field>/
75
+ assert self.builder.add(data).to_s =~ /<field name="id">1<\/field>/
72
76
  end
73
77
 
74
78
  # add an array of hashes
@@ -84,7 +88,7 @@ module MessageTestMethods
84
88
  }
85
89
  ]
86
90
 
87
- message = RSolr::Message.add(data)
91
+ message = self.builder.add(data)
88
92
  expected = '<add><doc><field name="id">1</field><field name="name">matt</field></doc><doc><field name="id">2</field><field name="name">sam</field></doc></add>'
89
93
 
90
94
  assert message.to_s=~/<field name="name">matt<\/field>/
@@ -98,7 +102,7 @@ module MessageTestMethods
98
102
  :name => ['matt1', 'matt2']
99
103
  }
100
104
 
101
- result = RSolr::Message.add(data)
105
+ result = self.builder.add(data)
102
106
 
103
107
  assert result.to_s =~ /<field name="name">matt1<\/field>/
104
108
  assert result.to_s =~ /<field name="name">matt2<\/field>/
@@ -108,7 +112,7 @@ module MessageTestMethods
108
112
  document = RSolr::Message::Document.new
109
113
  document.add_field('id', 1)
110
114
  document.add_field('name', 'matt', :boost => 2.0)
111
- result = RSolr::Message.add(document)
115
+ result = self.builder.add(document)
112
116
 
113
117
  assert result.to_s =~ /<field name="id">1<\/field>/
114
118
 
@@ -127,7 +131,7 @@ module MessageTestMethods
127
131
  doc.add_field('name', "matt#{i}")
128
132
  doc
129
133
  end
130
- result = RSolr::Message.add(documents)
134
+ result = self.builder.add(documents)
131
135
 
132
136
  assert result.to_s =~ /<field name="name">matt1<\/field>/
133
137
  assert result.to_s =~ /<field name="name">matt2<\/field>/
@@ -143,7 +147,7 @@ unless defined?(JRUBY_VERSION)
143
147
  include MessageTestMethods
144
148
 
145
149
  def setup
146
- RSolr::Message.builder = RSolr::Message::Builders::Libxml.new
150
+ self.builder.adapter = RSolr::Message::Adapter::Libxml.new
147
151
  end
148
152
 
149
153
  end
@@ -157,8 +161,7 @@ class BuilderMessageTest < RSolrBaseTest
157
161
  include MessageTestMethods
158
162
 
159
163
  def setup
160
- # RSolr::Message::Builders::Libxml.new
161
- RSolr::Message.builder = RSolr::Message::Builders::Builder.new
164
+ self.builder.adapter = RSolr::Message::Adapter::Builder.new
162
165
  end
163
166
 
164
167
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwmitchell-rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mitchell
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-22 00:00:00 -07:00
12
+ date: 2009-09-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,17 +37,14 @@ files:
37
37
  - examples/http.rb
38
38
  - examples/direct.rb
39
39
  - lib/rsolr.rb
40
- - lib/rsolr/adapter/direct.rb
41
- - lib/rsolr/adapter/http.rb
42
- - lib/rsolr/adapter.rb
40
+ - lib/rsolr/connection/adapter/direct.rb
41
+ - lib/rsolr/connection/adapter/http.rb
43
42
  - lib/rsolr/connection.rb
44
43
  - lib/rsolr/http_client/adapter/curb.rb
45
44
  - lib/rsolr/http_client/adapter/net_http.rb
46
- - lib/rsolr/http_client/adapter.rb
47
45
  - lib/rsolr/http_client.rb
48
- - lib/rsolr/message/builders/builder.rb
49
- - lib/rsolr/message/builders/libxml.rb
50
- - lib/rsolr/message/builders.rb
46
+ - lib/rsolr/message/adapter/builder.rb
47
+ - lib/rsolr/message/adapter/libxml.rb
51
48
  - lib/rsolr/message.rb
52
49
  - LICENSE
53
50
  - Rakefile
@@ -56,6 +53,7 @@ files:
56
53
  - CHANGES.txt
57
54
  has_rdoc: true
58
55
  homepage: http://github.com/mwmitchell/rsolr
56
+ licenses:
59
57
  post_install_message:
60
58
  rdoc_options: []
61
59
 
@@ -76,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
74
  requirements: []
77
75
 
78
76
  rubyforge_project:
79
- rubygems_version: 1.2.0
77
+ rubygems_version: 1.3.5
80
78
  signing_key:
81
79
  specification_version: 2
82
80
  summary: A Ruby client for Apache Solr
data/lib/rsolr/adapter.rb DELETED
@@ -1,6 +0,0 @@
1
- module RSolr::Adapter
2
-
3
- autoload :Direct, 'rsolr/adapter/direct'
4
- autoload :HTTP, 'rsolr/adapter/http'
5
-
6
- end
@@ -1,6 +0,0 @@
1
- module RSolr::HTTPClient::Adapter
2
-
3
- autoload :Curb, 'rsolr/http_client/adapter/curb'
4
- autoload :NetHTTP, 'rsolr/http_client/adapter/net_http'
5
-
6
- end
@@ -1,6 +0,0 @@
1
- module RSolr::Message::Builders
2
-
3
- autoload :Builder, 'rsolr/message/builders/builder'
4
- autoload :Libxml, 'rsolr/message/builders/libxml'
5
-
6
- end