gsolr 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in gsolr.gemspec
4
4
  gemspec
5
5
 
6
- # gem 'builder'
6
+ gem 'builder'
7
7
 
8
8
  group :test do
9
9
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -1,30 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gsolr (0.0.1)
5
- json (~> 1.4.6)
4
+ gsolr (0.12.3)
5
+ json
6
+ streamly_ffi
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ builder (2.1.2)
12
+ curl_ffi (0.0.8)
13
+ ffi
10
14
  diff-lcs (1.1.2)
15
+ ffi (0.6.3)
16
+ rake (>= 0.8.7)
17
+ ffi (0.6.3-java)
11
18
  json (1.4.6)
12
- rspec (2.0.1)
13
- rspec-core (~> 2.0.1)
14
- rspec-expectations (~> 2.0.1)
15
- rspec-mocks (~> 2.0.1)
16
- rspec-core (2.0.1)
17
- rspec-expectations (2.0.1)
18
- diff-lcs (>= 1.1.2)
19
- rspec-mocks (2.0.1)
20
- rspec-core (~> 2.0.1)
21
- rspec-expectations (~> 2.0.1)
19
+ json (1.4.6-java)
20
+ rake (0.8.7)
21
+ rspec (2.1.0)
22
+ rspec-core (~> 2.1.0)
23
+ rspec-expectations (~> 2.1.0)
24
+ rspec-mocks (~> 2.1.0)
25
+ rspec-core (2.1.0)
26
+ rspec-expectations (2.1.0)
27
+ diff-lcs (~> 1.1.2)
28
+ rspec-mocks (2.1.0)
29
+ streamly_ffi (0.2.4)
30
+ curl_ffi
22
31
 
23
32
  PLATFORMS
33
+ java
24
34
  ruby
25
35
 
26
36
  DEPENDENCIES
37
+ builder
27
38
  gsolr!
28
- json (~> 1.4.6)
39
+ json
29
40
  rspec
30
41
  rspec-core
42
+ streamly_ffi
data/Rakefile CHANGED
@@ -28,7 +28,6 @@ task :release => :gem do
28
28
  system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
29
29
  end
30
30
 
31
-
32
31
  ENV['RUBYOPT'] = '-W1'
33
32
 
34
33
  task :environment do
data/bench.rb ADDED
@@ -0,0 +1,38 @@
1
+
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
4
+
5
+ require 'rubygems' if RUBY_VERSION < '1.9'
6
+ require 'gsolr'
7
+ require 'rsolr'
8
+ require 'benchmark'
9
+
10
+ #puts "press any key to continue"; blah = STDIN.gets.chomp
11
+
12
+ iters = (ARGV[0] || 100).to_i
13
+ url = ARGV[1]
14
+ query = ARGV[2] || "hello"
15
+
16
+ if url.nil? or query.nil?
17
+ puts "to use, call #{$0} with arguments: #iterations solr_url \"query to benchmark\""
18
+ exit
19
+ end
20
+
21
+ Benchmark.bmbm do |x|
22
+ x.report do
23
+ puts "GSolr"
24
+ gsolr = GSolr.connect(:url => url)
25
+ iters.to_i.times do |_i|
26
+ gsolr.request("/select", :q => query)
27
+ end
28
+ end
29
+
30
+ x.report do
31
+ puts "RSolr"
32
+ rsolr = RSolr.connect(:url => url)
33
+ iters.to_i.times do
34
+ rsolr.request("/select", :q => query)
35
+ end
36
+ end
37
+ end
38
+
data/gsolr.gemspec CHANGED
@@ -1,25 +1,26 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require 'date'
3
5
  require "gsolr/version"
4
6
 
5
7
  Gem::Specification.new do |s|
6
8
  s.name = "gsolr"
