websolr-sunspot_rails_geoding 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009 Kyle Maxwell
2
+ Contributions from Mat Brown, John Barnette
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,213 @@
1
+ == About
2
+
3
+ This is the gem to install for the supported version of sunspot_rails on websolr. The version number of this gem will track the sunspot_rails gem version, with an additional number at the end for our patches. If you install websolr-sunspot_rails 0.11.4.2, that means you got the third (0, 1, 2) release of websolr support for sunspot_rails 0.11.4.
4
+
5
+ == Installation
6
+
7
+ cd your_rails_app
8
+ sudo gem install websolr-sunspot_rails
9
+ config.gem "websolr-sunspot_rails" # into config.environment.rb
10
+ echo websolr-sunspot_rails >> .gems # if using Heroku
11
+ ./script/generate sunspot # Installs config/sunspot.yml
12
+ echo "require 'sunspot/rails/tasks'" >> Rakefile # Installs local development tasks
13
+
14
+ == Usage
15
+
16
+ === Starting a local development server
17
+
18
+ To start up a Solr instance for development, issue the following:
19
+
20
+ rake sunspot:solr:start
21
+
22
+ === Using in production
23
+
24
+ You need to make sure that the WEBSOLR_URL environment variable is set correctly.
25
+
26
+ If you're using Heroku, this should happen automatically. You can verify by running <code>heroku config</code>.
27
+
28
+ If you're running in your own environment, set the environment variable as you normally would on a *nix system.
29
+
30
+ If you have to set the variable in Ruby, you should be able to put the following in an Rails initializer:
31
+
32
+ if RAILS_ENV == "production"
33
+ ENV["WEBSOLR_URL"] = "http://index.websolr.com/solr/[your-api-key]"
34
+ load "websolr-sunspot_rails.rb"
35
+ end
36
+
37
+ === Setup
38
+
39
+ In order for an ActiveRecord model to be indexable and searchable, it must be
40
+ configured for search. For example:
41
+
42
+ class Post < ActiveRecord::Base
43
+ searchable do
44
+ text :title, :body
45
+ integer :blog_id
46
+ time :updated_at
47
+ string :sort_title do
48
+ title.downcase.sub(/^(an?|the) /, '')
49
+ end
50
+ end
51
+ end
52
+
53
+ See the documentation for Sunspot.setup for full details on what can go in the
54
+ configuration block.
55
+
56
+ === Indexing
57
+
58
+ By default, models are indexed whenever they are saved, and removed from the
59
+ index whenever they are destroyed. This behavior can be disabled:
60
+
61
+ class Post < ActiveRecord::Base
62
+ searchable :auto_index => false, :auto_remove => false do
63
+ # setup...
64
+ end
65
+ end
66
+
67
+ Note that <b>using the <code>:auto_remove</code> option is not recommended
68
+ </b>, as destroying an object without removing it from the index will
69
+ create an orphaned document in the index, which is a Bad Thing. Turning off
70
+ <code>:auto_index</code> is perfectly safe if you prefer to manage indexing manually
71
+ (perhaps using a background job).
72
+
73
+ If you have disabled lifecycle indexing hooks, you can invoke indexing
74
+ operations directly on your model:
75
+
76
+ post = Post.create
77
+ post.index
78
+ post.remove_from_index
79
+
80
+ === Committing
81
+
82
+ When data is changed in Solr, it is initially stored in memory and not made
83
+ available to the currently running searcher instance. Issuing a +commit+ to Solr
84
+ will cause it to write the changes to disk, and instantiate a new searcher
85
+ instance. This operation is fairly expensive, so rather than issuing a commit
86
+ every time a document is added or removed, Sunspot::Rails issues a commit at
87
+ the end of any request where data has been added to or removed from Solr. If
88
+ you need to immediately issue a commit, bang!-versions of the methods are
89
+ available:
90
+
91
+ post = Post.create
92
+ post.index!
93
+ # this is the same as...
94
+ post.index
95
+ Sunspot.commit
96
+
97
+ When writing tests outside of the context of a controller request, you will want
98
+ to use one of these two approaches.
99
+
100
+ === Searching
101
+
102
+ Do it like this:
103
+
104
+ Post.search do
105
+ with :blog_id, 1
106
+ with(:updated_at).greater_than(Time.now - 2.weeks)
107
+ order :sort_title, :asc
108
+ paginate :page => 1, :per_page => 15
109
+ end
110
+
111
+ See the documentation for <code>Sunspot.search</code> for all the options
112
+ available in the search block, and the information available in the result
113
+ block.
114
+
115
+ === Searching for IDs
116
+
117
+ In some situations, you may want to get the IDs for models returned by a search
118
+ without actually loading the models out of the database. For that, you can
119
+ call +search_ids+, using the same block format as #search. This will return an
120
+ array of IDs.
121
+
122
+
123
+ === Searching for multiple types
124
+
125
+ Sunspot is entirely agnostic about whether searches are for one or more types;
126
+ the only restriction is that columns used for restriction, ordering, etc. are
127
+ defined in the same way for all types being searched. Sunspot::Rails does not
128
+ provide any additional support for this, since there is not anything useful to
129
+ be added, so just use the interface provided by Sunspot:
130
+
131
+ Sunspot.search(Post, Comment) do
132
+ with :blog_id, 1
133
+ order :created_at, :asc
134
+ end
135
+
136
+ Be sure to check out the Sunspot documentation for all the details.
137
+
138
+ === Adding search functionality in mixins
139
+
140
+ Sunspot does not require that search setup for a given class happen all in one
141
+ place; it is perfectly acceptable to call the <code>Sunspot.setup</code> method
142
+ more than once. This capability is particularly useful for adding search
143
+ functionality in mixins. For instance, if you have a +Ratable+ module, you may
144
+ wish to add additional search fields for searchable classes that mix in that
145
+ module. For example:
146
+
147
+ module Ratable
148
+ def self.included(base)
149
+ if base.searchable?
150
+ base.searchable do
151
+ float :average_rating do
152
+ ratings.average(:value)
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ Note the use of <code>base.searchable?</code> - this ensures that only classes
160
+ that already have search enabled will have the additional configuration added.
161
+ The above pattern requires that the class be declared searchable before the
162
+ module is mixed in; other patterns (such as passing a :searchable option to an
163
+ acts_as_-style declaration) may be more flexible.
164
+
165
+ === Utility methods
166
+
167
+ If you need to completely reindex all of the instances of a given model class,
168
+ you can issue:
169
+
170
+ Post.reindex
171
+
172
+ If for some reason models get deleted from the database, but not from the index,
173
+ they will become index orphans - not a good situation. To get IDs that exist in
174
+ the index but not the database, you can use the +index_orphans+ method; to
175
+ remove those documents from the index, use +clean_index_orphans+. Note that
176
+ neither of these operations should be needed if Sunspot and Sunspot::Rails are
177
+ used as intended.
178
+
179
+
180
+ == Testing Solr integration using RSpec
181
+
182
+ To disable the sunspot-solr integration for your active record models, add the
183
+ following line to your spec_helper.rb
184
+
185
+ require 'sunspot/spec/extension'
186
+
187
+ This will disable all automatic after_save/after_destroy solr-requests generated
188
+ via the #searchable method. This will not disable/mock explicit calls in your code.
189
+
190
+ If you want to test the sunspot-solr integration with active record, you can
191
+ reenable the after_save/after_destroy hooks by adding 'integrate_sunspot' in your
192
+ examples.
193
+
194
+ describe Searches do
195
+ integrate_sunspot
196
+
197
+ before(:each) do
198
+ @movie = Factory.create :movie
199
+ end
200
+
201
+ it "should find a movie" do
202
+ Movie.search { keywords @movie.title }.first.should == @movie
203
+ end
204
+ end
205
+
206
+
207
+
208
+ == Further Reading
209
+
210
+ Reading the {Sunspot documentation}[http://outoftime.github.com/sunspot/docs] is
211
+ highly recommended. Sunspot::Rails exists to wrap Sunspot with a Rails-friendly
212
+ API, but almost all of the functionality you use in Sunspot::Rails is
213
+ implemented in Sunspot.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ VERSION = File.read(File.join(File.dirname(__FILE__), "VERSION"))
2
+
3
+ desc "Build the websolr-sunspot_rails gem for local testing"
4
+ task :build do
5
+ system "gem build websolr-sunspot_rails_geoding.gemspec"
6
+ end
7
+
8
+ desc "Release the websolr-sunspot_rails_geoding gem"
9
+ task :release => :build do
10
+ version_tag = "v#{VERSION}"
11
+ system "git tag -am 'Release version #{VERSION}' '#{version_tag}'"
12
+ system "git push -f origin #{version_tag}:#{version_tag}"
13
+ system "gem push websolr-sunspot_rails_geoding-#{VERSION}.gem"
14
+ FileUtils.rm("websolr-sunspot_rails_geoding-#{VERSION}.gem")
15
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0
@@ -0,0 +1,2 @@
1
+ require "sunspot_rails"
2
+ Sunspot.session = Sunspot::SessionProxy::SilentFailSessionProxy.new(Sunspot.session)
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+ VERSION = File.read(File.join(File.dirname(__FILE__), "VERSION"))
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{websolr-sunspot_rails_geoding}
6
+ s.version = VERSION
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.authors = ["Anup Pareek"]
10
+ s.date = %q{2012-09-20}
11
+ s.description = %q{websolr to sunspot_rails shim}
12
+ s.email = %q{anup.p@cisinlabs.com}
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".document",
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/websolr-sunspot_rails_geoding.rb",
25
+ "websolr-sunspot_rails_geoding.gemspec"
26
+ ]
27
+
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.6}
31
+ s.summary = %q{websolr to sunspot_rails shim}
32
+
33
+ if s.respond_to? :specification_version then
34
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
38
+ s.add_runtime_dependency(%q<sunspot_rails>, ["= 2.0.0.pre.120417"])
39
+ s.add_development_dependency(%q<rspec>, [">= 0"])
40
+ else
41
+ s.add_dependency(%q<sunspot_rails>, ["= 2.0.0.pre.120417"])
42
+ s.add_dependency(%q<rspec>, [">= 0"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<sunspot_rails>, ["= 2.0.0.pre.120417"])
46
+ s.add_dependency(%q<rspec>, [">= 0"])
47
+ end
48
+ end
49
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: websolr-sunspot_rails_geoding
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anup Pareek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sunspot_rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0.pre.120417
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0.pre.120417
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: websolr to sunspot_rails shim
47
+ email: anup.p@cisinlabs.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files:
51
+ - LICENSE
52
+ - README.rdoc
53
+ files:
54
+ - .document
55
+ - .gitignore
56
+ - LICENSE
57
+ - README.rdoc
58
+ - Rakefile
59
+ - VERSION
60
+ - lib/websolr-sunspot_rails_geoding.rb
61
+ - websolr-sunspot_rails_geoding.gemspec
62
+ homepage:
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.18
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: websolr to sunspot_rails shim
87
+ test_files: []