mongoid_search 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -66,7 +66,7 @@ Note that the search is case insensitive, and accept partial searching too:
66
66
  Assuming you have a category with multiple products you can now use the following
67
67
  code to search for 'iphone' in products cheaper than $499
68
68
 
69
- @category.products.where(:price.lt => 499).asc(:price).csearch('iphone')
69
+ @category.products.where(:price.lt => 499).csearch('iphone').asc(:price)
70
70
 
71
71
  In this case we have to use csearch, an alias for search, because since v2.0.0
72
72
  Mongoid defines it's own Criteria.search method.
@@ -17,7 +17,7 @@ module Mongoid::Search
17
17
  self.search_fields = (self.search_fields || []).concat args
18
18
 
19
19
  field :_keywords, :type => Array
20
- index :_keywords
20
+ index :_keywords, background: true
21
21
 
22
22
  before_save :set_keywords
23
23
  end
@@ -105,12 +105,9 @@ module Mongoid::Search
105
105
  end
106
106
  else
107
107
  value = self[field]
108
- if value.is_a?(Array)
109
- value.each {|v| Util.keywords(v, stem_keywords, ignore_list) if v}
110
- else
111
- Util.keywords(value, stem_keywords, ignore_list) if value
112
- end
108
+ value = value.join(' ') if value.respond_to?(:join)
109
+ Util.keywords(value, stem_keywords, ignore_list) if value
113
110
  end
114
- end.flatten.map(&:to_s).select{|f| not f.empty? }.uniq.sort
111
+ end.flatten.reject{|k| k.nil? || k.empty?}.uniq.sort
115
112
  end
116
113
  end
@@ -30,10 +30,10 @@ describe Mongoid::Search do
30
30
  end
31
31
  end
32
32
 
33
- it "should set the _keywords field" do
34
- @product.attrs = ['lightweight', 'rugged', :red]
33
+ it "should set the _keywords field for array fields also" do
34
+ @product.attrs = ['lightweight', 'plastic', :red]
35
35
  @product.save!
36
- @product._keywords.should include "amazing", "apple", "awesome", "craddle", "iphone", "mobile", "ole", "lightweight", "rugged", "red"
36
+ @product._keywords.should include 'lightweight', 'plastic', 'red'
37
37
  end
38
38
 
39
39
  it "should inherit _keywords field and build upon" do
@@ -43,8 +43,8 @@ describe Mongoid::Search do
43
43
  :category => Category.new(:name => "Mobile"),
44
44
  :subproducts => [Subproduct.new(:brand => "Apple", :name => "Craddle")],
45
45
  :color => :white
46
- variant._keywords.should include "amazing", "apple", "awesome", "craddle", "iphone", "mobile", "ole", "white"
47
- Variant.search(:name => 'Apple', :color => :white).size.should == 1
46
+ variant._keywords.should include 'white'
47
+ Variant.search(:name => 'Apple', :color => :white).should eq [variant]
48
48
  end
49
49
 
50
50
  it "should set the _keywords field with stemmed words if stem is enabled" do
metadata CHANGED
@@ -1,120 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongoid_search
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Mauricio Zaffari
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-05-26 00:00:00 -03:00
12
+ date: 2011-05-31 00:00:00.000000000 -03:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: mongoid
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2155959000 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
19
+ requirements:
26
20
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 0
31
- - 0
21
+ - !ruby/object:Gem::Version
32
22
  version: 2.0.0
33
23
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bson_ext
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2155959000
26
+ - !ruby/object:Gem::Dependency
27
+ name: bson_ext
28
+ requirement: &2155958360 !ruby/object:Gem::Requirement
39
29
  none: false
40
- requirements:
30
+ requirements:
41
31
  - - ~>
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 1
45
- - 2
46
- version: "1.2"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
47
34
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: fast-stemmer
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2155958360
37
+ - !ruby/object:Gem::Dependency
38
+ name: fast-stemmer
39
+ requirement: &2155957680 !ruby/object:Gem::Requirement
53
40
  none: false
54
- requirements:
41
+ requirements:
55
42
  - - ~>
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 1
59
- - 0
60
- - 0
43
+ - !ruby/object:Gem::Version
61
44
  version: 1.0.0
62
45
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: database_cleaner
66
46
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2155957680
48
+ - !ruby/object:Gem::Dependency
49
+ name: database_cleaner
50
+ requirement: &2155957100 !ruby/object:Gem::Requirement
68
51
  none: false
69
- requirements:
52
+ requirements:
70
53
  - - ~>
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- - 6
75
- - 4
54
+ - !ruby/object:Gem::Version
76
55
  version: 0.6.4
77
56
  type: :development
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: rake
81
57
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2155957100
59
+ - !ruby/object:Gem::Dependency
60
+ name: rake
61
+ requirement: &2155956180 !ruby/object:Gem::Requirement
83
62
  none: false
84
- requirements:
63
+ requirements:
85
64
  - - ~>
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- - 8
90
- - 7
65
+ - !ruby/object:Gem::Version
91
66
  version: 0.8.7
92
67
  type: :development
93
- version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- name: rspec
96
68
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *2155956180
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &2155955460 !ruby/object:Gem::Requirement
98
73
  none: false
99
- requirements:
74
+ requirements:
100
75
  - - ~>
101
- - !ruby/object:Gem::Version
102
- segments:
103
- - 2
104
- - 4
105
- version: "2.4"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.4'
106
78
  type: :development
107
- version_requirements: *id006
79
+ prerelease: false
80
+ version_requirements: *2155955460
108
81
  description: Simple full text search implementation.
109
- email:
82
+ email:
110
83
  - mauricio@papodenerd.net
111
84
  executables: []
112
-
113
85
  extensions: []
114
-
115
86
  extra_rdoc_files: []
116
-
117
- files:
87
+ files:
118
88
  - lib/mongoid_search/mongoid_search.rb
119
89
  - lib/mongoid_search/util.rb
120
90
  - lib/mongoid_search.rb
@@ -134,38 +104,29 @@ files:
134
104
  has_rdoc: true
135
105
  homepage: http://www.papodenerd.net/mongoid-search-full-text-search-for-your-mongoid-models/
136
106
  licenses: []
137
-
138
107
  post_install_message:
139
108
  rdoc_options: []
140
-
141
- require_paths:
109
+ require_paths:
142
110
  - lib
143
- required_ruby_version: !ruby/object:Gem::Requirement
111
+ required_ruby_version: !ruby/object:Gem::Requirement
144
112
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- segments:
149
- - 0
150
- version: "0"
151
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
118
  none: false
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- segments:
157
- - 1
158
- - 3
159
- - 6
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
160
122
  version: 1.3.6
161
123
  requirements: []
162
-
163
124
  rubyforge_project:
164
- rubygems_version: 1.3.7
125
+ rubygems_version: 1.6.2
165
126
  signing_key:
166
127
  specification_version: 3
167
128
  summary: Search implementation for Mongoid ORM
168
- test_files:
129
+ test_files:
169
130
  - spec/config/ignorelist.yml
170
131
  - spec/models/category.rb
171
132
  - spec/models/product.rb