7
- s.version = Gsolr::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Scott Gonyea"]
9
+ s.version = GSolr::VERSION
10
+ s.date = Date.today.to_s
11
+ s.authors = ["Scott Gonyea"] # "Matt Mitchell" authored RSolr
10
12
  s.email = ["me@sgonyea.com"]
11
- s.homepage = "http://rubygems.org/gems/gsolr"
13
+ s.homepage = "https://github.com/aitrus/gsolr"
14
+
12
15
  s.summary = %q{Generic Solr Client}
13
16
  s.description = %q{This is a generic solr client, capable of talking to Solr, as well as Riak}
14
17
 
15
- s.rubyforge_project = "gsolr"
18
+ s.add_dependency('json')
19
+ s.add_dependency('streamly_ffi')
16
20
 
17
- s.add_dependency('json', '~>1.4.6')
18
-
19
21
  s.add_development_dependency "rspec"
20
22
 
21
23
  s.files = `git ls-files`.split("\n")
22
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
25
  s.require_paths = ["lib"]
25
26
  end
data/gsolr.tmproj ADDED
@@ -0,0 +1,307 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>currentDocument</key>
6
+ <string>Rakefile</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string>gsolr</string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>sourceDirectory</key>
17
+ <string></string>
18
+ </dict>
19
+ </array>
20
+ <key>fileHierarchyDrawerWidth</key>
21
+ <integer>200</integer>
22
+ <key>metaData</key>
23
+ <dict>
24
+ <key>Gemfile</key>
25
+ <dict>
26
+ <key>caret</key>
27
+ <dict>
28
+ <key>column</key>
29
+ <integer>0</integer>
30
+ <key>line</key>
31
+ <integer>11</integer>
32
+ </dict>
33
+ <key>firstVisibleColumn</key>
34
+ <integer>0</integer>
35
+ <key>firstVisibleLine</key>
36
+ <integer>0</integer>
37
+ </dict>
38
+ <key>Rakefile</key>
39
+ <dict>
40
+ <key>caret</key>
41
+ <dict>
42
+ <key>column</key>
43
+ <integer>0</integer>
44
+ <key>line</key>
45
+ <integer>0</integer>
46
+ </dict>
47
+ <key>columnSelection</key>
48
+ <false/>
49
+ <key>firstVisibleColumn</key>
50
+ <integer>0</integer>
51
+ <key>firstVisibleLine</key>
52
+ <integer>0</integer>
53
+ <key>selectFrom</key>
54
+ <dict>
55
+ <key>column</key>
56
+ <integer>94</integer>
57
+ <key>line</key>
58
+ <integer>1</integer>
59
+ </dict>
60
+ <key>selectTo</key>
61
+ <dict>
62
+ <key>column</key>
63
+ <integer>0</integer>
64
+ <key>line</key>
65
+ <integer>0</integer>
66
+ </dict>
67
+ </dict>
68
+ <key>gsolr.gemspec</key>
69
+ <dict>
70
+ <key>caret</key>
71
+ <dict>
72
+ <key>column</key>
73
+ <integer>26</integer>
74
+ <key>line</key>
75
+ <integer>17</integer>
76
+ </dict>
77
+ <key>columnSelection</key>
78
+ <false/>
79
+ <key>firstVisibleColumn</key>
80
+ <integer>0</integer>
81
+ <key>firstVisibleLine</key>
82
+ <integer>0</integer>
83
+ <key>selectFrom</key>
84
+ <dict>
85
+ <key>column</key>
86
+ <integer>3</integer>
87
+ <key>line</key>
88
+ <integer>17</integer>
89
+ </dict>
90
+ <key>selectTo</key>
91
+ <dict>
92
+ <key>column</key>
93
+ <integer>26</integer>
94
+ <key>line</key>
95
+ <integer>17</integer>
96
+ </dict>
97
+ </dict>
98
+ <key>lib/gsolr.rb</key>
99
+ <dict>
100
+ <key>caret</key>
101
+ <dict>
102
+ <key>column</key>
103
+ <integer>13</integer>
104
+ <key>line</key>
105
+ <integer>19</integer>
106
+ </dict>
107
+ <key>firstVisibleColumn</key>
108
+ <integer>0</integer>
109
+ <key>firstVisibleLine</key>
110
+ <integer>0</integer>
111
+ </dict>
112
+ <key>lib/gsolr/client.rb</key>
113
+ <dict>
114
+ <key>caret</key>
115
+ <dict>
116
+ <key>column</key>
117
+ <integer>28</integer>
118
+ <key>line</key>
119
+ <integer>6</integer>
120
+ </dict>
121
+ <key>firstVisibleColumn</key>
122
+ <integer>0</integer>
123
+ <key>firstVisibleLine</key>
124
+ <integer>0</integer>
125
+ </dict>
126
+ <key>lib/gsolr/connection.rb</key>
127
+ <dict>
128
+ <key>caret</key>
129
+ <dict>
130
+ <key>column</key>
131
+ <integer>0</integer>
132
+ <key>line</key>
133
+ <integer>13</integer>
134
+ </dict>
135
+ <key>firstVisibleColumn</key>
136
+ <integer>0</integer>
137
+ <key>firstVisibleLine</key>
138
+ <integer>0</integer>
139
+ </dict>
140
+ <key>lib/gsolr/connection/net_http.rb</key>
141
+ <dict>
142
+ <key>caret</key>
143
+ <dict>
144
+ <key>column</key>
145
+ <integer>16</integer>
146
+ <key>line</key>
147
+ <integer>32</integer>
148
+ </dict>
149
+ <key>firstVisibleColumn</key>
150
+ <integer>0</integer>
151
+ <key>firstVisibleLine</key>
152
+ <integer>13</integer>
153
+ </dict>
154
+ <key>lib/gsolr/connection/requestable.rb</key>
155
+ <dict>
156
+ <key>caret</key>
157
+ <dict>
158
+ <key>column</key>
159
+ <integer>0</integer>
160
+ <key>line</key>
161
+ <integer>18</integer>
162
+ </dict>
163
+ <key>columnSelection</key>
164
+ <false/>
165
+ <key>firstVisibleColumn</key>
166
+ <integer>0</integer>
167
+ <key>firstVisibleLine</key>
168
+ <integer>7</integer>
169
+ <key>selectFrom</key>
170
+ <dict>
171
+ <key>column</key>
172
+ <integer>9</integer>
173
+ <key>line</key>
174
+ <integer>44</integer>
175
+ </dict>
176
+ <key>selectTo</key>
177
+ <dict>
178
+ <key>column</key>
179
+ <integer>0</integer>
180
+ <key>line</key>
181
+ <integer>18</integer>
182
+ </dict>
183
+ </dict>
184
+ <key>lib/gsolr/connection/streamly.rb</key>
185
+ <dict>
186
+ <key>caret</key>
187
+ <dict>
188
+ <key>column</key>
189
+ <integer>17</integer>
190
+ <key>line</key>
191
+ <integer>46</integer>
192
+ </dict>
193
+ <key>firstVisibleColumn</key>
194
+ <integer>0</integer>
195
+ <key>firstVisibleLine</key>
196
+ <integer>11</integer>
197
+ </dict>
198
+ <key>lib/gsolr/connection/utils.rb</key>
199
+ <dict>
200
+ <key>caret</key>
201
+ <dict>
202
+ <key>column</key>
203
+ <integer>16</integer>
204
+ <key>line</key>
205
+ <integer>17</integer>
206
+ </dict>
207
+ <key>columnSelection</key>
208
+ <false/>
209
+ <key>firstVisibleColumn</key>
210
+ <integer>0</integer>
211
+ <key>firstVisibleLine</key>
212
+ <integer>0</integer>
213
+ <key>selectFrom</key>
214
+ <dict>
215
+ <key>column</key>
216
+ <integer>12</integer>
217
+ <key>line</key>
218
+ <integer>17</integer>
219
+ </dict>
220
+ <key>selectTo</key>
221
+ <dict>
222
+ <key>column</key>
223
+ <integer>16</integer>
224
+ <key>line</key>
225
+ <integer>17</integer>
226
+ </dict>
227
+ </dict>
228
+ <key>lib/gsolr/message.rb</key>
229
+ <dict>
230
+ <key>caret</key>
231
+ <dict>
232
+ <key>column</key>
233
+ <integer>3</integer>
234
+ <key>line</key>
235
+ <integer>7</integer>
236
+ </dict>
237
+ <key>firstVisibleColumn</key>
238
+ <integer>0</integer>
239
+ <key>firstVisibleLine</key>
240
+ <integer>0</integer>
241
+ </dict>
242
+ <key>lib/gsolr/message/document.rb</key>
243
+ <dict>
244
+ <key>caret</key>
245
+ <dict>
246
+ <key>column</key>
247
+ <integer>9</integer>
248
+ <key>line</key>
249
+ <integer>24</integer>
250
+ </dict>
251
+ <key>firstVisibleColumn</key>
252
+ <integer>0</integer>
253
+ <key>firstVisibleLine</key>
254
+ <integer>9</integer>
255
+ </dict>
256
+ <key>spec/api/connection/net_http_spec.rb</key>
257
+ <dict>
258
+ <key>caret</key>
259
+ <dict>
260
+ <key>column</key>
261
+ <integer>60</integer>
262
+ <key>line</key>
263
+ <integer>24</integer>
264
+ </dict>
265
+ <key>firstVisibleColumn</key>
266
+ <integer>0</integer>
267
+ <key>firstVisibleLine</key>
268
+ <integer>0</integer>
269
+ </dict>
270
+ <key>tasks/spec.rake</key>
271
+ <dict>
272
+ <key>caret</key>
273
+ <dict>
274
+ <key>column</key>
275
+ <integer>21</integer>
276
+ <key>line</key>
277
+ <integer>14</integer>
278
+ </dict>
279
+ <key>firstVisibleColumn</key>
280
+ <integer>0</integer>
281
+ <key>firstVisibleLine</key>
282
+ <integer>0</integer>
283
+ </dict>
284
+ </dict>
285
+ <key>openDocuments</key>
286
+ <array>
287
+ <string>lib/gsolr/client.rb</string>
288
+ <string>Gemfile</string>
289
+ <string>Rakefile</string>
290
+ <string>tasks/spec.rake</string>
291
+ <string>lib/gsolr/connection.rb</string>
292
+ <string>spec/api/connection/net_http_spec.rb</string>
293
+ <string>lib/gsolr.rb</string>
294
+ <string>gsolr.gemspec</string>
295
+ <string>lib/gsolr/connection/streamly.rb</string>
296
+ <string>lib/gsolr/connection/utils.rb</string>
297
+ <string>lib/gsolr/connection/net_http.rb</string>
298
+ <string>lib/gsolr/message.rb</string>
299
+ <string>lib/gsolr/message/document.rb</string>
300
+ <string>lib/gsolr/connection/requestable.rb</string>
301
+ </array>
302
+ <key>showFileHierarchyDrawer</key>
303
+ <true/>
304
+ <key>windowFrame</key>
305
+ <string>{{82, 229}, {944, 776}}</string>
306
+ </dict>
307
+ </plist>
data/lib/gsolr.rb CHANGED
@@ -2,6 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  require 'json'
5
+ require 'builder'
5
6
 
