mongoid-elasticsearch 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db302ae88bbc75a63351caed73d74ee3e42ef460
4
- data.tar.gz: 43dec6e93640ff4fb445f27207cdb9c811a71652
3
+ metadata.gz: 1f0c6eaa6812978af90ec347086edbcc03e71d8d
4
+ data.tar.gz: 9d8f30124b7a438dfab87a4e605f5c288050e466
5
5
  SHA512:
6
- metadata.gz: 95acd9cd4b2ee4fb6a6110caadc49d5ff2a4602becfe663da3215027f3f0831ff0efa63760d25e66e63af1634d423abd31d062f98fa5ca527f6d03810c583f3b
7
- data.tar.gz: 10ec98c4e4568bb234cb7ceb9087972e5379cede3901f5552b1d9e085c8eba7c426f983ff1e88286abcfec12e2df2cbc684c7865fd1cebddbe7a3f7f27fb9aa8
6
+ metadata.gz: 2f403b7966a91e238c8cdd7e4d3b990d5a5344f5cf60a51bf76178ed06cd75f998cb96efc5850a5a834c8e6a012709b52f40dd8df7cf7588daa039d4b1c799c9
7
+ data.tar.gz: 9396e8ac12fb662c50cc3e159d957a862952635747a9946c1fce4dc054eee67b491b067f7ff3ebb6f79e4a02d6f6c9cf175677aa1a4a98a303600ec0153589d4
data/.travis.yml CHANGED
@@ -9,9 +9,12 @@ language: ruby
9
9
  rvm:
10
10
  - 1.9.3
11
11
  - 2.0.0
12
+ - 2.1.0
12
13
  - jruby-19mode
14
+ - jruby-20mode
13
15
 
14
16
  gemfile:
15
17
  - Gemfile
18
+ - gemfiles/mongoid3.gemfile
16
19
  - gemfiles/es-git.gemfile
17
20
  - gemfiles/es-0.4.1.gemfile
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in mongoid_rating.gemspec
3
+ # Specify your gem's dependencies in mongoid-elasticsearch.gemspec
4
4
 
5
5
  gemspec
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "mongoid", '~> 3.1.0'
4
+ gem 'elasticsearch'
5
+ gem 'mongoid_slug'
6
+
7
+ gemspec path: "../"
@@ -61,7 +61,11 @@ module Mongoid
61
61
  hits.map do |h|
62
62
  s = h.delete('_source')
63
63
  m = Hashie::Mash.new(h.merge(s))
64
- m.id = BSON::ObjectId.from_string(h['_id'])
64
+ if defined?(Moped::BSON)
65
+ m.id = Moped::BSON::ObjectId.from_string(h['_id'])
66
+ else
67
+ m.id = BSON::ObjectId.from_string(h['_id'])
68
+ end
65
69
  m._id = m.id
66
70
  m
67
71
  end
@@ -148,13 +152,26 @@ module Mongoid
148
152
  hits.map do |h|
149
153
  klass = find_klass(h['_type'])
150
154
  source = h.delete('_source')
151
- source.each do |k,v|
152
- if v.is_a?(Hash) && v.has_key?("$oid")
153
- source[k] = BSON::ObjectId.from_string(v["$oid"])
155
+ if defined?(Moped::BSON)
156
+ source.each do |k,v|
157
+ if v.is_a?(Hash) && v.has_key?("$oid")
158
+ source[k] = Moped::BSON::ObjectId.from_string(v["$oid"])
159
+ end
160
+ end
161
+ else
162
+ source.each do |k,v|
163
+ if v.is_a?(Hash) && v.has_key?("$oid")
164
+ source[k] = BSON::ObjectId.from_string(v["$oid"])
165
+ end
154
166
  end
155
167
  end
156
168
  begin
157
169
  m = klass.new(h.merge(source))
170
+ if defined?(Moped::BSON)
171
+ m.id = Moped::BSON::ObjectId.from_string(h['_id'])
172
+ else
173
+ m.id = BSON::ObjectId.from_string(h['_id'])
174
+ end
158
175
  rescue Mongoid::Errors::UnknownAttribute
159
176
  klass.class_eval <<-RUBY, __FILE__, __LINE__+1
160
177
  attr_accessor :_type, :_score, :_source
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
- VERSION = "0.4.3"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "mongoid", "~> 4.0.0.alpha1"
21
+ spec.add_dependency "mongoid", [">= 3.0", "< 4.1"]
22
22
  spec.add_dependency "elasticsearch", "~> 0.4.1"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "rspec"
27
27
  spec.add_development_dependency "kaminari"
