public
Description: Ambition adapter for Sphinx
Clone URL: git://github.com/technicalpickles/ambitious-sphinx.git
Search Repo:
More rdoc improvements
Fri Feb 29 16:19:36 -0800 2008
commit  753416af4550d0bc834f7891526e128d16c116d6
tree    04f695b5f7a0f280f6006af27dc68f599e0de575
parent  c1588c2424dbf9b47f16ef40bde58d34ce0ac6a6
...
1
2
3
 
4
5
6
7
...
12
13
14
15
16
 
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
 
1
2
3
4
5
6
7
...
12
13
14
 
 
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
19
20
0
@@ -1,6 +1,6 @@
0
-
0
 require 'ambition'
0
 
0
+# stub out rails stuff enough so that ultrasphinx will be happy
0
 RAILS_ROOT = "./" unless defined? RAILS_ROOT
0
 RAILS_ENV = "development" unless defined? RAILS_ENV
0
 
0
0
@@ -12,21 +12,10 @@
0
   end
0
 end
0
 
0
-%w(base page query select sort slice).each do |base|
0
- require "ambition/adapters/ambitious_sphinx/#{base}"
0
+%w(base page query select sort slice).each do |f|
0
+ require "ambition/adapters/ambitious_sphinx/#{f}"
0
 end
0
 
0
-##
0
-# This is where you inject Ambition into your target.
0
-#
0
-# Use `extend' if you are injecting a class, `include' if you are
0
-# injecting instances of that class.
0
-#
0
-# You must also set the `ambition_adapter' class variable on your target
0
-# class, regardless of whether you are injecting instances or the class itself.
0
-#
0
-# You probably want something like this:
0
-#
0
 ActiveRecord::Base.extend Ambition::API
0
 ActiveRecord::Base.ambition_adapter = Ambition::Adapters::AmbitiousSphinx
...
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
16
17
18
19
20
21
22
23
0
@@ -1,17 +1,23 @@
0
 module Ambition::Adapters::AmbitiousSphinx
0
+ # Helper for the other
0
   class Base
0
+ # Does the string have an Ultrasphinx field?
0
     def has_field? str
0
       str =~ /:/
0
     end
0
     
0
+ # Does the string have any Ultrasphinx operators?
0
     def has_operator? str
0
       str =~ /(AND|OR|NOT)/
0
     end
0
     
0
+ # Should this string be quotified? It needs to happen if the string doesn't
0
+ # have an operator or a field.
0
     def needs_quoting? str
0
       not (has_operator?(str) or has_field?(str))
0
     end
0
     
0
+ # Quote the string if it needs it.
0
     def quotify str
0
       if needs_quoting?(str)
0
         %Q("#{str}")
...
6
7
8
9
 
10
11
12
...
18
19
20
21
 
22
23
24
...
6
7
8
 
9
10
11
12
...
18
19
20
 
21
22
23
24
0
@@ -6,7 +6,7 @@
0
       Ultrasphinx::Search.new(to_hash).results
0
     end
0
 
0
- # Some magic to add pagination. this gets called if you were to do:
0
+ # Some magic to add pagination. This gets called if you were to do:
0
     #
0
     # Meal.select {'bacon'}.page(5)
0
     #
0
@@ -18,7 +18,7 @@
0
       context
0
     end
0
 
0
- # Not entirely sure what this is for, so unimplemented so far.
0
+ # Not entirely sure when this is used, so unimplemented so far.
0
     def size
0
       raise "Not implemented yet."
0
     end
...
1
 
2
3
4
5
6
7
8
9
10
 
11
12
13
...
1
2
3
 
 
 
 
 
 
 
 
4
5
6
7
0
@@ -1,13 +1,7 @@
0
 module Ambition::Adapters::AmbitiousSphinx
0
+ # Slice would normally handle slicing, but we don't support it yet.
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
+ # Not implemented
0
     def slice(start, length)
0
       raise "Not implemented."
0
     end
...
1
 
2
3
4
 
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
37
...
1
2
3
 
 
4
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
0
@@ -1,37 +1,32 @@
0
 module Ambition::Adapters::AmbitiousSphinx
0
+ # +Sort+ would normally handle sorting, but we don't support it yet.
0
   class Sort < Base
0
- # >> sort_by { |u| u.age }
0
- # => #sort_by(:age)
0
+ # Not implemented
0
     def sort_by(method)
0
       raise "Not implemented."
0
     end
0
 
0
- # >> sort_by { |u| -u.age }
0
- # => #reverse_sort_by(:age)
0
+ # Not implemented
0
     def reverse_sort_by(method)
0
       raise "Not implemented."
0
     end
0
 
0
- # >> sort_by { |u| u.profile.name }
0
- # => #chained_sort_by(:profile, :name)
0
+ # Not implemented
0
     def chained_sort_by(receiver, method)
0
       raise "Not implemented."
0
     end
0
 
0
- # >> sort_by { |u| -u.profile.name }
0
- # => #chained_reverse_sort_by(:profile, :name)
0
+ # Not implemented
0
     def chained_reverse_sort_by(receiver, method)
0
       raise "Not implemented."
0
     end
0
 
0
- # >> sort_by(&:name)
0
- # => #to_proc(:name)
0
+ # Not implemented
0
     def to_proc(symbol)
0
       raise "Not implemented."
0
     end
0
 
0
- # >> sort_by { rand }
0
- # => #rand
0
+ # Not implemented
0
     def rand
0
       raise "Not implemented."
0
     end

Comments

    No one has commented yet.