6
7
  module GSolr
7
8
  autoload :Message, 'gsolr/message'
@@ -10,7 +11,7 @@ module GSolr
10
11
 
11
12
  module Connectable
12
13
  def connect(opts={})
13
- Client.new Connection::NetHttp.new(opts)
14
+ Client.new Connection::Streamly.new(opts)
14
15
  end
15
16
  end
16
17
  extend Connectable
@@ -1,9 +1,13 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
1
4
  require 'uri'
2
5
 
3
6
  module GSolr
4
7
  module Connection
5
- autoload :NetHttp, 'gsolr/connection/net_http'
6
- autoload :Utils, 'gsolr/connection/utils'
7
- autoload :Requestable, 'gsolr/connection/requestable'
8
+ autoload :NetHttp, 'connection/net_http'
9
+ autoload :Streamly, 'connection/streamly'
10
+ autoload :Utils, 'connection/utils'
11
+ autoload :Requestable, 'connection/requestable'
8
12
  end
9
- end
13
+ end
@@ -27,9 +27,7 @@ module GSolr
27
27
 
28
28
  def create_http_context(net_http_response, url, path, params, data=nil, headers={})
29
29
  full_url = "#{@uri.scheme}://#{@uri.host}"
30
-
31
30
  full_url += ":#{@uri.port}" if @uri.port
