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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 819da31a85723db82618fafa0c5e3afc5ae6b68d
4
- data.tar.gz: 5f050e56fdd23c886619a327a887cd93498da183
3
+ metadata.gz: 887730f8410e42b1acace349cfd05efdae5a76bd
4
+ data.tar.gz: 4c135ea6545f21801acef13704de67eed2f9c2f4
5
5
  SHA512:
6
- metadata.gz: 73eb200b759b8bf2eb7e3dab39089e4b42ee125fa6fcc6a6007cf652f263c85bef6f7f5de61c9d30f2a16652e4d7af78f8131e6c9f5ffdc8b3219b44e85fae93
7
- data.tar.gz: dbf935fb20c72b0582352d688fcde25a8ba7db4fc861fc32a63b1e3d1d8d840be2abef973efd89c5c49acb4999ef6885ffd0e9b88e1c7da9faef569252536e81
6
+ metadata.gz: 5b0f274024b8217cec6bbfe73bf81fb8d205433006518766e908c486c49b2be67c3f6d2d3382af71a677f0e61cba990d25d75cd36c14693e3348d7e6b1c3de7d
7
+ data.tar.gz: fb7c7f5385f6080ae74c5fa3017f4402517a9907e9f43019592da2fd11b4072b56164463b53060f637d930f62ac4e0be7620bf498b87f237a51ef1a422135adc
data/README.md CHANGED
@@ -41,6 +41,7 @@ A Simple Example
41
41
 
42
42
  searchable do
43
43
  text :title
44
+ integer :foo_totals, multiple: true
44
45
  end
45
46
 
46
47
  field :title
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.5'
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", ">= 0"
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"
@@ -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 (opt = {}, &block)
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(::Moped::BSON::ObjectId.from_string(id)) rescue nil
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| ::Moped::BSON::ObjectId.from_string(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
@@ -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.5"
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-05-27"
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>, [">= 0"])
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>, [">= 0"])
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>, [">= 0"])
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"])
@@ -1,12 +1,6 @@
1
- require 'rubygems'
2
- require 'test/unit'
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 'sunspot_mongoid'
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::Mongoid
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::Mongoid
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
- context 'default' do
28
- should 'sunspot_options is specified' do
29
- assert Foo.sunspot_options == {:include => []}
30
- assert Bar.sunspot_options == {:auto_index=>false, :auto_remove=>false, :include=>[]}
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
- should 'be called Sunspot.setup when call Foo.searchable' do
34
- mock(Sunspot).setup(Foo)
35
- Foo.searchable
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
- should 'get as text_fields from Sunspot::Setup' do
39
- text_field = Sunspot::Setup.for(Foo).all_text_fields.first
40
- assert text_field.type == Sunspot::Type::TextType.instance
41
- assert text_field.name == :title
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
- should 'search' do
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.5
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-05-27 00:00:00.000000000 Z
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: '0'
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: '0'
28
+ version: '2'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: sunspot
31
31
  requirement: !ruby/object:Gem::Requirement