mongoid-elasticsearch 0.3.0 → 0.3.1

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: 817468060649097bdc9d2087961b3c1e48a3f3bf
4
- data.tar.gz: 11a922cfb895f5d0876148f98f69582ed267209a
3
+ metadata.gz: d6ddc81ca8a60464402cee8f9b312a60386c203c
4
+ data.tar.gz: 772a4c6a18512ccaddcb0f334e20fe1596c6ec24
5
5
  SHA512:
6
- metadata.gz: 8108f386fc0005c154d79cc7cf0b9e91d40545295880240781e62b9ec6a58f81e08d73fdfa7eabeaf19e6ed7418e7406f3971deee9d3b08c3bf9b655b4c4b972
7
- data.tar.gz: 6c2cd84050776f09459cddb15c11526c13a55ed6f1719dba9183e869eed87f9e283de44c490ce9fcab9a3380e24585c5a572dd4272c4d7d19e08067dbea6cecc
6
+ metadata.gz: c438080f5c384aa026249dcd58c3ba94b75e0713539e54a91f79db8d43db52db6c394bfc942fd27c2b5e79cdf45bf274a666df990efdc4b56359091a5cb882ca
7
+ data.tar.gz: f1687552273b2f52af268a5c4c12705f31bde5162f65f1881f138b4edc304e983cb4036eec4cb71eccb242ac7bfaa50cdd281534ce7591638d92bd0d2bad48c4
@@ -10,16 +10,8 @@ rvm:
10
10
  - 1.9.3
11
11
  - 2.0.0
12
12
  - jruby-19mode
13
- - ruby-head
14
13
 
15
14
  gemfile:
16
15
  - Gemfile
17
- - gemfiles/mongoid-4.0.gemfile
18
16
  - gemfiles/es-git.gemfile
19
- - gemfiles/es-0.4.0.gemfile
20
17
  - gemfiles/es-0.4.1.gemfile
21
-
22
- matrix:
23
- allow_failures:
24
- - rvm: ruby-head
25
-
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mongoid_rating.gemspec
4
4
  gem "mongoid", github: "mongoid/mongoid"
5
+ gem 'mongoid_slug', github: 'glebtv/mongoid-slug'
6
+
5
7
  gemspec
data/README.md CHANGED
@@ -129,6 +129,7 @@ index definition options and custom model serialization:
129
129
  name: name,
130
130
  excerpt: excerpt
131
131
  }
132
+ # mongoid_slug note: add _slugs to as_indexed_json, NOT slug
132
133
  end
133
134
 
134
135
  [Mapping definition docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html)
@@ -2,5 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "mongoid", github: "mongoid/mongoid", branch: "master"
4
4
  gem 'elasticsearch', '0.4.1'
5
+ gem 'mongoid_slug', github: 'glebtv/mongoid-slug'
5
6
 
6
7
  gemspec path: "../"
@@ -2,5 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "mongoid", github: "mongoid/mongoid", branch: "master"
4
4
  gem 'elasticsearch', github: 'elasticsearch/elasticsearch-ruby', branch: "master"
5
+ gem 'mongoid_slug', github: 'glebtv/mongoid-slug'
5
6
 
6
7
  gemspec path: "../"
@@ -66,13 +66,7 @@ module Mongoid
66
66
  m
67
67
  end
68
68
  when :model
69
- if @multi
70
- multi_without_load
71
- else
72
- hits.map do |h|
73
- model_from_hash(h)
74
- end
75
- end
69
+ multi_without_load
76
70
  else
77
71
  hits
78
72
  end
@@ -118,12 +112,6 @@ module Mongoid
118
112
  alias_method :length, :size
119
113
 
120
114
  private
121
- def model_from_hash(h)
122
- source = h.delete('_source')
123
- m = @model.new(h.merge(source))
124
- m.new_record = false
125
- m
126
- end
127
115
 
128
116
  def find_klass(type)
129
117
  raise NoMethodError, "You have tried to eager load the model instances, " +
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "mongoid", [">= 4.0", "< 5.0"]
22
- spec.add_dependency "elasticsearch", "~> 0.4.0"
22
+ spec.add_dependency "elasticsearch", "~> 0.4.1"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "database_cleaner"
29
29
  spec.add_development_dependency "coveralls"
30
30
  spec.add_development_dependency "hashie"