32
-
33
31
  full_url += url
34
32
 
35
33
  return {
@@ -12,7 +12,8 @@ module GSolr
12
12
  def initialize(opts={})
13
13
  opts[:url] ||= 'http://127.0.0.1:8983/solr'
14
14
  @opts = opts
15
- @uri = URI.parse opts[:url]
15
+ @url = opts[:url]
16
+ @uri = URI.parse @url
16
17
  end
17
18
 
18
19
  # send a request to the connection
@@ -40,7 +41,6 @@ module GSolr
40
41
  end
41
42
 
42
43
  raise GSolr::RequestError.new("Solr Response: #{http_context[:message]}") unless http_context[:status_code] == 200
43
-
44
44
  return http_context
45
45
  end
46
46
  end # module Requestable
@@ -0,0 +1,79 @@
1
+ require 'streamly_ffi'
2
+
3
+ #
4
+ # Connection for standard HTTP Solr server
5
+ #
6
+ module GSolr
7
+ module Connection
8
+ class Streamly
9
+
10
+ include GSolr::Connection::Requestable
11
+
12
+ def connection
13
+ @connection ||= StreamlyFFI.connect
14
+ end
15
+
16
+ def escape(_string)
17
+ self.connection.escape(_string)
18
+ end
19
+
20
+ def get(path, params={})
21
+ url = self.build_url path, params
22
+ response = connection.get url
23
+ create_http_context response, url, path, params
24
+ end
25
+
26
+ def post(path, data, params={}, headers={})
27
+ url = self.build_url path, params
28
+ response = connection.post url, data, headers
29
+ create_http_context response, url, path, params, data, headers
30
+ end
31
+
32
+ # send a request to the connection
33
+ # request '/select', :q=>'*:*'
34
+ #
35
+ # request '/update', {:wt=>:xml}, '</commit>'
36
+ #
37
+ # force a post where the post body is the param query
38
+ # request '/update', "<optimize/>", :method=>:post
39
+ #
40
+ def request(path, params={}, *extra)
41
+ opts = extra[-1].kind_of?(Hash) ? extra.pop : {}
42
+ data = extra[0]
43
+ # force a POST, use the query string as the POST body
44
+ if opts[:method] == :post and data.to_s.empty?
45
+ http_context = self.post(path, hash_to_query(params), {}, {'Content-Type' => 'application/x-www-form-urlencoded'})
46
+ else
47
+ if data
48
+ # standard POST, using "data" as the POST body
49
+ http_context = self.post(path, data, params, {"Content-Type" => 'text/xml; charset=utf-8'})
50
+ else
51
+ # standard GET
52
+ http_context = self.get(path, params)
53
+ end
54
+ end
55
+ return http_context
56
+ end
57
+
58
+ def create_http_context(response, url, path, params, data=nil, headers={})
59
+ return {
60
+ :url => url,
61
+ :body => response,
62
+ :path => path,
63
+ :params => params,
64
+ :data => data,
65
+ :headers => headers
66
+ }
67
+ end
68
+
69
+ # accepts a path/string and optional hash of query params
70
+ def build_url(path, params={})
71
+ full_path = @uri.path + path
72
+ full_url = "#{@uri.scheme}://#{@uri.host}"
73
+ full_url += ":#{@uri.port}" if @uri.port
74
+ full_url += super(full_path, params, @uri.query)
75
+ end
76
+
77
+ end # class NetHttp
78
+ end # module Connection
79
+ end # module GSolr
@@ -6,8 +6,8 @@ module GSolr
6
6
  # Performs URI escaping so that you can construct proper
7
7
  # query strings faster. Use this rather than the cgi.rb
8
8
  # version since it's faster. (Stolen from Rack).
9
- def escape(s)
10
- s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
9
+ def escape(_string)
10
+ _string.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
11
11
  #'%'+$1.unpack('H2'*$1.size).join('%').upcase
12
12
  '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
13
13
  }.tr(' ', '+')
