rsolr 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +7 -0
- data/README.rdoc +11 -13
- data/lib/rsolr.rb +1 -1
- data/lib/rsolr/client.rb +5 -2
- data/lib/rsolr/connection.rb +4 -2
- data/rsolr.gemspec +11 -1
- data/spec/api/client_spec.rb +11 -4
- data/spec/api/connection_spec.rb +37 -1
- metadata +35 -19
data/CHANGES.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
1.0.7
|
2
|
+
- Response body encoding is set to response charset in Ruby >= 1.9
|
3
|
+
- Ability to set :read_timeout and :open_timeout when creating new instance of RSolr
|
4
|
+
1.0.6
|
5
|
+
- More dependency fixups
|
6
|
+
1.0.5
|
7
|
+
- Dependency fixups
|
1
8
|
1.0.4
|
2
9
|
- The "builder" gem dependency is less strict: ~> 2.1.2
|
3
10
|
- RSolr.version is no longer read from a file
|
data/README.rdoc
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
A simple, extensible Ruby client for Apache Solr.
|
4
4
|
|
5
|
-
Notice: This document is only for the the 1.0 in the master. The last pre 1.0 gem release documentation can be found here: http://github.com/mwmitchell/rsolr/tree/v0.12.1
|
6
|
-
|
7
5
|
==Documentation
|
8
|
-
The code docs for the last *release* can be viewed here
|
6
|
+
The code docs for the last *release* can be viewed here: http://rubydoc.info/gems/rsolr/1.0.6/frames
|
9
7
|
|
10
8
|
== Installation:
|
11
9
|
sudo gem install rsolr
|
@@ -34,6 +32,10 @@ The :request attribute contains the original request context. You can use this f
|
|
34
32
|
|
35
33
|
The :response attribute contains the original response. This object contains the :status, :body and :headers keys.
|
36
34
|
|
35
|
+
== Timeouts
|
36
|
+
The read and connect timeout settings can be set when creating a new instance of RSolr:
|
37
|
+
solr = RSolr.connect(:read_timeout => 120, :open_timeout => 120)
|
38
|
+
|
37
39
|
== Querying
|
38
40
|
Use the #get / #post method to send search requests to the /select handler:
|
39
41
|
response = solr.get 'select', :params => {
|
@@ -173,17 +175,13 @@ The default response format is Ruby. When the :wt param is set to :ruby, the res
|
|
173
175
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
174
176
|
* Send me a pull request. Bonus points for topic branches.
|
175
177
|
|
176
|
-
== Note on Patches/Pull Requests
|
177
|
-
|
178
|
-
* Fork the project.
|
179
|
-
* Make your feature addition or bug fix.
|
180
|
-
* Add tests for it. This is important so I don't break it in a
|
181
|
-
future version unintentionally.
|
182
|
-
* Commit, do not mess with rakefile, version, or history.
|
183
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
184
|
-
* Send me a pull request. Bonus points for topic branches.
|
185
|
-
|
186
178
|
==Contributors
|
179
|
+
* Antoine Latter
|
180
|
+
* Dmitry Lihachev
|
181
|
+
* Lucas Souza
|
182
|
+
* Peter Kieltyka
|
183
|
+
* Rob Di Marco
|
184
|
+
* Magnus Bergmark
|
187
185
|
* Jonathan Rochkind
|
188
186
|
* Chris Beer
|
189
187
|
* Craig Smith
|
data/lib/rsolr.rb
CHANGED
data/lib/rsolr/client.rb
CHANGED
@@ -142,7 +142,7 @@ class RSolr::Client
|
|
142
142
|
# "opts" : A hash, which can contain the following keys:
|
143
143
|
# :method : required - the http method (:get, :post or :head)
|
144
144
|
# :params : optional - the query string params in hash form
|
145
|
-
# :data : optional - post data -- if a hash is given, it's sent as "application/x-www-form-urlencoded"
|
145
|
+
# :data : optional - post data -- if a hash is given, it's sent as "application/x-www-form-urlencoded; charset=UTF-8"
|
146
146
|
# :headers : optional - hash of request headers
|
147
147
|
# All other options are passed right along to the connection's +send_and_receive+ method (:get, :post, or :head)
|
148
148
|
#
|
@@ -155,6 +155,9 @@ class RSolr::Client
|
|
155
155
|
# then passes the request/response into +adapt_response+.
|
156
156
|
def send_and_receive path, opts
|
157
157
|
request_context = build_request path, opts
|
158
|
+
[:open_timeout, :read_timeout].each do |k|
|
159
|
+
request_context[k] = @options[k]
|
160
|
+
end
|
158
161
|
execute request_context
|
159
162
|
end
|
160
163
|
|
@@ -190,7 +193,7 @@ class RSolr::Client
|
|
190
193
|
if opts[:data].is_a? Hash
|
191
194
|
opts[:data] = RSolr::Uri.params_to_solr opts[:data]
|
192
195
|
opts[:headers] ||= {}
|
193
|
-
opts[:headers]['Content-Type'] ||= 'application/x-www-form-urlencoded'
|
196
|
+
opts[:headers]['Content-Type'] ||= 'application/x-www-form-urlencoded; charset=UTF-8'
|
194
197
|
end
|
195
198
|
opts[:path] = path
|
196
199
|
opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri
|
data/lib/rsolr/connection.rb
CHANGED
@@ -8,7 +8,7 @@ class RSolr::Connection
|
|
8
8
|
# send a request,
|
9
9
|
# then return the standard rsolr response hash {:status, :body, :headers}
|
10
10
|
def execute client, request_context
|
11
|
-
h = http request_context[:uri], request_context[:proxy]
|
11
|
+
h = http request_context[:uri], request_context[:proxy], request_context[:read_timeout], request_context[:open_timeout]
|
12
12
|
request = setup_raw_request request_context
|
13
13
|
request.body = request_context[:data] if request_context[:method] == :post and request_context[:data]
|
14
14
|
begin
|
@@ -26,7 +26,7 @@ class RSolr::Connection
|
|
26
26
|
protected
|
27
27
|
|
28
28
|
# This returns a singleton of a Net::HTTP or Net::HTTP.Proxy request object.
|
29
|
-
def http uri, proxy = nil
|
29
|
+
def http uri, proxy = nil, read_timeout = nil, open_timeout = nil
|
30
30
|
@http ||= (
|
31
31
|
http = if proxy
|
32
32
|
proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxy.userinfo
|
@@ -35,6 +35,8 @@ class RSolr::Connection
|
|
35
35
|
Net::HTTP.new uri.host, uri.port
|
36
36
|
end
|
37
37
|
http.use_ssl = uri.port == 443 || uri.instance_of?(URI::HTTPS)
|
38
|
+
http.read_timeout = read_timeout if read_timeout
|
39
|
+
http.open_timeout = open_timeout if open_timeout
|
38
40
|
http
|
39
41
|
)
|
40
42
|
end
|
data/rsolr.gemspec
CHANGED
@@ -8,7 +8,17 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.summary = "A Ruby client for Apache Solr"
|
9
9
|
s.description = %q{RSolr aims to provide a simple and extensible library for working with Solr}
|
10
10
|
s.version = RSolr.version
|
11
|
-
s.authors = ["
|
11
|
+
s.authors = ["Antoine Latter", "Dmitry Lihachev",
|
12
|
+
"Lucas Souza", "Peter Kieltyka",
|
13
|
+
"Rob Di Marco", "Magnus Bergmark",
|
14
|
+
"Jonathan Rochkind", "Chris Beer",
|
15
|
+
"Craig Smith", "Randy Souza",
|
16
|
+
"Colin Steele", "Peter Kieltyka",
|
17
|
+
"Lorenzo Riccucci", "Mike Perham",
|
18
|
+
"Mat Brown", "Shairon Toledo",
|
19
|
+
"Matthew Rudy", "Fouad Mardini",
|
20
|
+
"Jeremy Hinegardner", "Nathan Witmer",
|
21
|
+
"\"shima\""]
|
12
22
|
s.email = ["goodieboy@gmail.com"]
|
13
23
|
s.homepage = "https://github.com/mwmitchell/rsolr"
|
14
24
|
s.rubyforge_project = "rsolr"
|
data/spec/api/client_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe "RSolr::Client" do
|
|
5
5
|
def client
|
6
6
|
@client ||= (
|
7
7
|
connection = RSolr::Connection.new
|
8
|
-
RSolr::Client.new connection, :url => "http://localhost:9999/solr"
|
8
|
+
RSolr::Client.new connection, :url => "http://localhost:9999/solr", :read_timeout => 42, :open_timeout=>43
|
9
9
|
)
|
10
10
|
end
|
11
11
|
end
|
@@ -25,6 +25,13 @@ describe "RSolr::Client" do
|
|
25
25
|
client.send_and_receive '', :method => meth, :params => {}, :data => nil, :headers => {}
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
it "should be timeout aware" do
|
30
|
+
[:get, :post, :head].each do |meth|
|
31
|
+
client.connection.should_receive(:execute).with(client, hash_including(:read_timeout => 42, :open_timeout=>43))
|
32
|
+
client.send_and_receive '', :method => meth, :params => {}, :data => nil, :headers => {}
|
33
|
+
end
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
context "post" do
|
@@ -197,7 +204,7 @@ describe "RSolr::Client" do
|
|
197
204
|
result[:headers].should == {}
|
198
205
|
end
|
199
206
|
|
200
|
-
it "should set the Content-Type header to application/x-www-form-urlencoded if a hash is passed in to the data arg" do
|
207
|
+
it "should set the Content-Type header to application/x-www-form-urlencoded; charset=UTF-8 if a hash is passed in to the data arg" do
|
201
208
|
result = client.build_request('select',
|
202
209
|
:method => :post,
|
203
210
|
:data => {:q=>'test', :fq=>[0,1]},
|
@@ -208,9 +215,9 @@ describe "RSolr::Client" do
|
|
208
215
|
result[:data].should match pattern
|
209
216
|
end
|
210
217
|
result[:data].should_not match /wt=ruby/
|
211
|
-
result[:headers].should == {"Content-Type" => "application/x-www-form-urlencoded"}
|
218
|
+
result[:headers].should == {"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"}
|
212
219
|
end
|
213
220
|
|
214
221
|
end
|
215
222
|
|
216
|
-
end
|
223
|
+
end
|
data/spec/api/connection_spec.rb
CHANGED
@@ -11,5 +11,41 @@ describe "RSolr::Connection" do
|
|
11
11
|
req.each_header{|k,v| headers[k] = v}
|
12
12
|
headers.should == {"content-type"=>"text/xml"}
|
13
13
|
end
|
14
|
+
|
15
|
+
context "read timeout configuration" do
|
16
|
+
let(:client) { mock.as_null_object }
|
17
|
+
|
18
|
+
subject { RSolr::Connection.new }
|
19
|
+
|
20
|
+
it "should configure Net:HTTP read_timeout" do
|
21
|
+
subject.execute client, {:uri => URI.parse("http://localhost/some_uri"), :method => :get, :read_timeout => 42}
|
22
|
+
http = subject.instance_variable_get(:@http)
|
23
|
+
http.read_timeout.should == 42
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should use Net:HTTP default read_timeout if not specified" do
|
27
|
+
subject.execute client, {:uri => URI.parse("http://localhost/some_uri"), :method => :get}
|
28
|
+
http = subject.instance_variable_get(:@http)
|
29
|
+
http.read_timeout.should == 60
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "open timeout configuration" do
|
34
|
+
let(:client) { mock.as_null_object }
|
35
|
+
|
36
|
+
subject { RSolr::Connection.new }
|
37
|
+
|
38
|
+
it "should configure Net:HTTP open_timeout" do
|
39
|
+
subject.execute client, {:uri => URI.parse("http://localhost/some_uri"), :method => :get, :open_timeout => 42}
|
40
|
+
http = subject.instance_variable_get(:@http)
|
41
|
+
http.open_timeout.should == 42
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should use Net:HTTP default open_timeout if not specified" do
|
45
|
+
subject.execute client, {:uri => URI.parse("http://localhost/some_uri"), :method => :get}
|
46
|
+
http = subject.instance_variable_get(:@http)
|
47
|
+
http.open_timeout.should == nil
|
48
|
+
end
|
49
|
+
end
|
14
50
|
|
15
|
-
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsolr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- Mike Perham
|
12
|
-
- Nathan Witmer
|
8
|
+
- Antoine Latter
|
9
|
+
- Dmitry Lihachev
|
10
|
+
- Lucas Souza
|
13
11
|
- Peter Kieltyka
|
14
|
-
-
|
15
|
-
-
|
16
|
-
- shima
|
17
|
-
- Chris Beer
|
12
|
+
- Rob Di Marco
|
13
|
+
- Magnus Bergmark
|
18
14
|
- Jonathan Rochkind
|
15
|
+
- Chris Beer
|
16
|
+
- Craig Smith
|
17
|
+
- Randy Souza
|
18
|
+
- Colin Steele
|
19
|
+
- Peter Kieltyka
|
20
|
+
- Lorenzo Riccucci
|
21
|
+
- Mike Perham
|
22
|
+
- Mat Brown
|
23
|
+
- Shairon Toledo
|
24
|
+
- Matthew Rudy
|
25
|
+
- Fouad Mardini
|
26
|
+
- Jeremy Hinegardner
|
27
|
+
- Nathan Witmer
|
28
|
+
- ! '"shima"'
|
19
29
|
autorequire:
|
20
30
|
bindir: bin
|
21
31
|
cert_chain: []
|
22
|
-
date:
|
32
|
+
date: 2012-02-12 00:00:00.000000000Z
|
23
33
|
dependencies:
|
24
34
|
- !ruby/object:Gem::Dependency
|
25
35
|
name: builder
|
26
|
-
requirement: &
|
36
|
+
requirement: &70108731684080 !ruby/object:Gem::Requirement
|
27
37
|
none: false
|
28
38
|
requirements:
|
29
39
|
- - ! '>='
|
@@ -31,10 +41,10 @@ dependencies:
|
|
31
41
|
version: 2.1.2
|
32
42
|
type: :runtime
|
33
43
|
prerelease: false
|
34
|
-
version_requirements: *
|
44
|
+
version_requirements: *70108731684080
|
35
45
|
- !ruby/object:Gem::Dependency
|
36
46
|
name: rake
|
37
|
-
requirement: &
|
47
|
+
requirement: &70108731667240 !ruby/object:Gem::Requirement
|
38
48
|
none: false
|
39
49
|
requirements:
|
40
50
|
- - ~>
|
@@ -42,10 +52,10 @@ dependencies:
|
|
42
52
|
version: 0.9.2
|
43
53
|
type: :development
|
44
54
|
prerelease: false
|
45
|
-
version_requirements: *
|
55
|
+
version_requirements: *70108731667240
|
46
56
|
- !ruby/object:Gem::Dependency
|
47
57
|
name: rdoc
|
48
|
-
requirement: &
|
58
|
+
requirement: &70108731666080 !ruby/object:Gem::Requirement
|
49
59
|
none: false
|
50
60
|
requirements:
|
51
61
|
- - ~>
|
@@ -53,10 +63,10 @@ dependencies:
|
|
53
63
|
version: 3.9.4
|
54
64
|
type: :development
|
55
65
|
prerelease: false
|
56
|
-
version_requirements: *
|
66
|
+
version_requirements: *70108731666080
|
57
67
|
- !ruby/object:Gem::Dependency
|
58
68
|
name: rspec
|
59
|
-
requirement: &
|
69
|
+
requirement: &70108731665120 !ruby/object:Gem::Requirement
|
60
70
|
none: false
|
61
71
|
requirements:
|
62
72
|
- - ~>
|
@@ -64,7 +74,7 @@ dependencies:
|
|
64
74
|
version: 2.6.0
|
65
75
|
type: :development
|
66
76
|
prerelease: false
|
67
|
-
version_requirements: *
|
77
|
+
version_requirements: *70108731665120
|
68
78
|
description: RSolr aims to provide a simple and extensible library for working with
|
69
79
|
Solr
|
70
80
|
email:
|
@@ -113,12 +123,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
123
|
- - ! '>='
|
114
124
|
- !ruby/object:Gem::Version
|
115
125
|
version: '0'
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
hash: -700646824116965374
|
116
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
130
|
none: false
|
118
131
|
requirements:
|
119
132
|
- - ! '>='
|
120
133
|
- !ruby/object:Gem::Version
|
121
134
|
version: '0'
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
hash: -700646824116965374
|
122
138
|
requirements: []
|
123
139
|
rubyforge_project: rsolr
|
124
140
|
rubygems_version: 1.8.11
|