tanker 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +94 -2
- data/VERSION +1 -1
- data/tanker.gemspec +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,86 @@
|
|
1
|
-
=
|
1
|
+
= Tanker - IndexTank integration to your favorite orm
|
2
2
|
|
3
|
-
|
3
|
+
*Note:* This gem is still quite alpha but please feel free to send comments
|
4
|
+
|
5
|
+
IndexTank is a great search indexing service, this gem tries to make
|
6
|
+
any orm keep in sync with indextank with ease. This gem has a simple
|
7
|
+
but powerful approach to integrating IndexTank to any orm. The gem
|
8
|
+
also supports pagination using the +will_paginate/collection+. Its dead
|
9
|
+
simple to integrate with Rails 3 basically you just need to
|
10
|
+
|
11
|
+
There are very few things needed to integrate Tanker to any orm.
|
12
|
+
Basically the orm instance must respond to +id+ and any attributes
|
13
|
+
you wish to index.
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
gem install tanker
|
17
|
+
|
18
|
+
If you are using Rails 3 its better to add Tanker to your +GEMFILE+
|
19
|
+
|
20
|
+
gem 'tanker'
|
21
|
+
|
22
|
+
And run
|
23
|
+
|
24
|
+
bundle install
|
25
|
+
|
26
|
+
== Initialization
|
27
|
+
If you're using Rails, config/initializers/tanker.rb is a good place for this:
|
28
|
+
|
29
|
+
Tanker.configuration = {:url => 'http://:xxxxxxxxx@xxxxx.api.indextank.com' }
|
30
|
+
|
31
|
+
You would probably want to have a fancier configuration depending on
|
32
|
+
your environment. Be sure to copy and paste the correct url provided
|
33
|
+
in the IndexTank Dashboard
|
34
|
+
|
35
|
+
== Example
|
36
|
+
|
37
|
+
class Topic < ActiveRecord::Base
|
38
|
+
acts_as_taggable
|
39
|
+
|
40
|
+
# just include the Tanker module
|
41
|
+
include Tanker
|
42
|
+
|
43
|
+
# define the index by supplying the index name and the fields to index
|
44
|
+
tankit 'lgbt' do
|
45
|
+
indexes :title
|
46
|
+
indexes :content
|
47
|
+
indexes :tag_list #NOTICE this is an array of Tags! Awesome!
|
48
|
+
end
|
49
|
+
|
50
|
+
# define the callbacks to update or delete the index
|
51
|
+
# these methods can be called whenever or wherever
|
52
|
+
# this varies between ORMs
|
53
|
+
after_save :update_tank_indexes
|
54
|
+
after_destroy :delete_tank_indexes
|
55
|
+
|
56
|
+
# Note! Will Paginate pagination, thanks mislav!
|
57
|
+
def self.per_page
|
58
|
+
5
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
Create Topics
|
64
|
+
|
65
|
+
Topic.create(:title => 'Awesome Topic', :content => 'blah, blah', :tag_list => 'tag1, tag2')
|
66
|
+
Topic.create(:title => 'Bad Topic', :content => 'blah, blah', :tag_list => 'tag1')
|
67
|
+
Topic.create(:title => 'Cool Topic', :content => 'blah, blah', :tag_list => 'tag3, tag2')
|
68
|
+
|
69
|
+
Search Topics
|
70
|
+
|
71
|
+
@topics = Topic.search_tank('Topic', :page => 1, :per_page => 10) # Gets 3 results!
|
72
|
+
@topics = Topic.search_tank('blah', :conditions => {:tag_list => 'tag1'}) # Gets 2 results!
|
73
|
+
@topics = Topic.search_tank('blah', :conditions => {:title => 'Awesome', :tag_list => 'tag1'}) # Gets 1 result!
|
74
|
+
|
75
|
+
Paginate Results
|
76
|
+
|
77
|
+
<% will_paginate(@topics) %>
|
78
|
+
|
79
|
+
|
80
|
+
== TODO
|
81
|
+
* Rake Tasks to update the index.
|
82
|
+
* Documentation
|
83
|
+
* More fancy stuff (Suggestions?)
|
4
84
|
|
5
85
|
== Note on Patches/Pull Requests
|
6
86
|
|
@@ -12,6 +92,18 @@ Description goes here.
|
|
12
92
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
93
|
* Send me a pull request. Bonus points for topic branches.
|
14
94
|
|
95
|
+
|
96
|
+
== Acknowledgements
|
97
|
+
The gem is based on a couple of projects:
|
98
|
+
|
99
|
+
*{redis-textsearch}[http://github.com/nateware/redis-textsearch]
|
100
|
+
*{mongomapper}[http://github.com/jnunemaker/mongomapper]
|
101
|
+
*{thinkingtank}[http://github.com/flaptor/thinkingtank]
|
102
|
+
*{will_paginate}[http://github.com/mislav/will_paginate]
|
103
|
+
|
104
|
+
Kudos to this awesome projects and developers
|
105
|
+
|
106
|
+
|
15
107
|
== Copyright
|
16
108
|
|
17
109
|
Copyright (c) 2010 @kidpollo. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/tanker.gemspec
CHANGED