@@ -53,7 +53,7 @@ module GSolr
53
53
  # Example:
54
54
  # build_param(:id, 1) == "id=1"
55
55
  def build_param(k,v)
56
- "#{escape(k)}=#{escape(v)}"
56
+ "#{escape(k.to_s)}=#{escape(v.to_s)}"
57
57
  end
58
58
 
59
59
  #
@@ -69,7 +69,7 @@ module GSolr
69
69
  next if val.to_s.empty?
70
70
 
71
71
  if val.class == Array
72
- hash_to_query(v.map { |elem| [key, elem] })
72
+ hash_to_query(val.map { |elem| [key, elem] })
73
73
  else
74
74
  build_param key, val
75
75
  end
data/lib/gsolr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Gsolr
2
- VERSION = "0.12.2"
1
+ module GSolr
2
+ VERSION = "0.12.3"
3
3
  end
@@ -0,0 +1,139 @@
1
+ describe GSolr::Connection::Streamly do
2
+
3
+ # calls #let to set "net_http" as method accessor
4
+ module NetHttpHelper
5
+ def self.included base
6
+ base.let(:net_http){ GSolr::Connection::Streamly.new }
7
+ end
8
+ end
9
+
10
+ context '#request' do
11
+ include NetHttpHelper
12
+
13
+ it 'should forward simple, non-data calls to #get' do
14
+ net_http.should_receive(:get).
15
+ with('/select', :q=>'a').
16
+ and_return({:status_code=>200})
17
+ net_http.request('/select', :q=>'a')
18
+ end
19
+
20
+ it 'should forward :method=>:post calls to #post with a special header' do
21
+ net_http.should_receive(:post).
22
+ with('/select', 'q=a', {}, {"Content-Type"=>"application/x-www-form-urlencoded"}).
23
+ and_return({:status_code=>200})
24
+ net_http.request('/select', {:q=>'a'}, :method=>:post)
25
+ end
26
+
27
+ it 'should forward data calls to #post' do
28
+ net_http.should_receive(:post).
29
+ with("/update", "<optimize/>", {}, {"Content-Type"=>"text/xml; charset=utf-8"}).
30
+ and_return({:status_code=>200})
31
+ net_http.request('/update', {}, '<optimize/>')
32
+ end
33
+
34
+ end
35
+
36
+ =begin Streamly is a Singleton, atm
37
+ context 'connection' do
38
+ include NetHttpHelper
39
+ it 'will create an instance of Net::HTTP' do
40
+ net_http.send(:connection).should be_a(Net::HTTP)
41
+ end
42
+ end
43
+ =end
44
+ =begin Need to setup fakeweb
45
+ context 'get/post' do
46
+ include NetHttpHelper
47
+
48
+ it 'should make a GET request as expected' do
49
+ net_http_response = mock('net_http_response')
50
+
51
+ net_http_response.should_receive(:code).and_return(200)
52
+ net_http_response.should_receive(:body).and_return('The Response')
53
+ net_http_response.should_receive(:message).and_return('OK')
54
+ # c = net_http.send(:connection)
55
+ net_http.should_receive(:get).with('/solr/select?q=1').and_return(net_http_response)
56
+
57
+
58
+ context = net_http.send(:get, '/select', :q => 1)
59
+ context.should be_a(Hash)
60
+
61
+ keys = [:data, :body, :status_code, :path, :url, :headers, :params, :message]
62
+ context.keys.size.should == keys.size
63
+ context.keys.all?{|key| keys.include?(key) }.should == true
64
+
65
+ context[:data].should == nil
66
+ context[:body].should == 'The Response'
67
+ context[:status_code].should == 200
68
+ context[:path].should == '/select'
69
+ context[:url].should == 'http://127.0.0.1:8983/solr/select?q=1'
70
+ context[:headers].should == {}
71
+ context[:params].should == {:q=>1}
72
+ context[:message].should == 'OK'
73
+ end
74
+
75
+
76
+ it 'should make a POST request as expected' do
77
+ net_http_response = mock('net_http_response')
78
+ net_http_response.should_receive(:code).
79
+ and_return(200)
80
+ net_http_response.should_receive(:body).
81
+ and_return('The Response')
82
+ net_http_response.should_receive(:message).
83
+ and_return('OK')
84
+ c = net_http.send(:connection)
85
+ net_http.should_receive(:post).
86
+ with('/solr/update', '<rollback/>', {}).
87
+ and_return(net_http_response)
88
+ context = net_http.send(:post, '/update', '<rollback/>')
89
+ context.should be_a(Hash)
90
+
91
+ keys = [:data, :body, :status_code, :path, :url, :headers, :params, :message]
92
+ context.keys.size.should == keys.size
93
+ context.keys.all?{|key| keys.include?(key) }.should == true
94
+
95
+ context[:data].should == '<rollback/>'
96
+ context[:body].should == 'The Response'
97
+ context[:status_code].should == 200
98
+ context[:path].should == '/update'
99
+ context[:url].should == 'http://127.0.0.1:8983/solr/update'
100
+ context[:headers].should == {}
101
+ context[:params].should == {}
102
+ context[:message].should == 'OK'
103
+ end
104
+ end
105
+ =end
106
+ context 'build_url' do
107
+ include NetHttpHelper
108
+
109
+ it 'should incude the base path to solr' do
110
+ result = net_http.send(:build_url, '/select', :q=>'*:*', :check=>'{!}')
111
+ # this is a non-ordered hash work around,
112
+ # -- the order of the parameters in the resulting url will be different depending on the ruby distribution/platform
113
+ # yuk.
114
+ begin
115
+ result.should == 'http://127.0.0.1:8983/solr/select?check=%7B%21%7D&q=%2A%3A%2A'
116
+ rescue
117
+ result.should == 'http://127.0.0.1:8983/solr/select?q=%2A%3A%2A&check=%7B%21%7D'
118
+ end
119
+ end
120
+ end
121
+
122
+ context 'encode_utf8' do
123
+ include NetHttpHelper
124
+
125
+ it 'should encode response body as utf-8' do
126
+ string = 'testing'
127
+ if RUBY_VERSION =~ /1\.9/
128
+ string.encoding.should == Encoding::US_ASCII
129
+ encoded_string = net_http.send(:encode_utf8, string)
130
+ string.encoding.should == Encoding::UTF_8
131
+ else
132
+ encoded_string = net_http.send(:encode_utf8, string)
133
+ encoded_string.should == string
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+ end
@@ -48,9 +48,8 @@ describe GSolr::Connection::Utils do
48
48
  end
