public
Description: Ambition adapter for Sphinx
Clone URL: git://github.com/technicalpickles/ambitious-sphinx.git
More RDoc.
Josh Nichols (author)
Tue Feb 12 18:51:42 -0800 2008
commit  328450f1c86540bfa393c1f38e020635e0b0b914
tree    1cbfe38b5d823e88d2d72b56d331324046f9ab5d
parent  91c7a4bef34132a12442d413059a0fc1458fd942
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ module Ambition
0
             query_s = query.join(' ').squeeze(' ').strip
0
             hash[:query] = quotify(query_s)
0
           end
0
-
0
+
0
           hash
0
         end
0
 
...
2
3
4
5
 
6
7
8
...
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
 
37
38
39
...
50
51
52
53
54
 
 
 
 
 
 
 
 
55
56
57
58
59
60
61
62
 
 
 
 
 
 
 
 
63
64
65
66
67
68
69
70
 
 
71
72
73
74
 
 
75
76
77
78
 
 
79
80
81
82
 
 
83
84
85
86
87
88
 
 
89
90
91
...
2
3
4
 
5
6
7
8
...
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
...
45
46
47
 
 
48
49
50
51
52
53
54
55
56
57
58
59
60
 
 
 
61
62
63
64
65
66
67
68
69
70
71
72
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
0
@@ -2,7 +2,7 @@ module Ambition
0
   module Adapters
0
     module AmbitiousSphinx
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
+ # 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
@@ -10,30 +10,25 @@ module Ambition
0
           "#{method.to_s}:"
0
         end
0
 
0
- # chained calls not supported
0
+ # Should we be supporting chained calls like:
0
+ #
0
+ # u.name.downcase
0
+ #
0
+ # ?
0
+ #
0
+ # I don't think Sphinx would be able to handle this.
0
         def chained_call(*methods)
0
- # An idiom here is to call the chained method and pass it
0
- # the first method.
0
- #
0
- # if respond_to? methods[1]
0
- # send(methods[1], methods[0])
0
- # end
0
- #
0
- # In the above example, this translates to calling:
0
- #
0
- # #downcase(:name)
0
- #
0
           raise "Not implemented yet."
0
         end
0
 
0
- # Handles generating an UltraSphinx query for code like:
0
+ # Handles generating an Ultrasphinx query for code like:
0
         #
0
         # 'foo' && 'bar'
0
         def both(left, right)
0
           "#{quotify left} AND #{quotify right}"
0
         end
0
 
0
- # Handles generating an UltraSphinx query for code like:
0
+ # Handles generating an Ultrasphinx query for code like:
0
         #
0
         # 'foo' || 'bar'
0
         def either(left, right)
0
@@ -50,42 +45,59 @@ module Ambition
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
- # >> select { |u| u.name =~ 'chris' }
0
- # => #=~( call(:name), 'chris' )
0
+ # Handles generating an Ultrasphinx query for code like:
0
+ #
0
+ # u.name =~ 'bob'
0
+ #
0
+ # Some cavaets:
0
+ # * left hand side _must_ be a field, like u.name
0
+ # * right hand side _must not_ be a regular expression. Pattern matching is generally not
0
+ # supported by full text search engines
0
         def =~(left, right)
0
           raise if right.is_a? Regexp
0
           "#{left}#{quotify right}"
0
         end
0
 
0
- # !~
0
- # >> select { |u| u.name !~ 'chris' }
0
- # => #not_regexp( call(:name), 'chris' )
0
+ # Handles generating an Ultrasphinx query for code like:
0
+ #
0
+ # u.name !~ 'bob'
0
+ #
0
+ # Some cavaets:
0
+ # * left hand side _must_ be a field, like u.name
0
+ # * right hand side _must not_ be a regular expression. Pattern matching is generally not
0
+ # supported by full text search engines
0
         def not_regexp(left, right)
0
           # could be DRYer, but this is more readable than: "NOT #{self.=~(left,right)}"
0
           raise if right.is_a? Regexp
0
           "NOT #{left}#{quotify right}"
0
         end
0
 
0
- ##
0
- # Etc.
0
+ # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
+ # using ambitious-activerecord.
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
         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
         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
         def <=(left, right)
0
           raise "Not applicable to sphinx."
0
         end
0
 
0
- # >> select { |u| [1, 2, 3].include? u.id }
0
- # => #include?( [1, 2, 3], call(:id) )
0
+ # Not supported by Sphinx. If you need this kind of comparison, you probably should be
0
+ # using ambitious-activerecord.
0
         def include?(left, right)
0
           raise "Not applicable to sphinx."
0
         end

Comments

    No one has commented yet.