@@ -1,7 +1,7 @@
1
1
  class Article
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps::Short
4
- include ActiveModel::ForbiddenAttributesProtection
4
+ #include ActiveModel::ForbiddenAttributesProtection
5
5
 
6
6
  field :name
7
7
 
@@ -2,7 +2,7 @@ module Namespaced
2
2
  class Model
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps::Short
5
- include ActiveModel::ForbiddenAttributesProtection
5
+ #include ActiveModel::ForbiddenAttributesProtection
6
6
 
7
7
  field :name
8
8
 
data/spec/models/post.rb CHANGED
@@ -3,8 +3,13 @@ class Post
3
3
 
4
4
  field :name, type: String
5
5
  field :content, type: String
6
-
7
- field :my_object_id, type: BSON::ObjectId
6
+
7
+ if defined?(Moped::BSON)
8
+ field :my_object_id, type: Moped::BSON::ObjectId
9
+ else
10
+ field :my_object_id, type: BSON::ObjectId
11
+ end
12
+
8
13
 
9
14
  include Mongoid::Elasticsearch
10
15
  elasticsearch!
@@ -44,7 +44,14 @@ describe Article do
44
44
  @article_1 = Article.create!(name: 'test article name likes', tags: 'likely')
45
45
  @article_2 = Article.create!(name: 'tests likely an another article title')
46
46
  @article_3 = Article.create!(name: 'a strange name for this stuff')
47
- @post_1 = Post.create!(name: 'object_id', my_object_id: BSON::ObjectId.new)
47
+
48
+ if defined?(Moped::BSON)
49
+ @post_1 = Post.create!(name: 'object_id', my_object_id: Moped::BSON::ObjectId.new)
50
+ else
51
+ @post_1 = Post.create!(name: 'object_id', my_object_id: BSON::ObjectId.new)
52
+ end
53
+
54
+
48
55
  Article.es.index.refresh
49
56
  Post.es.index.refresh
50
57
  end
@@ -76,7 +83,12 @@ describe Article do
76
83
 
77
84
  it 'restores BSON::ObjectId with wrapper :model' do
78
85
  results = Post.es.search 'object_id'
79
- results.first.my_object_id.should be_kind_of(BSON::ObjectId)
86
+ if defined?(Moped::BSON)
87
+ results.first.my_object_id.should be_kind_of(Moped::BSON::ObjectId)
88
+ else
89
+ results.first.my_object_id.should be_kind_of(BSON::ObjectId)
90
+ end
91
+
80
92
  results.first.my_object_id.should eq(@post_1.my_object_id)
81
93
  end
82
94
 
@@ -254,6 +266,10 @@ describe "Multisearch" do
254
266
 
255
267
  it 'works' do
256
268
  response = Mongoid::Elasticsearch.search 'test'
269
+ #p response
270
+ #pp response.results
271
+ #pp response.raw_response
272
+ #pp @article_1
257
273
  response.length.should eq 4
258
274
  response.to_a.map(&:class).map(&:name).uniq.sort.should eq ['Article', 'Namespaced::Model', 'Post']
259
275
  response.select { |r| r.class == Article && r.id == @article_1.id }.first.should_not be_nil
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ require "database_cleaner"
22
22
  require "mongoid-elasticsearch"
23
23
 
24
24
  Mongoid::Elasticsearch.prefix = "mongoid_es_test_"
25
+ I18n.enforce_available_locales = true
25
26
 
26
27
  Dir["#{MODELS}/*.rb"].each { |f| require f }
27
28
 
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - <
18
21
  - !ruby/object:Gem::Version
19
- version: 4.0.0.alpha1
22
+ version: '4.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - <
25
31
  - !ruby/object:Gem::Version
26
- version: 4.0.0.alpha1
32
+ version: '4.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: elasticsearch
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +48,16 @@ dependencies:
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - '>='
46
52
  - !ruby/object:Gem::Version
47
- version: '1.3'
53
+ version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - '>='
53
59
  - !ruby/object:Gem::Version
54
- version: '1.3'
60
+ version: '0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +175,7 @@ files:
169
175
  - Rakefile
170
176
  - gemfiles/es-0.4.1.gemfile
171
177
  - gemfiles/es-git.gemfile
178
+ - gemfiles/mongoid3.gemfile
172
179
  - lib/mongoid-elasticsearch.rb
173
180
  - lib/mongoid/elasticsearch.rb
174
181
  - lib/mongoid/elasticsearch/callbacks.rb
@@ -207,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
214
  version: '0'
208
215
  requirements: []
209
216
  rubyforge_project:
210
- rubygems_version: 2.1.11
217
+ rubygems_version: 2.2.1
211
218
  signing_key:
212
219
  specification_version: 4
213
220
  summary: Simple and easy integration of mongoid with the new elasticsearch gem