49
49
 
50
50
  context 'escape method' do
51
-
52
51
  include UtilsHelper
53
-
52
+
54
53
  it 'should escape properly' do
55
54
  utils.escape('+').should == '%2B'
56
55
  utils.escape('This is a test').should == 'This+is+a+test'
@@ -7,7 +7,7 @@ describe GSolr do
7
7
  end
8
8
 
9
9
  it 'should create an instance of GSolr::Connection::NetHttp as the #connection' do
10
- expected_class = GSolr::Connection::NetHttp
10
+ expected_class = GSolr::Connection::Streamly
11
11
  GSolr.connect.connection.should be_a(expected_class)
12
12
  GSolr.connect(:url=>'blah').connection.should be_a(expected_class)
13
13
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 12
8
- - 2
9
- version: 0.12.2
8
+ - 3
9
+ version: 0.12.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Gonyea
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-07 01:00:00 -07:00
17
+ date: 2010-11-13 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -22,18 +22,16 @@ dependencies:
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
- - - ~>
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
- - 1
29
- - 4
30
- - 6
31
- version: 1.4.6
28
+ - 0
29
+ version: "0"
32
30
  type: :runtime
33
31
  prerelease: false
34
32
  version_requirements: *id001
35
33
  - !ruby/object:Gem::Dependency
