websolr-sunspot4heroku 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: 19518e2a99da4e64da090a6661b0cb254fa666d8
4
+ metadata.gz: 0013c65bf65e7069719f09575e31c06af8e2225e
5
+ SHA512:
6
+ data.tar.gz: 6251d5f9121e142d949bfb80bd5323a36a734a24ed5d4a8e192b9e18bde59257e6bc6736b2ae92899fc13cfa20f7c1109555d63a959e43f1b55c4c1225165fd4
7
+ metadata.gz: 5bc198058139c667b347b08946aa45798d7cba6024326c3c7dca195866fbf0898c199893e45605bfd790c6d9dd2a5f3aae16dd7371e1d802475964897164e5e0
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/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,0 +1,2 @@
1
+ require "sunspot_rails"
2
+ Sunspot.session = Sunspot::SessionProxy::SilentFailSessionProxy.new(Sunspot.session)
@@ -0,0 +1,44 @@
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-sunspot4heroku}
6
+ s.version = VERSION
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.authors = ["Sapna Jadon"]
10
+ s.date = %q{2013-10-08}
11
+ s.description = %q{websolr with geocoding for heroku}
12
+ s.email = %q{jadon.sapna11@gmail.com}
13
+ s.files = [
14
+ ".document",
15
+ ".gitignore",
16
+ "README.rdoc",
17
+ "Rakefile",
18
+ "VERSION",
19
+ "lib/websolr-sunspot4heroku.rb",
20
+ "websolr-sunspot4heroku.gemspec"
21
+ ]
22
+
23
+ s.rdoc_options = ["--charset=UTF-8"]
24
+ s.require_paths = ["lib"]
25
+ s.rubygems_version = %q{1.3.6}
26
+ s.summary = %q{websolr with geocoding for heroku}
27
+
28
+ if s.respond_to? :specification_version then
29
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
30
+ s.specification_version = 3
31
+
32
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
33
+ s.add_runtime_dependency(%q<sunspot_rails>)
34
+ s.add_development_dependency(%q<rspec>, [">= 0"])
35
+ else
36
+ s.add_dependency(%q<sunspot_rails>)
37
+ s.add_dependency(%q<rspec>, [">= 0"])
38
+ end
39
+ else
40
+ s.add_dependency(%q<sunspot_rails>)
41
+ s.add_dependency(%q<rspec>, [">= 0"])
42
+ end
43
+ end
44
+
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: websolr-sunspot4heroku
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sapna Jadon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2013-10-08 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sunspot_rails
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - &id002
20
+ - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :runtime
24
+ version_requirements: *id001
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ prerelease: false
28
+ requirement: &id003 !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - *id002
31
+ type: :development
32
+ version_requirements: *id003
33
+ description: websolr with geocoding for heroku
34
+ email: jadon.sapna11@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - .document
43
+ - .gitignore
44
+ - README.rdoc
45
+ - Rakefile
46
+ - VERSION
47
+ - lib/websolr-sunspot4heroku.rb
48
+ - websolr-sunspot4heroku.gemspec
49
+ homepage:
50
+ licenses: []
51
+
52
+ metadata: {}
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --charset=UTF-8
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - *id002
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - *id002
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 2.1.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: websolr with geocoding for heroku
72
+ test_files: []
73
+