public
Description: Ambition adapter for Sphinx
Clone URL: git://github.com/technicalpickles/ambitious-sphinx.git
More rdoc. Added test to verify slice isn't supported.
Mon Feb 18 13:41:30 -0800 2008
commit  d474ea39535766bd6fc1c383145ba7808dd7a713
tree    c4f5655529ded488405725b24597d759f5165f9e
parent  5daac3847bdd94de713dad1adf5db111b4d79417
...
1
2
3
 
4
5
6
...
13
14
15
16
 
 
17
18
19
...
1
2
 
3
4
5
6
...
13
14
15
 
16
17
18
19
20
0
@@ -1,6 +1,6 @@
0
 module Ambition #:nodoc:
0
   module Adapters #:nodoc:
0
- module AmbitiousSphinx
0
+ module AmbitiousSphinx #:nodoc:
0
       # Responsible for taking the clauses that Ambition has generated, and ultimately doing a
0
       # Ultrasphinx::Search based on them
0
       class Query < Base
0
@@ -13,7 +13,8 @@ module Ambition #:nodoc:
0
           raise "Not implemented yet."
0
         end
0
 
0
- # Builds a hash of options for Ultrasphinx::Search based on the clauses Ambition has generated.
0
+ # Builds a hash of options for Ultrasphinx::Search based on the clauses Ambition
0
+ # has generated.
0
         def to_hash
0
           hash = {}
0
 
...
4
5
6
7
8
 
 
 
 
9
10
11
...
73
74
75
76
 
77
78
79
80
81
82
 
83
84
85
86
87
88
 
89
90
91
92
93
94
 
95
96
97
98
99
100
 
101
102
103
...
4
5
6
 
 
7
8
9
10
11
12
13
...
75
76
77
 
78
79
80
81
82
83
 
84
85
86
87
88
89
 
90
91
92
93
94
95
 
96
97
98
99
100
101
 
102
103
104
105
0
@@ -4,8 +4,10 @@ module Ambition #:nodoc:
0
       # Select is responsible for taking pure Ruby, and mangling it until it resembles
0
       # the syntax that Ultrasphinx[http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/files/README.html] uses.
0
       class Select < Base
0
- # method calls
0
- # converts
0
+
0
+ # Handles method calls, like
0
+ #
0
+ # u.name
0
         def call(method)
0
           "#{method.to_s}:"
0
         end
0
@@ -73,31 +75,31 @@ module Ambition #:nodoc:
0
         end
0
 
0
         # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
- # using ambitious-activerecord.
0
+ # using ambitious-activerecord instead.
0
         def <(left, right)
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
         # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
- # using ambitious-activerecord.
0
+ # using ambitious-activerecord instead.
0
         def >(left, right)
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
         # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
- # using ambitious-activerecord.
0
+ # using ambitious-activerecord instead.
0
         def >=(left, right)
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
         # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
- # using ambitious-activerecord.
0
+ # using ambitious-activerecord instead.
0
         def <=(left, right)
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
         # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
- # using ambitious-activerecord.
0
+ # using ambitious-activerecord instead.
0
         def include?(left, right)
0
           raise "Not applicable to sphinx."
0
         end
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
10
11
12
 
 
13
14
 
15
16
17
...
1
2
 
3
4
5
6
7
8
 
 
 
 
 
 
 
 
9
10
11
 
12
13
14
15
0
@@ -1,17 +1,15 @@
0
 module Ambition #:nodoc:
0
   module Adapters #:nodoc:
0
- module AmbitiousSphinx
0
+ module AmbitiousSphinx #:nodoc:
0
+ # Slicing would normally let you choose a 'slice' of the search results.
0
+ #
0
+ # We don't support it at this time because of limitations of Ultrasphinx.
0
+ # It allows you to select what 'page' of results to select, but not a specific range.
0
       class Slice < Base
0
- # >> User.first(5)
0
- # => #slice(0, 5)
0
- #
0
- # >> User.first
0
- # => #slice(0, 1)
0
- #
0
- # >> User[10, 20]
0
- # => #slice(10, 20)
0
+
0
+ # Not implemented.
0
         def slice(start, length)
0
- raise "Not implemented."
0
+ raise "Not supported by Ultrasphinx"
0
         end
0
       end
0
     end
...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
 
35
36
...
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
 
 
9
10
11
12
0
@@ -5,32 +5,8 @@ context "AmbitiousSphinx Adapter :: Slice" do
0
     @klass = User
0
     @block = @klass.select { |m| m.name =~ 'jon' }
0
   end
0
-
0
- xspecify "first" do
0
- @klass.expects(:find).with(:limit => 1, :name => 'jon')
0
- @block.first
0
- end
0
-
0
- xspecify "first with argument" do
0
- @klass.expects(:find).with(:limit => 5, :name => 'jon')
0
- @block.first(5).entries
0
- end
0
-
0
- xspecify "[] with two elements" do
0
- @klass.expects(:find).with(:limit => 20, :offset => 10, :name => 'jon')
0
- @block[10, 20].entries
0
-
0
- @klass.expects(:find).with(:limit => 20, :offset => 20, :name => 'jon')
0
- @block[20, 20].entries
0
- end
0
-
0
- xspecify "slice is an alias of []" do
0
- @klass.expects(:find).with(:limit => 20, :offset => 10, :name => 'jon')
0
- @block.slice(10, 20).entries
0
- end
0
   
0
- xspecify "[] with range" do
0
- @klass.expects(:find).with(:limit => 10, :offset => 10, :name => 'jon')
0
- @block[11..20].entries
0
+ specify "not supported" do
0
+ should.raise {@block.first}
0
   end
0
 end

Comments

    No one has commented yet.