sunspot_mongo 1.0.1 → 1.1.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 +7 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +28 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +118 -0
- data/Gemfile +18 -1
- data/Guardfile +8 -0
- data/LICENSE +2 -2
- data/README.md +77 -0
- data/Rakefile +5 -0
- data/lib/sunspot/mongo.rb +2 -2
- data/lib/sunspot/mongo/railtie.rb +1 -1
- data/lib/sunspot/mongo/tasks.rb +8 -8
- data/lib/sunspot/mongo/version.rb +1 -1
- data/lib/sunspot_mongo.rb +4 -4
- data/spec/shared_examples.rb +27 -0
- data/spec/spec_helper.rb +42 -5
- data/spec/sunspot_mongo_spec.rb +29 -0
- data/spec/support/models/mongo_mapper.rb +21 -0
- data/spec/support/models/mongoid.rb +10 -0
- data/sunspot_mongo.gemspec +18 -17
- metadata +91 -48
- data/README.rdoc +0 -55
- data/spec/sunspot_mongoid_spec.rb +0 -59
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c76e7526946c4e71396d8e9be616809e2cf0641c
|
4
|
+
data.tar.gz: 8a95498eadd27dae4388aa7f9b29a96144e3df77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f1f22f005de41f9724c181d4806e96a4fee285a756c511c061f5ee9b90778ef2b3875eb08ae4182db364ac22916873352ad325bb8451e4025325fba2e6b45e9
|
7
|
+
data.tar.gz: b15f31a49fc636d6d2cb61b05f94cf4f1ba15eb5b157431fc5ed59d1d8a077b45747102e4e814b8e22ba8b2bfb3bf1ee171f14a4368815083d40ade566f55f5b
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-01-27 17:13:18 -0500 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 1
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 20
|
11
|
+
|
12
|
+
# Offense count: 10
|
13
|
+
# Configuration parameters: AllowURI, URISchemes.
|
14
|
+
Metrics/LineLength:
|
15
|
+
Max: 124
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: CountComments.
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Max: 15
|
21
|
+
|
22
|
+
# Offense count: 8
|
23
|
+
Style/Documentation:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
# Offense count: 2
|
27
|
+
Style/RegexpLiteral:
|
28
|
+
MaxSlashes: 0
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#### 1.1.0 (2015/01/27)
|
2
|
+
|
3
|
+
* Changed `DataAccessor#load_all` to use the `.find` method for MongoMapper and Mongoid for loading a group of documents - [@derekharmel](https://github.com/derekharmel).
|
4
|
+
* Changed `load` and `load_all` methods to not force ids to BSON::ObjectId's - [@derekharmel](https://github.com/derekharmel).
|
5
|
+
* [#5](https://github.com/derekharmel/sunspot_mongo/pull/5): Added CONTRIBUTING and CHANGELOG - [@dblock](https://github.com/dblock).
|
6
|
+
* [#5](https://github.com/derekharmel/sunspot_mongo/pull/5): Added Travis-CI - [@dblock](https://github.com/dblock).
|
7
|
+
* [#5](https://github.com/derekharmel/sunspot_mongo/pull/5): Added RuboCop, Ruby-style linter - [@dblock](https://github.com/dblock).
|
8
|
+
* [#1](https://github.com/derekharmel/sunspot_mongo/pull/1): Also search subdirectories of models in `rake sunspot:mongo:reindex` - [@aaw](https://github.com/aaw).
|
9
|
+
|
10
|
+
#### 1.0.1 (2011/10/08)
|
11
|
+
|
12
|
+
* Created rake task `sunspot:mongo:reindex` and a Railtie - [@balexand](https://github.com/balexand).
|
13
|
+
|
14
|
+
#### 1.0 (2011/08/11)
|
15
|
+
|
16
|
+
* Initial public release - [@balexand](https://github.com/balexand).
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
Contributing
|
2
|
+
============
|
3
|
+
|
4
|
+
This library is work of [many of contributors](https://github.com/derekharmel/sunspot_mongo/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/derekharmel/sunspot_mongo/pulls), [propose features and discuss issues](https://github.com/derekharmel/sunspot_mongo/issues).
|
5
|
+
|
6
|
+
#### Fork the Project
|
7
|
+
|
8
|
+
Fork the [project on Github](https://github.com/derekharmel/sunspot_mongo) and check out your copy.
|
9
|
+
|
10
|
+
```
|
11
|
+
git clone https://github.com/contributor/sunspot_mongo.git
|
12
|
+
cd sunspot_mongo
|
13
|
+
git remote add upstream https://github.com/derekharmel/sunspot_mongo.git
|
14
|
+
```
|
15
|
+
|
16
|
+
#### Create a Topic Branch
|
17
|
+
|
18
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
19
|
+
|
20
|
+
```
|
21
|
+
git checkout master
|
22
|
+
git pull upstream master
|
23
|
+
git checkout -b my-feature-branch
|
24
|
+
```
|
25
|
+
|
26
|
+
#### Bundle Install and Test
|
27
|
+
|
28
|
+
Ensure that you can build the project and run tests.
|
29
|
+
|
30
|
+
```
|
31
|
+
bundle install
|
32
|
+
bundle exec rake
|
33
|
+
```
|
34
|
+
|
35
|
+
#### Write Tests
|
36
|
+
|
37
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/sunspot_mongo](spec/sunspot_mongo).
|
38
|
+
|
39
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
40
|
+
|
41
|
+
#### Write Code
|
42
|
+
|
43
|
+
Implement your feature or bug fix.
|
44
|
+
|
45
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
|
46
|
+
|
47
|
+
Make sure that `bundle exec rake` completes without errors.
|
48
|
+
|
49
|
+
#### Write Documentation
|
50
|
+
|
51
|
+
Document any external behavior in the [README](README.md).
|
52
|
+
|
53
|
+
#### Update Changelog
|
54
|
+
|
55
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
56
|
+
|
57
|
+
#### Commit Changes
|
58
|
+
|
59
|
+
Make sure git knows your name and email address:
|
60
|
+
|
61
|
+
```
|
62
|
+
git config --global user.name "Your Name"
|
63
|
+
git config --global user.email "contributor@example.com"
|
64
|
+
```
|
65
|
+
|
66
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
67
|
+
|
68
|
+
```
|
69
|
+
git add ...
|
70
|
+
git commit
|
71
|
+
```
|
72
|
+
|
73
|
+
#### Push
|
74
|
+
|
75
|
+
```
|
76
|
+
git push origin my-feature-branch
|
77
|
+
```
|
78
|
+
|
79
|
+
#### Make a Pull Request
|
80
|
+
|
81
|
+
Go to https://github.com/contributor/sunspot_mongo and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
82
|
+
|
83
|
+
#### Rebase
|
84
|
+
|
85
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
86
|
+
|
87
|
+
```
|
88
|
+
git fetch upstream
|
89
|
+
git rebase upstream/master
|
90
|
+
git push origin my-feature-branch -f
|
91
|
+
```
|
92
|
+
|
93
|
+
#### Update CHANGELOG Again
|
94
|
+
|
95
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
96
|
+
|
97
|
+
```
|
98
|
+
* [#123](https://github.com/derekharmel/sunspot_mongo/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
99
|
+
```
|
100
|
+
|
101
|
+
Amend your previous commit and force push the changes.
|
102
|
+
|
103
|
+
```
|
104
|
+
git commit --amend
|
105
|
+
git push origin my-feature-branch -f
|
106
|
+
```
|
107
|
+
|
108
|
+
#### Check on Your Pull Request
|
109
|
+
|
110
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
111
|
+
|
112
|
+
#### Be Patient
|
113
|
+
|
114
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
115
|
+
|
116
|
+
#### Thank You
|
117
|
+
|
118
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Gemfile
CHANGED
@@ -1,4 +1,21 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
ENV['MONGOID_VERSION'] = '4' unless ENV['MONGOID_VERSION'] || ENV['MONGO_MAPPER_VERSION']
|
4
|
+
|
5
|
+
if ENV['MONGOID_VERSION']
|
6
|
+
case version = ENV['MONGOID_VERSION'] || '~> 4.0'
|
7
|
+
when /4/
|
8
|
+
gem 'mongoid', '~> 4.0'
|
9
|
+
when /3/
|
10
|
+
gem 'mongoid', '~> 3.1'
|
11
|
+
else
|
12
|
+
gem 'mongoid', version
|
13
|
+
end
|
14
|
+
elsif ENV['MONGO_MAPPER_VERSION']
|
15
|
+
version = ENV['MONGO_MAPPER_VERSION'] || '~> 0.13'
|
16
|
+
gem 'mongo_mapper', version
|
17
|
+
gem 'bson_ext'
|
18
|
+
end
|
2
19
|
|
3
20
|
# Specify your gem's dependencies in sunspot_mongo.gemspec
|
4
21
|
gemspec
|
data/Guardfile
ADDED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009 jugyo
|
1
|
+
Copyright (c) 2009-2015 jugyo, Derek Hamel and Contributors
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
[](http://badge.fury.io/rb/sunspot_mongo)
|
2
|
+
[](https://travis-ci.org/derekharmel/sunspot_mongo)
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
### Mongo Mapper
|
7
|
+
|
8
|
+
Put the following in your Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'mongo_mapper'
|
12
|
+
gem 'sunspot_mongo'
|
13
|
+
```
|
14
|
+
|
15
|
+
Then run:
|
16
|
+
|
17
|
+
```
|
18
|
+
rails g mongo_mapper:config
|
19
|
+
rails g sunspot_rails:install
|
20
|
+
rake sunspot:solr:start
|
21
|
+
```
|
22
|
+
|
23
|
+
### Mongoid
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'mongoid'
|
27
|
+
gem 'sunspot_mongo'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then run:
|
31
|
+
|
32
|
+
```
|
33
|
+
rails g mongoid:config
|
34
|
+
rails g sunspot_rails:install
|
35
|
+
rake sunspot:solr:start
|
36
|
+
```
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
Add the following to your model (assuming you have a string field named "content"):
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
include Sunspot::Mongo
|
44
|
+
searchable do
|
45
|
+
text :content
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
Then search like usual:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
search = Article.search do
|
53
|
+
fulltext "something interesting"
|
54
|
+
end
|
55
|
+
search.results
|
56
|
+
```
|
57
|
+
|
58
|
+
Note: Mongoid adds `Article.search`, use `Article.solr_search` instead.
|
59
|
+
|
60
|
+
### Reindexing Objects
|
61
|
+
|
62
|
+
If you are using Rails, objects are automatically indexed to Solr as a part of the save callbacks.
|
63
|
+
|
64
|
+
If you make a change to the object's "schema" (code in the searchable block), you must reindex all objects so the changes are reflected in Solr. Run:
|
65
|
+
|
66
|
+
```
|
67
|
+
bundle exec rake sunspot:mongo:reindex
|
68
|
+
```
|
69
|
+
|
70
|
+
## More info
|
71
|
+
|
72
|
+
See the [Sunspot documentation](http://sunspot.github.com/docs/index.html).
|
73
|
+
|
74
|
+
## Credit
|
75
|
+
|
76
|
+
Based on [sunspot_mongoid](https://github.com/jugyo/sunspot_mongoid) by jugyo.
|
77
|
+
Originally developed by [balexand](https://github.com/balexand).
|
data/Rakefile
CHANGED
data/lib/sunspot/mongo.rb
CHANGED
@@ -19,11 +19,11 @@ module Sunspot
|
|
19
19
|
|
20
20
|
class DataAccessor < Sunspot::Adapters::DataAccessor
|
21
21
|
def load(id)
|
22
|
-
@clazz.find(
|
22
|
+
@clazz.find(id)
|
23
23
|
end
|
24
24
|
|
25
25
|
def load_all(ids)
|
26
|
-
@clazz.
|
26
|
+
@clazz.find(ids)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/sunspot/mongo/tasks.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
namespace :sunspot do
|
2
2
|
namespace :mongo do
|
3
3
|
desc "Reindex all models that include Sunspot::Mongo and are located in your application's models directory."
|
4
|
-
task :reindex, [:models] => :environment do |
|
4
|
+
task :reindex, [:models] => :environment do |_t, args|
|
5
5
|
sunspot_models = if args[:models]
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
args[:models].split('+').map(&:constantize)
|
7
|
+
else
|
8
|
+
all_files = Dir.glob(Rails.root.join('app', 'models', '**', '*.rb'))
|
9
|
+
all_models = all_files.map { |path| File.basename(path, '.rb').camelize.constantize }
|
10
|
+
all_models.select { |m| m.include?(Sunspot::Mongo) && m.searchable? }
|
11
|
+
end
|
12
12
|
|
13
13
|
sunspot_models.each do |model|
|
14
14
|
puts "reindexing #{model}"
|
@@ -17,4 +17,4 @@ namespace :sunspot do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
data/lib/sunspot_mongo.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'sunspot_rails'
|
2
|
+
require 'sunspot/mongo'
|
3
|
+
require 'sunspot/mongo/version'
|
4
|
+
require 'sunspot/mongo/railtie'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
shared_examples 'a mongo document' do
|
2
|
+
subject { described_class }
|
3
|
+
|
4
|
+
it 'should call Sunspot.setup when searchable is called' do
|
5
|
+
expect(Sunspot).to receive(:setup).once.with subject
|
6
|
+
subject.searchable
|
7
|
+
expect(subject.searchable?).to be_truthy
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should search' do
|
11
|
+
options = {}
|
12
|
+
expect(Sunspot).to receive(:new_search).once.and_return(double('search', execute: nil))
|
13
|
+
subject.solr_search(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should index and retrieve' do
|
17
|
+
test_doc = subject.create title: 'So much foo, so little bar.'
|
18
|
+
test_doc.index!
|
19
|
+
|
20
|
+
search = subject.solr_search do
|
21
|
+
fulltext 'foo'
|
22
|
+
end
|
23
|
+
|
24
|
+
expect(search.hits.length).to eql 1
|
25
|
+
expect(search.results.first).to eql test_doc
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,43 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require "sunspot_mongo"
|
1
|
+
require 'rails'
|
2
|
+
require 'sunspot_mongo'
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
ENV['MONGOID_VERSION'] = '4' unless ENV['MONGOID_VERSION'] || ENV['MONGO_MAPPER_VERSION']
|
5
|
+
|
6
|
+
if ENV['MONGOID_VERSION']
|
7
|
+
require 'mongoid'
|
8
|
+
require 'support/models/mongoid'
|
9
|
+
elsif ENV['MONGO_MAPPER_VERSION']
|
10
|
+
require 'mongo_mapper'
|
11
|
+
require 'support/models/mongo_mapper'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Load shared examples
|
15
|
+
require 'shared_examples'
|
16
|
+
|
17
|
+
def setup_servers_and_connections
|
18
|
+
FileUtils.mkdir_p '/tmp/sunspot_mongo_test/'
|
19
|
+
|
20
|
+
@solr_pid = fork { `sunspot-solr start --log-file=solr.log --data-directory=data --log-level=INFO --port=8900` }
|
21
|
+
sleep 5
|
22
|
+
|
23
|
+
if ENV['MONGOID_VERSION']
|
24
|
+
Mongoid.configure do |config|
|
25
|
+
config.connect_to('sunspot_mongo_test')
|
26
|
+
end
|
27
|
+
elsif ENV['MONGO_MAPPER_VERSION']
|
28
|
+
connection = Mongo::Connection.new
|
29
|
+
database = connection.db('sunspot_mongo_test')
|
30
|
+
database.collections.reject { |col| col.name =~ /^system/ }.each(&:drop)
|
31
|
+
MongoMapper.connection = connection
|
32
|
+
MongoMapper.database = 'sunspot_mongo_test'
|
33
|
+
end
|
34
|
+
|
35
|
+
Sunspot.config.solr.url = 'http://127.0.0.1:8900/solr'
|
36
|
+
end
|
37
|
+
setup_servers_and_connections
|
38
|
+
|
39
|
+
RSpec.configure do |config|
|
40
|
+
config.before :each do
|
41
|
+
Sunspot.remove_all!
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Sunspot::Mongo' do
|
4
|
+
it 'has a version' do
|
5
|
+
expect(Sunspot::Mongo::VERSION).to_not be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
if ENV['MONGO_MAPPER_VERSION']
|
9
|
+
describe MongoMapperTestDocument do
|
10
|
+
it_behaves_like 'a mongo document'
|
11
|
+
end
|
12
|
+
describe 'test documents with options' do
|
13
|
+
it 'should set sunspot_options' do
|
14
|
+
expect(MongoMapperTestDocumentWithOptions.sunspot_options).to eq(auto_index: false, auto_remove: false, include: [])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV['MONGOID_VERSION']
|
20
|
+
describe MongoidTestDocument do
|
21
|
+
it_behaves_like 'a mongo document'
|
22
|
+
end
|
23
|
+
describe 'test documents with options' do
|
24
|
+
it 'should set sunspot_options' do
|
25
|
+
expect(MongoidTestDocument.sunspot_options).to eq(include: [])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class MongoMapperTestDocument
|
2
|
+
include MongoMapper::Document
|
3
|
+
include Sunspot::Mongo
|
4
|
+
|
5
|
+
key :title, String
|
6
|
+
|
7
|
+
searchable do
|
8
|
+
text :title
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class MongoMapperTestDocumentWithOptions
|
13
|
+
include MongoMapper::Document
|
14
|
+
include Sunspot::Mongo
|
15
|
+
|
16
|
+
key :title, String
|
17
|
+
|
18
|
+
searchable(auto_index: false, auto_remove: false) do
|
19
|
+
text :title
|
20
|
+
end
|
21
|
+
end
|
data/sunspot_mongo.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'sunspot/mongo/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'sunspot_mongo'
|
7
7
|
s.version = Sunspot::Mongo::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
8
|
+
s.authors = ['Brian Alexander', 'Derek Harmel']
|
9
|
+
s.email = ['balexand@gmail.com', 'dgharmel@gmail.com']
|
10
|
+
s.homepage = 'https://github.com/derekharmel/sunspot_mongo'
|
11
|
+
s.summary = 'Sunspot support for Mongo Mapper and Mongoid.'
|
12
|
+
s.description = 'Sunspot support for Mongo Mapper and Mongoid.'
|
13
13
|
|
14
|
-
s.rubyforge_project =
|
14
|
+
s.rubyforge_project = 'sunspot_mongo'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_dependency
|
21
|
+
s.add_dependency 'sunspot_rails'
|
22
22
|
|
23
|
-
s.add_development_dependency
|
24
|
-
s.add_development_dependency
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
23
|
+
s.add_development_dependency 'rails'
|
24
|
+
s.add_development_dependency 'rspec'
|
25
|
+
s.add_development_dependency 'guard'
|
26
|
+
s.add_development_dependency 'guard-rspec'
|
27
|
+
s.add_development_dependency 'sunspot_solr', '2.0.0'
|
28
|
+
s.add_development_dependency 'rubocop', '0.28.0'
|
28
29
|
end
|
metadata
CHANGED
@@ -1,128 +1,171 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Alexander
|
8
|
+
- Derek Harmel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: sunspot_rails
|
17
|
-
requirement:
|
18
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
|
-
version_requirements:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
26
28
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
28
|
-
requirement:
|
29
|
-
none: false
|
29
|
+
name: rails
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
37
42
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
39
|
-
requirement:
|
40
|
-
none: false
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
41
45
|
requirements:
|
42
|
-
- -
|
46
|
+
- - ">="
|
43
47
|
- !ruby/object:Gem::Version
|
44
48
|
version: '0'
|
45
49
|
type: :development
|
46
50
|
prerelease: false
|
47
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
48
56
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
50
|
-
requirement:
|
51
|
-
none: false
|
57
|
+
name: guard
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
52
59
|
requirements:
|
53
|
-
- -
|
60
|
+
- - ">="
|
54
61
|
- !ruby/object:Gem::Version
|
55
62
|
version: '0'
|
56
63
|
type: :development
|
57
64
|
prerelease: false
|
58
|
-
version_requirements:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
61
|
-
requirement:
|
62
|
-
none: false
|
71
|
+
name: guard-rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
63
73
|
requirements:
|
64
|
-
- -
|
74
|
+
- - ">="
|
65
75
|
- !ruby/object:Gem::Version
|
66
76
|
version: '0'
|
67
77
|
type: :development
|
68
78
|
prerelease: false
|
69
|
-
version_requirements:
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rspec
|
72
|
-
requirement: &70180241338480 !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
80
|
requirements:
|
75
|
-
- -
|
81
|
+
- - ">="
|
76
82
|
- !ruby/object:Gem::Version
|
77
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: sunspot_solr
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 2.0.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.0.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.28.0
|
78
105
|
type: :development
|
79
106
|
prerelease: false
|
80
|
-
version_requirements:
|
81
|
-
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.28.0
|
112
|
+
description: Sunspot support for Mongo Mapper and Mongoid.
|
82
113
|
email:
|
83
114
|
- balexand@gmail.com
|
115
|
+
- dgharmel@gmail.com
|
84
116
|
executables: []
|
85
117
|
extensions: []
|
86
118
|
extra_rdoc_files: []
|
87
119
|
files:
|
88
|
-
- .gitignore
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".rubocop_todo.yml"
|
124
|
+
- ".travis.yml"
|
125
|
+
- CHANGELOG.md
|
126
|
+
- CONTRIBUTING.md
|
89
127
|
- Gemfile
|
128
|
+
- Guardfile
|
90
129
|
- LICENSE
|
91
|
-
- README.
|
130
|
+
- README.md
|
92
131
|
- Rakefile
|
93
132
|
- lib/sunspot/mongo.rb
|
94
133
|
- lib/sunspot/mongo/railtie.rb
|
95
134
|
- lib/sunspot/mongo/tasks.rb
|
96
135
|
- lib/sunspot/mongo/version.rb
|
97
136
|
- lib/sunspot_mongo.rb
|
137
|
+
- spec/shared_examples.rb
|
98
138
|
- spec/spec_helper.rb
|
99
|
-
- spec/
|
139
|
+
- spec/sunspot_mongo_spec.rb
|
140
|
+
- spec/support/models/mongo_mapper.rb
|
141
|
+
- spec/support/models/mongoid.rb
|
100
142
|
- sunspot_mongo.gemspec
|
101
|
-
|
102
|
-
homepage: https://github.com/balexand/sunspot_mongo
|
143
|
+
homepage: https://github.com/derekharmel/sunspot_mongo
|
103
144
|
licenses: []
|
145
|
+
metadata: {}
|
104
146
|
post_install_message:
|
105
147
|
rdoc_options: []
|
106
148
|
require_paths:
|
107
149
|
- lib
|
108
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
151
|
requirements:
|
111
|
-
- -
|
152
|
+
- - ">="
|
112
153
|
- !ruby/object:Gem::Version
|
113
154
|
version: '0'
|
114
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
156
|
requirements:
|
117
|
-
- -
|
157
|
+
- - ">="
|
118
158
|
- !ruby/object:Gem::Version
|
119
159
|
version: '0'
|
120
160
|
requirements: []
|
121
161
|
rubyforge_project: sunspot_mongo
|
122
|
-
rubygems_version:
|
162
|
+
rubygems_version: 2.2.2
|
123
163
|
signing_key:
|
124
|
-
specification_version:
|
125
|
-
summary: Sunspot
|
164
|
+
specification_version: 4
|
165
|
+
summary: Sunspot support for Mongo Mapper and Mongoid.
|
126
166
|
test_files:
|
167
|
+
- spec/shared_examples.rb
|
127
168
|
- spec/spec_helper.rb
|
128
|
-
- spec/
|
169
|
+
- spec/sunspot_mongo_spec.rb
|
170
|
+
- spec/support/models/mongo_mapper.rb
|
171
|
+
- spec/support/models/mongoid.rb
|
data/README.rdoc
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
== Installation
|
2
|
-
|
3
|
-
=== Mongo Mapper
|
4
|
-
|
5
|
-
Put the following in your Gemfile:
|
6
|
-
|
7
|
-
gem 'bson_ext'
|
8
|
-
gem 'mongo_mapper'
|
9
|
-
gem 'sunspot_mongo'
|
10
|
-
|
11
|
-
Then run:
|
12
|
-
|
13
|
-
rails g mongo_mapper:config
|
14
|
-
rails g sunspot_rails:install
|
15
|
-
rake sunspot:solr:start
|
16
|
-
|
17
|
-
=== Mongoid
|
18
|
-
|
19
|
-
gem 'bson_ext'
|
20
|
-
gem 'mongoid'
|
21
|
-
gem 'sunspot_mongo'
|
22
|
-
|
23
|
-
Then run:
|
24
|
-
|
25
|
-
rails g mongoid:config
|
26
|
-
rails g sunspot_rails:install
|
27
|
-
rake sunspot:solr:start
|
28
|
-
|
29
|
-
== Usage
|
30
|
-
|
31
|
-
Add the following to your model (assuming you have a string field named "content"):
|
32
|
-
|
33
|
-
include Sunspot::Mongo
|
34
|
-
searchable do
|
35
|
-
text :content
|
36
|
-
end
|
37
|
-
|
38
|
-
Then search like usual:
|
39
|
-
|
40
|
-
search = Article.search do
|
41
|
-
fulltext "something interesting"
|
42
|
-
end
|
43
|
-
search.results
|
44
|
-
|
45
|
-
== More info
|
46
|
-
|
47
|
-
See the {Sunspot documentation}[http://outoftime.github.com/sunspot/].
|
48
|
-
|
49
|
-
== Compatibility
|
50
|
-
|
51
|
-
This gem has been tested against Ruby 1.9.2 and Rails 3.1, although it should work with older versions.
|
52
|
-
|
53
|
-
== Credit
|
54
|
-
|
55
|
-
Based on {sunspot_mongoid}[https://github.com/jugyo/sunspot_mongoid] by jugyo.
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class MongoMapperTestDocument
|
4
|
-
include MongoMapper::Document
|
5
|
-
key :title, String
|
6
|
-
|
7
|
-
include Sunspot::Mongo
|
8
|
-
searchable do
|
9
|
-
text :title
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class MongoidTestDocument
|
14
|
-
include Mongoid::Document
|
15
|
-
field :title
|
16
|
-
|
17
|
-
include Sunspot::Mongo
|
18
|
-
searchable do
|
19
|
-
text :title
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class MongoMapperTestDocumentWithOptions
|
24
|
-
include MongoMapper::Document
|
25
|
-
key :title, String
|
26
|
-
|
27
|
-
include Sunspot::Mongo
|
28
|
-
searchable(:auto_index => false, :auto_remove => false) do
|
29
|
-
text :title
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
shared_examples "a mongo document" do
|
34
|
-
it "should call Sunspot.setup when searchable is called" do
|
35
|
-
Sunspot.should_receive(:setup).once.with(described_class)
|
36
|
-
described_class.searchable
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should search" do
|
40
|
-
options = {}
|
41
|
-
Sunspot.should_receive(:new_search).once.and_return(double("search", :execute => nil))
|
42
|
-
MongoMapperTestDocument.search(options)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe MongoMapperTestDocument do
|
47
|
-
it_behaves_like "a mongo document"
|
48
|
-
end
|
49
|
-
|
50
|
-
describe MongoidTestDocument do
|
51
|
-
it_behaves_like "a mongo document"
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "test documents with options" do
|
55
|
-
it "should set sunspot_options" do
|
56
|
-
MongoidTestDocument.sunspot_options.should == {:include => []}
|
57
|
-
MongoMapperTestDocumentWithOptions.sunspot_options.should == {:auto_index=>false, :auto_remove=>false, :include=>[]}
|
58
|
-
end
|
59
|
-
end
|