31
+ spec.add_development_dependency "mongoid_slug"
31
32
  end
@@ -4,12 +4,17 @@ class Article
4
4
  include ActiveModel::ForbiddenAttributesProtection
5
5
 
6
6
  field :name
7
+
8
+ include Mongoid::Slug
9
+ slug :name
10
+
7
11
  field :tags
8
12
 
9
13
  include Mongoid::Elasticsearch
10
14
  i_fields = {
11
15
  name: {type: 'string', analyzer: 'snowball'},
12
- raw: {type: 'string', index: :not_analyzed}
16
+ raw: {type: 'string', index: :not_analyzed},
17
+ _slugs: {type: 'string', index: :not_analyzed}
13
18
  }
14
19
 
15
20
  if Gem::Version.new(::Elasticsearch::Client.new.info['version']['number']) > Gem::Version.new('0.90.2')
@@ -54,6 +54,24 @@ describe Article do
54
54
  results.first.name.should eq @article_2.name
55
55
  end
56
56
 
57
+ it 'mongoid_slug with wrapper: :load' do
58
+ results = Article.es.search q: 'likely'
59
+ expect(Article).to receive(:find).once.with([@article_2.id.to_s]).and_call_original
60
+ results.first.slug.should eq @article_2.name.to_url
61
+ results.first.to_param.should eq @article_2.name.to_url
62
+ end
63
+
64
+ it 'mongoid_slug with wrapper: :model' do
65
+ sleep 3
66
+ results = Article.es.search 'likely', wrapper: :model
67
+ sleep 3
68
+ allow(Article).to receive(:find)
69
+ results.first.slug.should eq @article_2.name.to_url
70
+ results.first.to_param.should eq @article_2.name.to_url
71
+ expect(Article).to_not have_received(:find)
72
+ end
73
+
74
+
57
75
  if Article.es.completion_supported?
58
76
  it 'completion' do
59
77
  Article.es.completion('te', 'name.suggest').should eq [
@@ -204,6 +222,7 @@ describe "Multisearch" do
204
222
  @ns_1 = Namespaced::Model.create!(name: 'test article name likes')
205
223
  Namespaced::Model.es.index.refresh
206
224
  end
225
+
207
226
  it 'works' do
208
227
  response = Mongoid::Elasticsearch.search 'test'
209
228
  response.length.should eq 4
@@ -16,6 +16,7 @@ require "rubygems"
16
16
  require "rspec"
17
17
  require "mongoid"
18
18
  require "hashie"
19
+ require "mongoid_slug"
19
20
  require "database_cleaner"
20
21
 
21
22
  require "mongoid-elasticsearch"
@@ -26,9 +27,9 @@ Dir["#{MODELS}/*.rb"].each { |f| require f }
26
27
 
27
28
  Mongoid.configure do |config|
28
29
  config.connect_to "mongoid_elasticsearch_test"
30
+ #config.logger = Logger.new($stdout, :info)
29
31
  end
30
- Mongoid.logger = Logger.new($stdout)
31
-
32
+ #Moped.logger = Logger.new($stdout, Logger::DEBUG)
32
33
 
33
34
  DatabaseCleaner.orm = "mongoid"
34
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: 0.4.0
39
+ version: 0.4.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 0.4.0
46
+ version: 0.4.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +142,20 @@ dependencies:
142
142
  - - '>='
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: mongoid_slug
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
145
159
  description: Simple and easy integration of mongoid with the new elasticsearch gem
146
160
  email:
147
161
  - glebtv@gmail.com
@@ -159,10 +173,8 @@ files:
159
173
  - MIT-LICENSE.txt
160
174
  - README.md
161
175
  - Rakefile
162
- - gemfiles/es-0.4.0.gemfile
163
176
  - gemfiles/es-0.4.1.gemfile
164
177
  - gemfiles/es-git.gemfile
165
- - gemfiles/mongoid-4.0.gemfile
166
178
  - lib/mongoid-elasticsearch.rb
167
179
  - lib/mongoid/elasticsearch.rb
168
180
  - lib/mongoid/elasticsearch/callbacks.rb
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "mongoid", github: "mongoid/mongoid", branch: "master"
4
- gem 'elasticsearch', '0.4.0'
5
-
6
- gemspec path: "../"
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "mongoid", github: "mongoid/mongoid", branch: "master"
4
-
5
- gemspec path: "../"