acts_as_indexed 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -5
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/acts_as_indexed.gemspec +2 -2
- data/lib/acts_as_indexed/search_index.rb +3 -1
- data/lib/acts_as_indexed/storage.rb +2 -2
- data/test/acts_as_indexed_test.rb +27 -27
- data/test/will_paginate_search_test.rb +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
===0.8.
|
2
|
-
- Fixed bug where
|
1
|
+
===0.8.1 [21 December 2012]
|
2
|
+
- Fixed bug where record count was not correctly updated on bulk add. [phurni - Pascal Hurni]
|
3
|
+
|
4
|
+
===0.8.0 [20 December 2012]
|
5
|
+
- Fixed bug where intentional hyphenation was treated as a negative query. Fixes #31.
|
3
6
|
- Fixed bug where will_paginate_search was not being required. Fixes #23.
|
4
7
|
- Fixed bug where quoted phrases were matched across field boundaries. [novalis - David Turner]
|
5
|
-
- Fixed bug where records with indentical match-rankings were returned in different orders under different
|
8
|
+
- Fixed bug where records with indentical match-rankings were returned in different orders under different Ruby implementations.
|
6
9
|
- Storage is now process and thread-safe. Fixes issue #34. [rsamoilov - Roman Samoilov]
|
7
10
|
- Added configuration option to force is-Windows mode for storage. Fixes issues #32, #39.
|
8
|
-
- Added multiple Gemfiles for
|
11
|
+
- Added multiple Gemfiles for Travis CI. https://travis-ci.org/dougal/acts_as_indexed
|
9
12
|
- Acts as Indexed can now be tested stand-alone without a generated Rails app.
|
10
|
-
- ModelKlass.build_index is now a public method
|
13
|
+
- ModelKlass.build_index is now a public method.
|
11
14
|
|
12
15
|
===0.7.8 [14 March 2011]
|
13
16
|
- Fixed bug with file renaming on Windows. Fixes issue #21. [gabynamiman - Gabriel Namiman]
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.1
|
data/acts_as_indexed.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "acts_as_indexed"
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Douglas F Shearer"]
|
12
|
-
s.date = "2012-12-
|
12
|
+
s.date = "2012-12-21"
|
13
13
|
s.description = "Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app"
|
14
14
|
s.email = "dougal.s@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,15 +26,17 @@ module ActsAsIndexed #:nodoc:
|
|
26
26
|
# Adds multiple records to the index. Accepts an array of +records+.
|
27
27
|
def add_records(records)
|
28
28
|
atoms = ActiveSupport::OrderedHash.new
|
29
|
+
records_count = 0
|
29
30
|
|
30
31
|
records.each do |record|
|
31
32
|
next unless @if_proc.call(record)
|
33
|
+
records_count += 1
|
32
34
|
|
33
35
|
condensed_record = condense_record(record)
|
34
36
|
atoms = add_occurences(condensed_record, record.id, atoms)
|
35
37
|
end
|
36
38
|
|
37
|
-
@storage.add(atoms)
|
39
|
+
@storage.add(atoms, records_count)
|
38
40
|
end
|
39
41
|
|
40
42
|
# Removes +record+ from the index.
|
@@ -15,10 +15,10 @@ module ActsAsIndexed #:nodoc:
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Takes a hash of atoms and adds these to storage.
|
18
|
-
def add(atoms)
|
18
|
+
def add(atoms, count=1)
|
19
19
|
operate(:+, atoms)
|
20
20
|
|
21
|
-
update_record_count(
|
21
|
+
update_record_count(count)
|
22
22
|
end
|
23
23
|
|
24
24
|
# Takes a hash of atoms and removes these from storage.
|
@@ -52,8 +52,8 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
52
52
|
queries = {
|
53
53
|
nil => [],
|
54
54
|
'' => [],
|
55
|
-
'ship' => [5
|
56
|
-
'crane' => [6
|
55
|
+
'ship' => [6,5],
|
56
|
+
'crane' => [5,6],
|
57
57
|
'foo' => [6],
|
58
58
|
'foo ship' => [6],
|
59
59
|
'ship foo' => [6]
|
@@ -104,17 +104,17 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
104
104
|
|
105
105
|
def test_start_queries
|
106
106
|
queries = {
|
107
|
-
'ship ^crane' => [5
|
108
|
-
'^crane ship' => [5
|
109
|
-
'^ship ^crane' => [5
|
110
|
-
'^crane ^ship' => [5
|
111
|
-
'^ship crane' => [5
|
112
|
-
'crane ^ship' => [5
|
113
|
-
'^crane' => [6
|
114
|
-
'^cran' => [6
|
115
|
-
'^cra' => [6
|
116
|
-
'^cr' => [
|
117
|
-
'^c' => [
|
107
|
+
'ship ^crane' => [6,5],
|
108
|
+
'^crane ship' => [6,5],
|
109
|
+
'^ship ^crane' => [6,5],
|
110
|
+
'^crane ^ship' => [6,5],
|
111
|
+
'^ship crane' => [6,5],
|
112
|
+
'crane ^ship' => [6,5],
|
113
|
+
'^crane' => [5,6] ,
|
114
|
+
'^cran' => [5,6],
|
115
|
+
'^cra' => [5,6],
|
116
|
+
'^cr' => [4,5,6],
|
117
|
+
'^c' => [1,2,3,4,5,6],
|
118
118
|
'^notthere' => []
|
119
119
|
}
|
120
120
|
|
@@ -123,18 +123,18 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
123
123
|
|
124
124
|
def test_start_quoted_queries
|
125
125
|
queries = {
|
126
|
-
'^"crane" ship' => [5
|
127
|
-
'ship ^"crane"' => [5
|
126
|
+
'^"crane" ship' => [6,5],
|
127
|
+
'ship ^"crane"' => [6,5],
|
128
128
|
'^"crane ship"' => [5],
|
129
129
|
'^"crane shi"' => [5],
|
130
130
|
'^"crane sh"' => [5],
|
131
131
|
'^"crane s"' => [5],
|
132
|
-
'^"crane "' => [6
|
133
|
-
'^"crane"' => [6
|
134
|
-
'^"cran"' => [6
|
135
|
-
'^"cra"' => [6
|
136
|
-
'^"cr"' => [
|
137
|
-
'^"c"' => [
|
132
|
+
'^"crane "' => [5,6],
|
133
|
+
'^"crane"' => [5,6],
|
134
|
+
'^"cran"' => [5,6],
|
135
|
+
'^"cra"' => [5,6],
|
136
|
+
'^"cr"' => [4,5,6],
|
137
|
+
'^"c"' => [1,2,3,4,5,6],
|
138
138
|
}
|
139
139
|
|
140
140
|
run_queries(queries)
|
@@ -146,16 +146,16 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
146
146
|
# The offending assertions are not run in CI as a result.
|
147
147
|
def test_find_options
|
148
148
|
# limit.
|
149
|
-
assert_equal [
|
150
|
-
assert_equal [
|
149
|
+
assert_equal [4], Post.find_with_index('^cr', { :limit => 1 }, :ids_only => true)
|
150
|
+
assert_equal [4], Post.find_with_index('^cr', { :limit => 1 }).map{ |r| r.id }
|
151
151
|
|
152
152
|
# offset
|
153
|
-
assert_equal [
|
154
|
-
assert_equal [
|
153
|
+
assert_equal [5,6], Post.find_with_index('^cr', { :offset => 1 }, :ids_only => true)
|
154
|
+
assert_equal [5,6], Post.find_with_index('^cr', { :offset => 1 }).map{ |r| r.id }
|
155
155
|
|
156
156
|
# limit and offset
|
157
|
-
assert_equal [
|
158
|
-
assert_equal [
|
157
|
+
assert_equal [5], Post.find_with_index('^cr', { :limit => 1, :offset => 1 }, :ids_only => true)
|
158
|
+
assert_equal [5], Post.find_with_index('^cr', { :limit => 1, :offset => 1 }).map{ |r| r.id }
|
159
159
|
|
160
160
|
# order
|
161
161
|
assert_equal [6,5,4,3,2,1], Post.find_with_index('^c', { :order => 'id desc' }).map{ |r| r.id }
|
@@ -11,9 +11,9 @@ class WillPaginateSearchTest < ActiveSupport::TestCase
|
|
11
11
|
|
12
12
|
def test_paginate_search
|
13
13
|
|
14
|
-
assert_equal [
|
15
|
-
assert_equal [
|
16
|
-
assert_equal [
|
14
|
+
assert_equal [1,2,3,4,5,6], paginate_search(1, 10)
|
15
|
+
assert_equal [1,2,3], paginate_search(1, 3)
|
16
|
+
assert_equal [4,5,6], paginate_search(2, 3)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_indexed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Acts As Indexed is a plugin which provides a pain-free way to add fulltext
|
15
15
|
search to your Ruby on Rails app
|