36
- name: rspec
34
+ name: streamly_ffi
37
35
  requirement: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
@@ -42,9 +40,22 @@ dependencies:
42
40
  segments:
43
41
  - 0
44
42
  version: "0"
45
- type: :development
43
+ type: :runtime
46
44
  prerelease: false
47
45
  version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id003
48
59
  description: This is a generic solr client, capable of talking to Solr, as well as Riak
49
60
  email:
50
61
  - me@sgonyea.com
@@ -61,12 +72,15 @@ files:
61
72
  - LICENSE
62
73
  - README.md
63
74
  - Rakefile
75
+ - bench.rb
64
76
  - gsolr.gemspec
77
+ - gsolr.tmproj
65
78
  - lib/gsolr.rb
66
79
  - lib/gsolr/client.rb
67
80
  - lib/gsolr/connection.rb
68
81
  - lib/gsolr/connection/net_http.rb
69
82
  - lib/gsolr/connection/requestable.rb
83
+ - lib/gsolr/connection/streamly.rb
70
84
  - lib/gsolr/connection/utils.rb
71
85
  - lib/gsolr/message.rb
72
86
  - lib/gsolr/message/document.rb
@@ -76,13 +90,14 @@ files:
76
90
  - spec/api/client_spec.rb
77
91
  - spec/api/connection/net_http_spec.rb
