sunspot_mongoid2 0.5.1.5 → 0.5.1.7
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 +4 -4
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/lib/sunspot/mongoid2.rb +12 -4
- data/sunspot_mongoid2.gemspec +5 -5
- data/test/helper.rb +3 -9
- data/test/test_sunspot_mongoid.rb +23 -18
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 887730f8410e42b1acace349cfd05efdae5a76bd
|
4
|
+
data.tar.gz: 4c135ea6545f21801acef13704de67eed2f9c2f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0f274024b8217cec6bbfe73bf81fb8d205433006518766e908c486c49b2be67c3f6d2d3382af71a677f0e61cba990d25d75cd36c14693e3348d7e6b1c3de7d
|
7
|
+
data.tar.gz: fb7c7f5385f6080ae74c5fa3017f4402517a9907e9f43019592da2fd11b4072b56164463b53060f637d930f62ac4e0be7620bf498b87f237a51ef1a422135adc
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -5,13 +5,13 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "sunspot_mongoid2"
|
8
|
-
gem.version = '0.5.1.
|
8
|
+
gem.version = '0.5.1.7'
|
9
9
|
gem.summary = %Q{A Sunspot wrapper for Mongoid 2 or newer.}
|
10
10
|
gem.description = %Q{A Sunspot wrapper for Mongoid that is like sunspot_rails.}
|
11
11
|
gem.email = "jugyo.org@gmail.com aq1018@gmail.com hlegius@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/hlegius/sunspot_mongoid"
|
13
13
|
gem.authors = ["jugyo", "aq1018", 'hlegius']
|
14
|
-
gem.add_runtime_dependency "mongoid", ">=
|
14
|
+
gem.add_runtime_dependency "mongoid", ">= 2"
|
15
15
|
gem.add_runtime_dependency "sunspot", ">= 2"
|
16
16
|
gem.add_runtime_dependency "sunspot_rails", ">= 2"
|
17
17
|
gem.add_development_dependency "shoulda", ">= 0"
|
data/lib/sunspot/mongoid2.rb
CHANGED
@@ -16,8 +16,8 @@ module Sunspot
|
|
16
16
|
module ActsAsMethods
|
17
17
|
# ClassMethods isn't loaded until searchable is called so we need
|
18
18
|
# call it, then extend our own ClassMethods.
|
19
|
-
def searchable
|
20
|
-
super
|
19
|
+
def searchable(opt = {}, &block)
|
20
|
+
super
|
21
21
|
extend ClassMethods
|
22
22
|
end
|
23
23
|
end
|
@@ -39,11 +39,19 @@ module Sunspot
|
|
39
39
|
|
40
40
|
class DataAccessor < Sunspot::Adapters::DataAccessor
|
41
41
|
def load(id)
|
42
|
-
@clazz.find(
|
42
|
+
@clazz.find(bson_id(id)) rescue nil
|
43
43
|
end
|
44
44
|
|
45
45
|
def load_all(ids)
|
46
|
-
@clazz.where(:_id.in => ids.map { |id|
|
46
|
+
@clazz.where(:_id.in => ids.map { |id| bson_id(id) })
|
47
|
+
end
|
48
|
+
|
49
|
+
def bson_id(id)
|
50
|
+
if Gem::Version.new(Mongoid::VERSION) >= Gem::Version.new('3')
|
51
|
+
::Moped::BSON::ObjectId.from_string(id)
|
52
|
+
else
|
53
|
+
::BSON::ObjectId.from_string(id)
|
54
|
+
end
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
data/sunspot_mongoid2.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sunspot_mongoid2"
|
8
|
-
s.version = "0.5.1.
|
8
|
+
s.version = "0.5.1.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jugyo", "aq1018", "hlegius"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-08-29"
|
13
13
|
s.description = "A Sunspot wrapper for Mongoid that is like sunspot_rails."
|
14
14
|
s.email = "jugyo.org@gmail.com aq1018@gmail.com hlegius@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,20 +41,20 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.specification_version = 4
|
42
42
|
|
43
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_runtime_dependency(%q<mongoid>, [">=
|
44
|
+
s.add_runtime_dependency(%q<mongoid>, [">= 2"])
|
45
45
|
s.add_runtime_dependency(%q<sunspot>, [">= 2"])
|
46
46
|
s.add_runtime_dependency(%q<sunspot_rails>, [">= 2"])
|
47
47
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
48
48
|
s.add_development_dependency(%q<rr>, [">= 0"])
|
49
49
|
else
|
50
|
-
s.add_dependency(%q<mongoid>, [">=
|
50
|
+
s.add_dependency(%q<mongoid>, [">= 2"])
|
51
51
|
s.add_dependency(%q<sunspot>, [">= 2"])
|
52
52
|
s.add_dependency(%q<sunspot_rails>, [">= 2"])
|
53
53
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
54
54
|
s.add_dependency(%q<rr>, [">= 0"])
|
55
55
|
end
|
56
56
|
else
|
57
|
-
s.add_dependency(%q<mongoid>, [">=
|
57
|
+
s.add_dependency(%q<mongoid>, [">= 2"])
|
58
58
|
s.add_dependency(%q<sunspot>, [">= 2"])
|
59
59
|
s.add_dependency(%q<sunspot_rails>, [">= 2"])
|
60
60
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
data/test/helper.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'shoulda'
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'pry'
|
4
3
|
require 'rr'
|
5
|
-
|
6
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
-
require '
|
9
|
-
|
10
|
-
class Test::Unit::TestCase
|
11
|
-
include RR::Adapters::TestUnit
|
12
|
-
end
|
6
|
+
require 'sunspot_mongoid2'
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
# NOTE: I think tests are too few...
|
5
|
-
#
|
6
|
-
class TestSunspotMongoid < Test::Unit::TestCase
|
3
|
+
describe Sunspot::Mongoid2 do
|
7
4
|
class Foo
|
8
5
|
include Mongoid::Document
|
9
6
|
field :title
|
10
7
|
|
11
|
-
include Sunspot::
|
8
|
+
include Sunspot::Mongoid2
|
12
9
|
searchable do
|
13
10
|
text :title
|
11
|
+
integer :counting, multiple: false
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
@@ -18,30 +16,37 @@ class TestSunspotMongoid < Test::Unit::TestCase
|
|
18
16
|
include Mongoid::Document
|
19
17
|
field :title
|
20
18
|
|
21
|
-
include Sunspot::
|
19
|
+
include Sunspot::Mongoid2
|
22
20
|
searchable(:auto_index => false, :auto_remove => false) do
|
23
21
|
text :title
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
describe 'initial' do
|
26
|
+
it 'sunspot_options is specified' do
|
27
|
+
Foo.sunspot_options.must_equal({include: []})
|
28
|
+
Bar.sunspot_options.must_equal({auto_index: false, auto_remove: false, include: []})
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
it 'get as text_fields from Sunspot::Setup' do
|
32
|
+
text_field = Sunspot::Setup.for(Foo).all_text_fields.first
|
33
|
+
text_field.type.must_be_instance_of Sunspot::Type::TextType
|
34
|
+
text_field.name.must_equal :title
|
35
|
+
text_field.multiple?.must_equal true
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
it "Sunspot field must support the 'multiple' attribute" do
|
39
|
+
integer_field = Sunspot::Setup.for(Foo).fields.last
|
40
|
+
integer_field.name.must_equal :counting
|
41
|
+
integer_field.multiple?.must_equal false
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'be called Sunspot.setup when call Foo.searchable' do
|
45
|
+
mock(Sunspot).setup(Foo)
|
46
|
+
Foo.searchable
|
42
47
|
end
|
43
48
|
|
44
|
-
|
49
|
+
it '#search' do
|
45
50
|
options = {}
|
46
51
|
mock.proxy(Foo).solr_execute_search(options)
|
47
52
|
mock(Sunspot).new_search(Foo) { mock(Object.new).execute }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_mongoid2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.1.
|
4
|
+
version: 0.5.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongoid
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '>='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '2'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: sunspot
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|