rsolr-ext 0.12.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rsolr-ext/client.rb +8 -8
- data/spec/rsolr-ext_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -1
- metadata +25 -12
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/mwmitchell/rsolr-ext"
|
12
12
|
gem.authors = ["Matt Mitchell"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "rsolr", ">= 0.
|
14
|
+
gem.add_dependency "rsolr", ">= 1.0.0"
|
15
15
|
|
16
16
|
gem.files = FileList['lib/**/*.rb', 'LICENSE', 'README.rdoc', 'VERSION']
|
17
17
|
gem.test_files = ['spec/*', 'Rakefile']
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/rsolr-ext/client.rb
CHANGED
@@ -6,18 +6,18 @@ module RSolr::Ext::Client
|
|
6
6
|
# OR
|
7
7
|
# <solr-params-hash>
|
8
8
|
#
|
9
|
-
# The default request-handler-path is
|
9
|
+
# The default request-handler-path is select
|
10
10
|
#
|
11
11
|
# If a hash is used for solr params, all of the normal RSolr::Ext::Request
|
12
12
|
# mappings are available (everything else gets passed to solr).
|
13
13
|
# Returns a new RSolr::Ext::Response::Base object.
|
14
14
|
def find *args
|
15
15
|
# remove the handler arg - the first, if it is a string OR set default
|
16
|
-
path = args.first.is_a?(String) ? args.shift : '
|
16
|
+
path = args.first.is_a?(String) ? args.shift : 'select'
|
17
17
|
# remove the params - the first, if it is a Hash OR set default
|
18
18
|
params = args.first.kind_of?(Hash) ? args.shift : {}
|
19
19
|
# send path, map params and send the rest of the args along
|
20
|
-
response = self.
|
20
|
+
response = self.send_and_receive path, { :params => RSolr::Ext::Request.map(params) }
|
21
21
|
RSolr::Ext::Response::Base.new(response, path, params)
|
22
22
|
end
|
23
23
|
|
@@ -32,17 +32,17 @@ module RSolr::Ext::Client
|
|
32
32
|
#
|
33
33
|
# Returns a new Mash object.
|
34
34
|
def luke *args
|
35
|
-
path = args.first.is_a?(String) ? args.shift : '
|
35
|
+
path = args.first.is_a?(String) ? args.shift : 'admin/luke'
|
36
36
|
params = args.pop || {}
|
37
37
|
params['numTerms'] ||= 0
|
38
|
-
self.
|
38
|
+
self.get(path, params).to_mash
|
39
39
|
end
|
40
40
|
|
41
41
|
# sends request to /admin/ping
|
42
42
|
def ping *args
|
43
|
-
path = args.first.is_a?(String) ? args.shift : '
|
44
|
-
params = args.pop || {}
|
45
|
-
self.
|
43
|
+
path = args.first.is_a?(String) ? args.shift : 'admin/ping'
|
44
|
+
params = args.pop || {:wt => :ruby}
|
45
|
+
self.get(path, params).to_mash
|
46
46
|
end
|
47
47
|
|
48
48
|
# Ping the server and make sure it is alright
|
data/spec/rsolr-ext_spec.rb
CHANGED
@@ -12,8 +12,8 @@ describe RSolr::Ext do
|
|
12
12
|
|
13
13
|
it 'should produce results from the #find method' do
|
14
14
|
c = client
|
15
|
-
c.should_receive(:
|
16
|
-
with('
|
15
|
+
c.should_receive(:send_and_receive).
|
16
|
+
with('select', {:params => {:rows=>10, :start=>20, :q=>"*:*"}}).
|
17
17
|
and_return({'response'=>{'docs' => []}, 'responseHeader' => {}})
|
18
18
|
response = c.find :page=>3, :per_page=>10, :q=>'*:*'#, :page=>1, :per_page=>10
|
19
19
|
response.should be_a(Mash)
|
@@ -24,19 +24,19 @@ describe RSolr::Ext do
|
|
24
24
|
expected_response = {'response'=>{'docs' => []}, 'responseHeader' => {}}
|
25
25
|
# ok this is hacky... the raw method needs to go into a mixin dude
|
26
26
|
def expected_response.raw
|
27
|
-
{:path => '
|
27
|
+
{:path => 'select'}
|
28
28
|
end
|
29
|
-
c.should_receive(:
|
30
|
-
with('
|
29
|
+
c.should_receive(:send_and_receive).
|
30
|
+
with('select', {:params => {:q=>'*:*'}}).
|
31
31
|
and_return(expected_response)
|
32
|
-
response = c.find '
|
33
|
-
response.raw[:path].should match(
|
32
|
+
response = c.find 'select', :q=>'*:*'
|
33
|
+
response.raw[:path].should match(/select/)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should be ok' do
|
37
37
|
c = client
|
38
|
-
c.should_receive(:
|
39
|
-
with('
|
38
|
+
c.should_receive(:send_and_receive).
|
39
|
+
with('select', {:params => {:q=>'*:*'}}).
|
40
40
|
and_return({'response'=>{'docs' => []}, 'responseHeader' => {'status'=>0}})
|
41
41
|
response = c.find :q=>'*:*'
|
42
42
|
response.should respond_to(:ok?)
|
@@ -45,8 +45,8 @@ describe RSolr::Ext do
|
|
45
45
|
|
46
46
|
it 'should call the #luke method' do
|
47
47
|
c = client
|
48
|
-
c.should_receive(:
|
49
|
-
with('
|
48
|
+
c.should_receive(:get).
|
49
|
+
with('admin/luke', {"numTerms"=>0}).
|
50
50
|
and_return({"fields"=>nil, "index"=>nil, "info" => nil})
|
51
51
|
info = c.luke
|
52
52
|
info.should be_a(Mash)
|
@@ -55,9 +55,9 @@ describe RSolr::Ext do
|
|
55
55
|
info.should have_key('info')
|
56
56
|
end
|
57
57
|
|
58
|
-
it 'should
|
59
|
-
client.
|
60
|
-
with('
|
58
|
+
it 'should forward #ping? calls to the connection' do
|
59
|
+
client.should_receive(:get).
|
60
|
+
with('admin/ping', :wt => :ruby ).
|
61
61
|
and_return( :params => { :wt => :ruby },
|
62
62
|
:status_code => 200,
|
63
63
|
:body => "{'responseHeader'=>{'status'=>0,'QTime'=>44,'params'=>{'echoParams'=>'all','echoParams'=>'all','q'=>'solrpingquery','qt'=>'standard','wt'=>'ruby'}},'status'=>'OK'}" )
|
@@ -65,11 +65,11 @@ describe RSolr::Ext do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should raise an error if the ping service is not available' do
|
68
|
-
client.
|
69
|
-
with('
|
68
|
+
client.should_receive(:get).
|
69
|
+
with('admin/ping', :wt => :ruby ).
|
70
70
|
# the first part of the what the message would really be
|
71
|
-
and_raise(
|
72
|
-
lambda { client.ping? }.should raise_error(
|
71
|
+
and_raise( RuntimeError.new("Solr Response: pingQuery_not_configured_consider_registering_PingRequestHandler_with_the_name_adminping_instead__") )
|
72
|
+
lambda { client.ping? }.should raise_error( RuntimeError )
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
@@ -137,7 +137,7 @@ describe RSolr::Ext do
|
|
137
137
|
|
138
138
|
def create_response
|
139
139
|
raw_response = eval(mock_query_response)
|
140
|
-
RSolr::Ext::Response::Base.new(raw_response, '
|
140
|
+
RSolr::Ext::Response::Base.new(raw_response, 'select', raw_response['params'])
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should create a valid response' do
|
@@ -199,7 +199,7 @@ describe RSolr::Ext do
|
|
199
199
|
item.value + ' - ' + item.hits.to_s
|
200
200
|
end.join(', ')
|
201
201
|
|
202
|
-
|
202
|
+
received.should == expected
|
203
203
|
|
204
204
|
r.facets.each do |facet|
|
205
205
|
facet.respond_to?(:name).should == true
|
data/spec/spec_helper.rb
CHANGED
@@ -7,7 +7,7 @@ require 'spec/autorun'
|
|
7
7
|
Spec::Runner.configure do |config|
|
8
8
|
|
9
9
|
def mock_query_response
|
10
|
-
%({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'facet.limit'=>'10','wt'=>'ruby','rows'=>'11','facet'=>'true','facet.field'=>['
|
10
|
+
%({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'facet.limit'=>'10','wt'=>'ruby','rows'=>'11','facet'=>'true','facet.field'=>['cat','manu'],'echoParams'=>'EXPLICIT','q'=>'*:*','facet.sort'=>'true'}},'response'=>{'numFound'=>26,'start'=>0,'docs'=>[{'id'=>'SP2514N','inStock'=>true,'manu'=>'Samsung Electronics Co. Ltd.','name'=>'Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133','popularity'=>6,'price'=>92.0,'sku'=>'SP2514N','timestamp'=>'2009-03-20T14:42:49.795Z','cat'=>['electronics','hard drive'],'spell'=>['Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133'],'features'=>['7200RPM, 8MB cache, IDE Ultra ATA-133','NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor']},{'id'=>'6H500F0','inStock'=>true,'manu'=>'Maxtor Corp.','name'=>'Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300','popularity'=>6,'price'=>350.0,'sku'=>'6H500F0','timestamp'=>'2009-03-20T14:42:49.877Z','cat'=>['electronics','hard drive'],'spell'=>['Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300'],'features'=>['SATA 3.0Gb/s, NCQ','8.5ms seek','16MB cache']},{'id'=>'F8V7067-APL-KIT','inStock'=>false,'manu'=>'Belkin','name'=>'Belkin Mobile Power Cord for iPod w/ Dock','popularity'=>1,'price'=>19.95,'sku'=>'F8V7067-APL-KIT','timestamp'=>'2009-03-20T14:42:49.937Z','weight'=>4.0,'cat'=>['electronics','connector'],'spell'=>['Belkin Mobile Power Cord for iPod w/ Dock'],'features'=>['car power adapter, white']},{'id'=>'IW-02','inStock'=>false,'manu'=>'Belkin','name'=>'iPod & iPod Mini USB 2.0 Cable','popularity'=>1,'price'=>11.5,'sku'=>'IW-02','timestamp'=>'2009-03-20T14:42:49.944Z','weight'=>2.0,'cat'=>['electronics','connector'],'spell'=>['iPod & iPod Mini USB 2.0 Cable'],'features'=>['car power adapter for iPod, white']},{'id'=>'MA147LL/A','inStock'=>true,'includes'=>'earbud headphones, USB cable','manu'=>'Apple Computer Inc.','name'=>'Apple 60 GB iPod with Video Playback Black','popularity'=>10,'price'=>399.0,'sku'=>'MA147LL/A','timestamp'=>'2009-03-20T14:42:49.962Z','weight'=>5.5,'cat'=>['electronics','music'],'spell'=>['Apple 60 GB iPod with Video Playback Black'],'features'=>['iTunes, Podcasts, Audiobooks','Stores up to 15,000 songs, 25,000 photos, or 150 hours of video','2.5-inch, 320x240 color TFT LCD display with LED backlight','Up to 20 hours of battery life','Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video','Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication']},{'id'=>'TWINX2048-3200PRO','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail','popularity'=>5,'price'=>185.0,'sku'=>'TWINX2048-3200PRO','timestamp'=>'2009-03-20T14:42:49.99Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail'],'features'=>['CAS latency 2, 2-3-3-6 timing, 2.75v, unbuffered, heat-spreader']},{'id'=>'VS1GB400C3','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail','popularity'=>7,'price'=>74.99,'sku'=>'VS1GB400C3','timestamp'=>'2009-03-20T14:42:50Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail']},{'id'=>'VDBDB1A16','inStock'=>true,'manu'=>'A-DATA Technology Inc.','name'=>'A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM','popularity'=>5,'sku'=>'VDBDB1A16','timestamp'=>'2009-03-20T14:42:50.004Z','cat'=>['electronics','memory'],'spell'=>['A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM'],'features'=>['CAS latency 3, 2.7v']},{'id'=>'3007WFP','inStock'=>true,'includes'=>'USB cable','manu'=>'Dell, Inc.','name'=>'Dell Widescreen UltraSharp 3007WFP','popularity'=>6,'price'=>2199.0,'sku'=>'3007WFP','timestamp'=>'2009-03-20T14:42:50.017Z','weight'=>401.6,'cat'=>['electronics','monitor'],'spell'=>['Dell Widescreen UltraSharp 3007WFP'],'features'=>['30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast']},{'id'=>'VA902B','inStock'=>true,'manu'=>'ViewSonic Corp.','name'=>'ViewSonic VA902B - flat panel display - TFT - 19"','popularity'=>6,'price'=>279.95,'sku'=>'VA902B','timestamp'=>'2009-03-20T14:42:50.034Z','weight'=>190.4,'cat'=>['electronics','monitor'],'spell'=>['ViewSonic VA902B - flat panel display - TFT - 19"'],'features'=>['19" TFT active matrix LCD, 8ms response time, 1280 x 1024 native resolution']},{'id'=>'0579B002','inStock'=>true,'manu'=>'Canon Inc.','name'=>'Canon PIXMA MP500 All-In-One Photo Printer','popularity'=>6,'price'=>179.99,'sku'=>'0579B002','timestamp'=>'2009-03-20T14:42:50.062Z','weight'=>352.0,'cat'=>['electronics','multifunction printer','printer','scanner','copier'],'spell'=>['Canon PIXMA MP500 All-In-One Photo Printer'],'features'=>['Multifunction ink-jet color photo printer','Flatbed scanner, optical scan resolution of 1,200 x 2,400 dpi','2.5" color LCD preview screen','Duplex Copying','Printing speed up to 29ppm black, 19ppm color','Hi-Speed USB','memory card: CompactFlash, Micro Drive, SmartMedia, Memory Stick, Memory Stick Pro, SD Card, and MultiMediaCard']}]},'facet_counts'=>{'facet_queries'=>{},'facet_fields'=>{'cat'=>['electronics',14,'memory',3,'card',2,'connector',2,'drive',2,'graphics',2,'hard',2,'monitor',2,'search',2,'software',2],'manu'=>['inc',8,'apach',2,'belkin',2,'canon',2,'comput',2,'corp',2,'corsair',2,'foundat',2,'microsystem',2,'softwar',2]},'facet_dates'=>{}}})
|
11
11
|
end
|
12
12
|
|
13
13
|
# These spellcheck responses are all Solr 1.4 responses
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsolr-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
|
-
- 0
|
7
|
-
- 12
|
8
7
|
- 1
|
9
|
-
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Matt Mitchell
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-03-01 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -35,14 +38,16 @@ dependencies:
|
|
35
38
|
name: rsolr
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
41
46
|
segments:
|
42
|
-
- 0
|
43
|
-
- 12
|
44
47
|
- 1
|
45
|
-
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 1.0.0
|
46
51
|
type: :runtime
|
47
52
|
version_requirements: *id002
|
48
53
|
description: A query/response extension lib for RSolr
|
@@ -68,38 +73,46 @@ files:
|
|
68
73
|
- lib/rsolr-ext/response/docs.rb
|
69
74
|
- lib/rsolr-ext/response/facets.rb
|
70
75
|
- lib/rsolr-ext/response/spelling.rb
|
76
|
+
- Rakefile
|
77
|
+
- spec/rsolr-ext_spec.rb
|
78
|
+
- spec/spec.opts
|
79
|
+
- spec/spec_helper.rb
|
71
80
|
has_rdoc: true
|
72
81
|
homepage: http://github.com/mwmitchell/rsolr-ext
|
73
82
|
licenses: []
|
74
83
|
|
75
84
|
post_install_message:
|
76
|
-
rdoc_options:
|
77
|
-
|
85
|
+
rdoc_options: []
|
86
|
+
|
78
87
|
require_paths:
|
79
88
|
- lib
|
80
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
81
91
|
requirements:
|
82
92
|
- - ">="
|
83
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
84
95
|
segments:
|
85
96
|
- 0
|
86
97
|
version: "0"
|
87
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
88
100
|
requirements:
|
89
101
|
- - ">="
|
90
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
91
104
|
segments:
|
92
105
|
- 0
|
93
106
|
version: "0"
|
94
107
|
requirements: []
|
95
108
|
|
96
109
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.
|
110
|
+
rubygems_version: 1.5.0
|
98
111
|
signing_key:
|
99
112
|
specification_version: 3
|
100
113
|
summary: A query/response extension lib for RSolr
|
101
114
|
test_files:
|
115
|
+
- Rakefile
|
102
116
|
- spec/rsolr-ext_spec.rb
|
103
117
|
- spec/spec.opts
|
104
118
|
- spec/spec_helper.rb
|
105
|
-
- Rakefile
|