78
92
  - spec/api/connection/requestable_spec.rb
93
+ - spec/api/connection/streamly_spec.rb
79
94
  - spec/api/connection/utils_spec.rb
80
95
  - spec/api/gsolr_spec.rb
81
96
  - spec/api/message_spec.rb
82
97
  - spec/spec_helper.rb
83
98
  - tasks/spec.rake
84
99
  has_rdoc: true
85
- homepage: http://rubygems.org/gems/gsolr
100
+ homepage: https://github.com/aitrus/gsolr
86
101
  licenses: []
87
102
 
88
103
  post_install_message:
@@ -108,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
123
  version: "0"
109
124
  requirements: []
110
125
 
111
- rubyforge_project: gsolr
126
+ rubyforge_project:
112
127
  rubygems_version: 1.3.7
113
128
  signing_key:
114
129
  specification_version: 3
@@ -117,6 +132,7 @@ test_files:
117
132
  - spec/api/client_spec.rb
118
133
  - spec/api/connection/net_http_spec.rb
119
134
  - spec/api/connection/requestable_spec.rb
135
+ - spec/api/connection/streamly_spec.rb
120
136
  - spec/api/connection/utils_spec.rb
121
137
  - spec/api/gsolr_spec.rb
122
138
  - spec/api/message_spec.rb