acts_as_indexed 0.8.3 → 0.9.0

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
- SHA1:
3
- metadata.gz: 642523bc6ba9fd2b5792780bb53c0b3c3dee27b2
4
- data.tar.gz: 8d5fe0cbb95dab8171e53291da5c451c667b91f6
2
+ SHA256:
3
+ metadata.gz: 2105cca0ae741b470e907e102d7fd28c9fa8085a8e56f15a9a762c6b999d14bc
4
+ data.tar.gz: f49826806af799bce91dee9f39fb648e5a772cda6600e89ea4b9cb798816892a
5
5
  SHA512:
6
- metadata.gz: 51b9c9c8996073136abe30daeda6381f88cd7b03c11b858be4c4c6f77533c24a55fe29ed052f77200e0d615c59652a50fbb38e1ebb9941f740695af2a747842f
7
- data.tar.gz: bfae2e2d9deba4c6c53f02a4f6c20b36c512f11e27e384de0bebfd0cbbd3355c4745f74f5b160cb54fb28f9a408713be7c26f66027dee2dadc036a8c0cdade49
6
+ metadata.gz: dc94b8bb0057c577aacfe2a3f917300995fec76ae971f12485e124915a60815ecc427d49548ce467c7a8f23ccc0e5c4e98f3e49bfef1e41c356f0e792e6cb3be
7
+ data.tar.gz: c57f65cdce75d9df799240ee978a7310a8a33dd057a53b835b8d8598616c75fe315062c6d16eaef004e361e72e58a954379f2e6f4e61f131992322ab67baed7e
data/CHANGELOG.md ADDED
@@ -0,0 +1,231 @@
1
+ # Changelog
2
+
3
+ ## 0.9.0 [25 August 2023]
4
+
5
+ Thanks to Ryan Kopf for reviewing PRs, fixing the broken CI, and tidying things up to make this release possible.
6
+
7
+ - Now tested on Ruby 3.0 and Ruby 3.1. [#70](https://github.com/dougal/acts_as_indexed/pull/70). [[ryankopf](https://github.com/ryankopf) - Ryan Kopf]
8
+ - Remove deprecated Fixnum references. [#62](https://github.com/dougal/acts_as_indexed/pull/62). [[yez](https://github.com/yez) - Jake Yesbeck]
9
+ - Delete Gemfile.lock from repo. [#68](https://github.com/dougal/acts_as_indexed/pull/68). [[parndt](https://github.com/parndt) - Philip Arndt]
10
+ - Bump i18n from 0.6.1 to 0.9.5. [#64](https://github.com/dougal/acts_as_indexed/pull/64)
11
+ - Bump tzinfo from 0.3.35 to 0.3.61. [#66](https://github.com/dougal/acts_as_indexed/pull/66)
12
+ - Bump will_paginate from 3.0.3 to 3.0.5. [#67](https://github.com/dougal/acts_as_indexed/pull/67)
13
+
14
+ ## 0.8.3 [17 February 2013]
15
+
16
+ - Now tested on Ruby 2.0.
17
+ - Fixed issue where underscores were not stripped by the pre-tokenizer.
18
+
19
+ ## 0.8.2 [27 January 2013]
20
+
21
+ - Full review and update of test examples.
22
+ - Fixed bug where all records matching resulted in an ID rather than scored order. [phurni - Pascal Hurni]
23
+ - Fixed bug where records were returned in order of lowest-score first. [phurni - Pascal Hurni]
24
+ - Fixed bug where 1.8.7 would fail CI tests. [parndt - Philip Arndt]
25
+ - 70x performance improvement for non-changed record updates.
26
+ - Added a benchmark suite.
27
+ - Updated README install instructions. [gudata - Ivaylo Bardarov]
28
+
29
+ ## 0.8.1 [21 December 2012]
30
+
31
+ - Fixed bug where record count was not correctly updated on bulk add. [phurni - Pascal Hurni]
32
+
33
+ ## 0.8.0 [20 December 2012]
34
+
35
+ - Fixed bug where intentional hyphenation was treated as a negative query. Fixes #31.
36
+ - Fixed bug where will_paginate_search was not being required. Fixes #23.
37
+ - Fixed bug where quoted phrases were matched across field boundaries. [novalis - David Turner]
38
+ - Fixed bug where records with indentical match-rankings were returned in different orders under different Ruby implementations.
39
+ - Storage is now process and thread-safe. Fixes issue #34. [rsamoilov - Roman Samoilov]
40
+ - Added configuration option to force is-Windows mode for storage. Fixes issues #32, #39.
41
+ - Added multiple Gemfiles for Travis CI. https://travis-ci.org/dougal/acts_as_indexed
42
+ - Acts as Indexed can now be tested stand-alone without a generated Rails app.
43
+ - ModelKlass.build_index is now a public method.
44
+
45
+ ## 0.7.8 [14 March 2011]
46
+
47
+ - Fixed bug with file renaming on Windows. Fixes issue #21. [gabynamiman - Gabriel Namiman]
48
+
49
+ ## 0.7.7 [14 November 2011]
50
+
51
+ - Fixed bug with out-of-date indexes on Windows. Fixes issue #20. [parndt - Philip Arndt]
52
+
53
+ ## 0.7.6 [24th October 2011]
54
+
55
+ - Removed support for atomic writes under Windows. Fixes issue #15.
56
+
57
+ ## 0.7.5 [14th October 2011]
58
+
59
+ - Screwup fix release.
60
+
61
+ ## 0.7.4 [13th October 2011]
62
+
63
+ - Default index location is now in tmp directory. [parndt - Philip Arndt]
64
+ - Fixed a bug where namespaced models would have directory names containing colons. [ugisozols - Uģis Ozols]
65
+
66
+ ## 0.7.3 [3rd July 2011]
67
+
68
+ - Support for non-default primary keys. [ttoomey - Theron Toomey]
69
+ - Fixed issue with file-locking on JRuby. [banderso - Ben Anderson]
70
+
71
+ ## 0.7.2 [31st March 2011]
72
+
73
+ - Fixed bug with ranking of records [Christopher Souvey - bug report]
74
+ - Fixed a bug with the slicing of records before AR order is applied. [Christopher Souvey - bug report]
75
+ - Fixed bug with slicing of id-only results.
76
+ - Error now raised when combining ids_only with find options other than limit and offset.
77
+ - Can now disable auto-indexing. Useful for large test suites.
78
+
79
+ ## 0.7.1 [22nd February 2011]
80
+
81
+ - Removed file locking on Microsoft Windows as it is unsupported.
82
+
83
+ ## 0.7.0 [11th February 2011]
84
+
85
+ - Threadsafe support. Index files are now locked for changes, and atomically written.
86
+ - Configurable case-sensitivity.
87
+ - Improved performance of index builds.
88
+ - Now warns on old version of the index.
89
+ - Upgrade instructions added to README. [ionas - Florent Guilleux]
90
+
91
+ ## 0.6.7 [7th February 2011]
92
+
93
+ - find_by_index and paginate_search are no longer deprecated.
94
+ - Improved documentation.
95
+ - Storage is now its own class to allow future development of locking and pluggable backends.
96
+
97
+ ## 0.6.6 [31st August 2010]
98
+
99
+ - Now Heroku compatible out of the box, index is created in tmp when root dir is non-writable. [parndt - Philip Arndt - Great suggestion]
100
+ - Fixed a require path issue on 1.9.2.
101
+ - Fixed an issue with index_file location on Rails 3.0.0 final.
102
+
103
+ ## 0.6.5 [19th August 2010]
104
+
105
+ - Reintroduced support for older version of Ruby which do not implement Array#exclude? [bug report by Andy Eggers]
106
+ - Using Bundler to manage development dependencies.
107
+
108
+ ## 0.6.4 [16th August 2010]
109
+
110
+ - Added starts-with query type [nilbus - Edward Anderson]
111
+ - Various fixes and improvements.
112
+ - Real names given for all contributors.
113
+
114
+ ## 0.6.3 [5th July 2010]
115
+
116
+ - Index file path can now be defined as a Pathname as well as an array. [parndt - Philip Arndt]
117
+ - Can now define which records are indexed and which are not via an :if proc. [madpilot - Myles Eftos]
118
+ - Lots of tidying up. [parndt - Philip Arndt]
119
+ - Rails 3 fixes. [myabc - Alex Coles]
120
+
121
+ ## 0.6.2 [11th June 2010]
122
+
123
+ - Now available as a Gem as well as the original plugin. [parndt - Philip Arndt - Thanks for doing most of the hard work.]
124
+
125
+ ## 0.6.0 [10th June 2010]
126
+
127
+ - Now supports Rails 3.x.x as well as Rails 2.x.x.
128
+ - Added global configuration options.
129
+ - Now recommending using with_query scope for searching.
130
+ - Deprecated find_with_index and will_paginate_search methods.
131
+
132
+ ## 0.5.3 [6th June 2010]
133
+
134
+ - Now supports non-standard table names automatically. [nandalopes - Fernanda Lopes]
135
+
136
+ ## 0.5.2 [3rd May 2010]
137
+
138
+ - Fix for Errno::ERANGE error related to certain Math.log calculations. [parndt - Philip Arndt]
139
+ - Improved index detection in a shared-directory environment. [bob-p - Thomas Pomfret]
140
+
141
+ ## 0.5.1 [11 June 2009]
142
+
143
+ - Fixed Ruby 1.8.6 compatibility.
144
+
145
+ ## 0.5.0 [24 April 2009]
146
+
147
+ - Ruby 1.9 and Rails 2.3 compatibility.
148
+ - Index location can now be set. Provides Heroku compatibility.
149
+ - Better errors on bad options.
150
+ - ActiveRecord order argument overrides ranking returned by find_by_index.
151
+ - Various test environment improvements
152
+ - Various Bugfixes
153
+
154
+ ## 0.4.6 [10 August 2008]
155
+
156
+ - Rolled in pagination.
157
+
158
+ ## 0.4.5 [04 February 2008]
159
+
160
+ - Fixed a bug where the find_options :limit would be added to the :offset, which caused incorrectly sized collections to be returned.
161
+ - Fixed an 'ambiguous column' error when using the :includes find_options key.
162
+
163
+ ## 0.4.4 [29 November 2007]
164
+
165
+ - Fixed a bug causing the weighting section of the code to error out.
166
+
167
+ ## 0.4.3 [27 September 2007]
168
+
169
+ - Fixed a bug causing records to be deleted from index during record updates.
170
+
171
+ ## 0.4.2 [27 September 2007]
172
+
173
+ - Fixed a bug causing identically ranked records to be lost.
174
+
175
+ ## 0.4.1 [22 September 2007]
176
+
177
+ - Fixed a bug in the main search method.
178
+
179
+ ## 0.4.0 [22 September 2007]
180
+
181
+ - Search results now ranked by relevance.
182
+
183
+ ## 0.3.3 [20 September 2007]
184
+
185
+ - Fixed index update bug where deleted atoms were not removed from index.
186
+ - Improved performance of quoted queries.
187
+ - Improved performance of index updates.
188
+ - When building a full index, records are retrieved and indexed in batches to reduce memory consumption.
189
+
190
+ ## 0.3.2 [19 September 2007]
191
+
192
+ - Fixed index update bug.
193
+
194
+ ## 0.3.1 [18 September 2007]
195
+
196
+ - Added RDoc documentation comments.
197
+
198
+ ## 0.3.0 [18 September 2007]
199
+
200
+ - Minor bug fixes.
201
+ - min_word_size now works properly, with queries containing small words in
202
+ quotes or being preceded by a '+' symbol are now searched on.
203
+
204
+ ## 0.2.2 [06 September 2007]
205
+
206
+ - Search now caches query results within a session. Call the search twice in an
207
+ action? Only runs once!
208
+
209
+ ## 0.2.1 [05 September 2007]
210
+
211
+ - AR find options can now be passed to the search to allow finer control of
212
+ returned Model Objects.
213
+
214
+ ## 0.2.0 [04 September 2007]
215
+
216
+ - Major performance improvements.
217
+ - Index segmentation can now be tuned.
218
+
219
+ ## 0.1.1 [31 August 2007]
220
+
221
+ - Added a full set of tests.
222
+ - Fixed various set-manipulation based errors.
223
+ - Fixed a bug when searching for quoted phrases.
224
+
225
+ ## 0.1.01 [31 August 2007]
226
+
227
+ - Fixed a casting bug occurring when adding non-string fields to the index.
228
+
229
+ ## 0.1 [31 August 2007]
230
+
231
+ - Initial release.
data/Gemfile CHANGED
@@ -1,9 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :test do
4
+ gem "sdoc"
4
5
  gem "rake"
5
- gem "mocha", "~> 0.9.11"
6
- gem "sqlite3", "~> 1.3.5"
7
- gem "activerecord", "~> 3.2.9"
8
- gem "will_paginate", "~> 3.0.3"
6
+ gem "minitest"
7
+ gem "mocha"#, "~> 0.9.11"
8
+ gem "sqlite3"#, "~> 1.3.5"
9
+ gem "activerecord"#, "~> 3.2.9"
10
+ gem "will_paginate"#, "~> 4.0"
11
+ gem "activesupport"
9
12
  end
data/README.rdoc CHANGED
@@ -187,6 +187,7 @@ bugfixes and features wouldn't have happened.
187
187
  * Roman Samoilov
188
188
  * David Turner
189
189
  * Pascal Hurni
190
+ * Ryan Kopf
190
191
 
191
192
 
192
193
  == Unicode (UTF8) Support
data/Rakefile CHANGED
@@ -28,6 +28,14 @@ Rake::TestTask.new('test:integration') do |t|
28
28
  t.verbose = true
29
29
  end
30
30
 
31
+ desc 'Run temp tests.'
32
+ Rake::TestTask.new('test:temp') do |t|
33
+ t.libs << 'test'
34
+ t.libs << 'lib'
35
+ t.pattern = 'test/integration/will_paginate_search_test.rb'
36
+ t.verbose = true
37
+ end
38
+
31
39
  desc 'Run performance tests.'
32
40
  Rake::TestTask.new('test:performance') do |t|
33
41
  t.libs << 'test'
@@ -61,6 +69,8 @@ begin
61
69
  gemspec.email = "dougal.s@gmail.com"
62
70
  gemspec.homepage = "http://github.com/dougal/acts_as_indexed"
63
71
  gemspec.authors = ["Douglas F Shearer"]
72
+ gemspec.files.exclude ".github/**/*"
73
+ gemspec.files.exclude ".travis.yml"
64
74
  end
65
75
  Jeweler::GemcutterTasks.new
66
76
  rescue LoadError
data/TODO ADDED
@@ -0,0 +1,9 @@
1
+
2
+ - Way to config pluginables.
3
+ - Alternative Unicode normalizer
4
+ - Alternative stemming normalizer - PROBABLY NOT
5
+ - Sort out atom/word/token fuckupery
6
+
7
+ Ways to speed up updates?
8
+ - queue up operations on files the commit all-at-once OR
9
+ - Do atom subtraction and deletion for updated record and only write changes.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.3
1
+ 0.9.0
@@ -2,24 +2,26 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: acts_as_indexed 0.9.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = "acts_as_indexed"
8
- s.version = "0.8.3"
8
+ s.name = "acts_as_indexed".freeze
9
+ s.version = "0.9.0"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Douglas F Shearer"]
12
- s.date = "2013-04-17"
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
- s.email = "dougal.s@gmail.com"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Douglas F Shearer".freeze]
14
+ s.date = "2023-08-25"
15
+ s.description = "Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app".freeze
16
+ s.email = "dougal.s@gmail.com".freeze
15
17
  s.extra_rdoc_files = [
16
- "README.rdoc"
18
+ "CHANGELOG.md",
19
+ "README.rdoc",
20
+ "TODO"
17
21
  ]
18
22
  s.files = [
19
- ".travis.yml",
20
- "CHANGELOG",
23
+ "CHANGELOG.md",
21
24
  "Gemfile",
22
- "Gemfile.lock",
23
25
  "MIT-LICENSE",
24
26
  "README.rdoc",
25
27
  "Rakefile",
@@ -61,9 +63,8 @@ Gem::Specification.new do |s|
61
63
  "test/unit/tokenizer_test.rb",
62
64
  "test/unit_test_helper.rb"
63
65
  ]
64
- s.homepage = "http://github.com/dougal/acts_as_indexed"
65
- s.require_paths = ["lib"]
66
- s.rubygems_version = "1.8.23"
67
- s.summary = "Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app"
66
+ s.homepage = "http://github.com/dougal/acts_as_indexed".freeze
67
+ s.rubygems_version = "3.3.7".freeze
68
+ s.summary = "Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app".freeze
68
69
  end
69
70
 
@@ -34,7 +34,10 @@ module ActsAsIndexed
34
34
  named_scope :with_query, lambda { |query| { :conditions => ["#{table_name}.#{primary_key} IN (?)", search_index(query, {}, {:ids_only => true}) ] } }
35
35
  end
36
36
 
37
- cattr_accessor :aai_config, :aai_fields
37
+ unless respond_to?(:aai_fields) && respond_to?(:aai_config)
38
+ cattr_accessor :aai_config, :aai_fields
39
+ end
40
+ #cattr_accessor :aai_config, :aai_fields
38
41
 
39
42
  self.aai_fields = options.delete(:fields)
40
43
  raise(ArgumentError, 'no fields specified') if self.aai_fields.nil? || self.aai_fields.empty?
@@ -134,25 +137,58 @@ module ActsAsIndexed
134
137
 
135
138
  return part_query if options[:ids_only]
136
139
 
137
- with_scope :find => find_options do
138
- # Doing the find like this eliminates the possibility of errors occuring
139
- # on either missing records (out-of-sync) or an empty results array.
140
- records = find(:all, :conditions => [ "#{table_name}.#{primary_key} IN (?)", part_query])
141
-
142
- if find_options.include?(:order)
143
- records # Just return the records without ranking them.
140
+ # New 2023 way to find the records.
141
+ conditions = ["#{table_name}.#{primary_key} IN (?)", part_query]
142
+ records = where(conditions)
144
143
 
145
- else
146
- # Results come back in random order from SQL, so order again.
147
- ranked_records = ActiveSupport::OrderedHash.new
148
- records.each do |r|
149
- ranked_records[r] = @query_cache[query][r.id]
150
- end
144
+ if find_options[:conditions]
145
+ records = records.where(find_options[:conditions])
146
+ end
147
+ if find_options[:joins]
148
+ records = records.joins(find_options[:joins])
149
+ end
150
+ if find_options[:includes]
151
+ records = records.includes(find_options[:includes])
152
+ end
153
+ if find_options[:limit]
154
+ records = records.limit(find_options[:limit])
155
+ end
156
+ if find_options[:offset]
157
+ records = records.offset(find_options[:offset])
158
+ end
159
+ if find_options[:order]
160
+ records = records.order(find_options[:order])
161
+ return records # Just return the records without ranking them.
162
+ end
151
163
 
152
- sort(ranked_records.to_a).map{ |r| r.first }
153
- end
164
+ # Results come back in random order from SQL, so order again.
165
+ ranked_records = {}
166
+ records.each do |r|
167
+ ranked_records[r] = @query_cache[query][r.id]
154
168
  end
155
169
 
170
+ sort(ranked_records.to_a).map{ |r| r.first }
171
+
172
+ # Old way, deprecated and broken.
173
+ # with_scope :find => find_options do
174
+ # # Doing the find like this eliminates the possibility of errors occuring
175
+ # # on either missing records (out-of-sync) or an empty results array.
176
+ # records = find(:all, :conditions => [ "#{table_name}.#{primary_key} IN (?)", part_query])
177
+ #
178
+ # if find_options.include?(:order)
179
+ # records # Just return the records without ranking them.
180
+ #
181
+ # else
182
+ # # Results come back in random order from SQL, so order again.
183
+ # ranked_records = ActiveSupport::OrderedHash.new
184
+ # records.each do |r|
185
+ # ranked_records[r] = @query_cache[query][r.id]
186
+ # end
187
+ #
188
+ # sort(ranked_records.to_a).map{ |r| r.first }
189
+ # end
190
+ # end
191
+
156
192
  end
157
193
 
158
194
  # Builds an index from scratch for the current model class.
@@ -162,7 +198,7 @@ module ActsAsIndexed
162
198
  return if aai_config.index_file.directory?
163
199
 
164
200
  index = new_index
165
- find_in_batches({ :batch_size => 500 }) do |records|
201
+ find_in_batches(batch_size: 500) do |records|
166
202
  index.add_records(records)
167
203
  end
168
204
  end
@@ -174,10 +210,10 @@ module ActsAsIndexed
174
210
  def sort(ranked_records)
175
211
  ranked_records.sort { |a, b|
176
212
  a_score = a.last
177
- a_id = a.first.is_a?(Fixnum) ? a.first : a.first.id
213
+ a_id = a.first.is_a?(Integer) ? a.first : a.first.id
178
214
 
179
215
  b_score = b.last
180
- b_id = b.first.is_a?(Fixnum) ? b.first : b.first.id
216
+ b_id = b.first.is_a?(Integer) ? b.first : b.first.id
181
217
 
182
218
  if a_score == b_score
183
219
  a_id <=> b_id
@@ -194,4 +230,4 @@ module ActsAsIndexed
194
230
 
195
231
  end
196
232
 
197
- end
233
+ end
@@ -4,7 +4,7 @@ module ActsAsIndexed
4
4
 
5
5
  # Sets the location for the index. Specify as an array. The default, for
6
6
  # example, would be set as [Rails.root,'tmp','index].
7
- attr_accessor :index_file
7
+ #attr_accessor :index_file
8
8
 
9
9
  # Tuning value for the index partitioning. Larger values result in quicker
10
10
  # searches, but slower indexing. Default is 3.
@@ -18,7 +18,7 @@ module ActsAsIndexed
18
18
  # Proc that allows you to turn on or off index for a record.
19
19
  # Useful if you don't want an object to be placed in the index, such as a
20
20
  # draft post.
21
- attr_accessor :if_proc
21
+ attr_writer :if_proc
22
22
 
23
23
  # Enable or disable case sensitivity.
24
24
  # Set to true to enable.
@@ -1,5 +1,7 @@
1
1
  require 'active_record'
2
2
 
3
+ path = File.expand_path(File.dirname(__FILE__))
4
+ $:.unshift path unless $:.include?(path)
3
5
  require 'acts_as_indexed/class_methods'
4
6
  require 'acts_as_indexed/instance_methods'
5
7
  require 'acts_as_indexed/singleton_methods'
@@ -1,8 +1,8 @@
1
1
  module ActsAsIndexed
2
2
 
3
- module WillPaginate
3
+ module WillPaginate
4
4
 
5
- module Search
5
+ module Search
6
6
 
7
7
  def paginate_search(query, options)
8
8
  page = options.fetch(:page) { raise ArgumentError, ":page parameter required" }
@@ -44,7 +44,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
44
44
  def test_updates_index
45
45
  p = Post.create(:title => 'A special title', :body => 'foo bar bla bla bla')
46
46
  assert find_with_index_ids('title').include?(p.id)
47
- p.update_attributes(:title => 'No longer special')
47
+ p.update(:title => 'No longer special')
48
48
  assert !find_with_index_ids('title').include?(p.id)
49
49
  end
50
50
 
@@ -185,7 +185,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
185
185
  # all records with that same atom from the index.
186
186
  def test_update_record_bug
187
187
  p = Post.find(6)
188
- assert p.update_attributes(:body => p.body + ' crane')
188
+ assert p.update(:body => p.body + ' crane')
189
189
  assert_equal 2, find_with_index_ids('crane').size
190
190
  assert_equal 2, find_with_index_ids('ship').size
191
191
  end
@@ -216,7 +216,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
216
216
 
217
217
  assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
218
218
  p = Post.find(6)
219
- assert p.update_attributes(:visible => true)
219
+ assert p.update(:visible => true)
220
220
  assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
221
221
  end
222
222
 
@@ -227,7 +227,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
227
227
 
228
228
  assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
229
229
  p = Post.find(6)
230
- assert p.update_attributes(:visible => false)
230
+ assert p.update(:visible => false)
231
231
  assert_equal 0, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size
232
232
  end
233
233
 
@@ -238,7 +238,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
238
238
 
239
239
  assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
240
240
  p = Post.find(5)
241
- assert p.update_attributes(:visible => true)
241
+ assert p.update(:visible => true)
242
242
  assert_equal 2, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size
243
243
  end
244
244
 
@@ -249,7 +249,7 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
249
249
 
250
250
  assert_equal [6], Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true})
251
251
 
252
- posts(:wikipedia_article_5).update_attributes(:title => 'A new title')
252
+ posts(:wikipedia_article_5).update(:title => 'A new title')
253
253
  assert_equal [6], Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true})
254
254
  end
255
255
 
@@ -1,4 +1,4 @@
1
- require 'integration_test_helper.rb'
1
+ require 'integration_test_helper'
2
2
 
3
3
  class WillPaginateSearchTest < ActiveSupport::TestCase
4
4
  fixtures :posts
@@ -10,7 +10,6 @@ class WillPaginateSearchTest < ActiveSupport::TestCase
10
10
  end
11
11
 
12
12
  def test_paginate_search
13
-
14
13
  assert_equal [5, 2, 1, 3, 6, 4], paginate_search(1, 10)
15
14
  assert_equal [5, 2, 1], paginate_search(1, 3)
16
15
  assert_equal [3, 6, 4], paginate_search(2, 3)
@@ -1,6 +1,5 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'fileutils'
3
- require 'rubygems'
4
3
 
5
4
  require 'bundler/setup'
6
5
  require 'active_record'
@@ -29,19 +28,21 @@ require test_path.parent.join('lib', 'acts_as_indexed').to_s
29
28
 
30
29
  ActiveRecord::Base.logger = Logger.new(test_path.join('test.log').to_s)
31
30
  ActiveRecord::Base.configurations = YAML::load(IO.read(test_path.join('config', 'database.yml').to_s))
32
- ActiveRecord::Base.establish_connection(ENV['DB'] || 'sqlite3')
31
+ ActiveRecord::Base.establish_connection(ENV['DB'] || :sqlite3)
33
32
 
34
33
  # Load Schema
35
34
  load(test_path.join('db', 'schema.rb').to_s)
36
35
 
37
36
  # Load model.
38
37
  $LOAD_PATH.unshift(test_path.join('fixtures').to_s)
38
+ require 'post'
39
39
 
40
40
  class ActiveSupport::TestCase #:nodoc:
41
41
  include ActiveRecord::TestFixtures
42
42
  self.fixture_path = Pathname.new(File.expand_path('../', __FILE__)).join('fixtures').to_s
43
- self.use_transactional_fixtures = true
44
- self.use_instantiated_fixtures = false
43
+ self.use_transactional_tests = true
44
+ self.use_instantiated_fixtures = false
45
+ #fixtures :all
45
46
 
46
47
  def destroy_index
47
48
  FileUtils.rm_rf(index_loc)
@@ -1,4 +1,4 @@
1
- require 'unit_test_helper.rb'
1
+ require 'unit_test_helper'
2
2
  include ActsAsIndexed
3
3
 
4
4
  class ConfigurationTest < ActiveSupport::TestCase
@@ -35,7 +35,7 @@ class ConfigurationTest < ActiveSupport::TestCase
35
35
  end
36
36
 
37
37
  def test_index_file_depth_should_raise_on_lower_than_1_value
38
- assert_nothing_raised(ArgumentError) { config.index_file_depth = 1 }
38
+ assert_nothing_raised { config.index_file_depth = 1 }
39
39
 
40
40
  e = assert_raise(ArgumentError) { config.index_file_depth = 0 }
41
41
  assert_equal 'index_file_depth cannot be less than one (1)', e.message
@@ -49,7 +49,7 @@ class ConfigurationTest < ActiveSupport::TestCase
49
49
  end
50
50
 
51
51
  def test_min_word_size_should_raise_on_lower_than_1_value
52
- assert_nothing_raised(ArgumentError) { config.min_word_size = 1 }
52
+ assert_nothing_raised { config.min_word_size = 1 }
53
53
 
54
54
  e = assert_raise(ArgumentError) { config.min_word_size = 0 }
55
55
  assert_equal 'min_word_size cannot be less than one (1)', e.message
@@ -1,7 +1,7 @@
1
1
  require 'unit_test_helper.rb'
2
2
  include ActsAsIndexed
3
3
 
4
- class SearchAtomTest < ActiveSupport::TestCase
4
+ class SearchAtomTest < ActiveSupport::TestCase
5
5
 
6
6
  def test_should_create_a_new_instance
7
7
  assert SearchAtom.new
@@ -48,7 +48,7 @@ class SearchAtomTest < ActiveSupport::TestCase
48
48
  end
49
49
 
50
50
  def test_positions_should_return_nil
51
- assert_equal nil, build_search_atom.positions(456)
51
+ assert_nil build_search_atom.positions(456)
52
52
  end
53
53
 
54
54
  def test_remove_record
@@ -1,9 +1,11 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'fileutils'
3
- require 'rubygems'
4
3
 
5
- require 'bundler/setup'
6
- require 'mocha'
4
+ # require 'bundler/setup'
5
+ # require 'mocha'
6
+ # require 'mocha/integration/test_unit'
7
+ require 'mocha/minitest'
8
+ require 'active_support/test_case'
7
9
 
8
10
  # Mock out the required environment variables.
9
11
  # Do this before requiring AAI.
@@ -16,5 +18,6 @@ class Rails
16
18
  end
17
19
  end
18
20
 
19
- test_path = Pathname.new(File.expand_path('../', __FILE__))
20
- require test_path.parent.join('lib', 'acts_as_indexed').to_s
21
+ # test_path = Pathname.new(File.expand_path('../', __FILE__))
22
+ # require test_path.parent.join('lib', 'acts_as_indexed').to_s
23
+ require_relative '../lib/acts_as_indexed'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_indexed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas F Shearer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-17 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Acts As Indexed is a plugin which provides a pain-free way to add fulltext
14
14
  search to your Ruby on Rails app
@@ -16,15 +16,16 @@ email: dougal.s@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files:
19
+ - CHANGELOG.md
19
20
  - README.rdoc
21
+ - TODO
20
22
  files:
21
- - .travis.yml
22
- - CHANGELOG
23
+ - CHANGELOG.md
23
24
  - Gemfile
24
- - Gemfile.lock
25
25
  - MIT-LICENSE
26
26
  - README.rdoc
27
27
  - Rakefile
28
+ - TODO
28
29
  - VERSION
29
30
  - acts_as_indexed.gemspec
30
31
  - gemfiles/rails2_3.gemfile
@@ -65,24 +66,23 @@ files:
65
66
  homepage: http://github.com/dougal/acts_as_indexed
66
67
  licenses: []
67
68
  metadata: {}
68
- post_install_message:
69
+ post_install_message:
69
70
  rdoc_options: []
70
71
  require_paths:
71
72
  - lib
72
73
  required_ruby_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
- - - '>='
75
+ - - ">="
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  required_rubygems_version: !ruby/object:Gem::Requirement
78
79
  requirements:
79
- - - '>='
80
+ - - ">="
80
81
  - !ruby/object:Gem::Version
81
82
  version: '0'
82
83
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.0.0
85
- signing_key:
84
+ rubygems_version: 3.3.7
85
+ signing_key:
86
86
  specification_version: 4
87
87
  summary: Acts As Indexed is a plugin which provides a pain-free way to add fulltext
88
88
  search to your Ruby on Rails app
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
8
-
9
- gemfile:
10
- - Gemfile
11
- - gemfiles/rails2_3.gemfile
12
- - gemfiles/rails3_0.gemfile
13
- - gemfiles/rails3_1.gemfile
14
- - gemfiles/rails3_2.gemfile
data/CHANGELOG DELETED
@@ -1,177 +0,0 @@
1
- ===0.8.3 [17 February 2013]
2
- - Now tested on Ruby 2.0.
3
- - Fixed issue where underscores were not stripped by the pre-tokenizer.
4
-
5
- ===0.8.2 [27 January 2013]
6
- - Full review and update of test examples.
7
- - Fixed bug where all records matching resulted in an ID rather than scored order. [phurni - Pascal Hurni]
8
- - Fixed bug where records were returned in order of lowest-score first. [phurni - Pascal Hurni]
9
- - Fixed bug where 1.8.7 would fail CI tests. [parndt - Philip Arndt]
10
- - 70x performance improvement for non-changed record updates.
11
- - Added a benchmark suite.
12
- - Updated README install instructions. [gudata - Ivaylo Bardarov]
13
-
14
- ===0.8.1 [21 December 2012]
15
- - Fixed bug where record count was not correctly updated on bulk add. [phurni - Pascal Hurni]
16
-
17
- ===0.8.0 [20 December 2012]
18
- - Fixed bug where intentional hyphenation was treated as a negative query. Fixes #31.
19
- - Fixed bug where will_paginate_search was not being required. Fixes #23.
20
- - Fixed bug where quoted phrases were matched across field boundaries. [novalis - David Turner]
21
- - Fixed bug where records with identical match-rankings were returned in different orders under different Ruby implementations.
22
- - Storage is now process and thread-safe. Fixes issue #34. [rsamoilov - Roman Samoilov]
23
- - Added configuration option to force is-Windows mode for storage. Fixes issues #32, #39.
24
- - Added multiple Gemfiles for Travis CI. https://travis-ci.org/dougal/acts_as_indexed
25
- - Acts as Indexed can now be tested stand-alone without a generated Rails app.
26
- - ModelKlass.build_index is now a public method.
27
-
28
- ===0.7.8 [14 March 2011]
29
- - Fixed bug with file renaming on Windows. Fixes issue #21. [gabynamiman - Gabriel Namiman]
30
-
31
- ===0.7.7 [14 November 2011]
32
- - Fixed bug with out-of-date indexes on Windows. Fixes issue #20. [parndt - Philip Arndt]
33
-
34
- ===0.7.6 [24th October 2011]
35
- - Removed support for atomic writes under Windows. Fixes issue #15.
36
-
37
- ===0.7.5 [14th October 2011]
38
- - Screwup fix release.
39
-
40
- ===0.7.4 [13th October 2011]
41
- - Default index location is now in tmp directory. [parndt - Philip Arndt]
42
- - Fixed a bug where namespaced models would have directory names containing colons. [ugisozols - Uģis Ozols]
43
-
44
- ===0.7.3 [3rd July 2011]
45
- - Support for non-default primary keys. [ttoomey - Theron Toomey]
46
- - Fixed issue with file-locking on JRuby. [banderso - Ben Anderson]
47
-
48
- ===0.7.2 [31st March 2011]
49
- - Fixed bug with ranking of records [Christopher Souvey - bug report]
50
- - Fixed a bug with the slicing of records before AR order is applied. [Christopher Souvey - bug report]
51
- - Fixed bug with slicing of id-only results.
52
- - Error now raised when combining ids_only with find options other than limit and offset.
53
- - Can now disable auto-indexing. Useful for large test suites.
54
-
55
- ===0.7.1 [22nd February 2011]
56
- - Removed file locking on Microsoft Windows as it is unsupported.
57
-
58
- ===0.7.0 [11th February 2011]
59
- - Threadsafe support. Index files are now locked for changes, and atomically written.
60
- - Configurable case-sensitivity.
61
- - Improved performance of index builds.
62
- - Now warns on old version of the index.
63
- - Upgrade instructions added to README. [ionas - Florent Guilleux]
64
-
65
- ===0.6.7 [7th February 2011]
66
- - find_by_index and paginate_search are no longer deprecated.
67
- - Improved documentation.
68
- - Storage is now its own class to allow future development of locking and pluggable backends.
69
-
70
- ===0.6.6 [31st August 2010]
71
- - Now Heroku compatible out of the box, index is created in tmp when root dir is non-writable. [parndt - Philip Arndt - Great suggestion]
72
- - Fixed a require path issue on 1.9.2.
73
- - Fixed an issue with index_file location on Rails 3.0.0 final.
74
-
75
- ===0.6.5 [19th August 2010]
76
- - Reintroduced support for older version of Ruby which do not implement Array#exclude? [bug report by Andy Eggers]
77
- - Using Bundler to manage development dependencies.
78
-
79
- ===0.6.4 [16th August 2010]
80
- - Added starts-with query type [nilbus - Edward Anderson]
81
- - Various fixes and improvements.
82
- - Real names given for all contributors.
83
-
84
- ===0.6.3 [5th July 2010]
85
- - Index file path can now be defined as a Pathname as well as an array. [parndt - Philip Arndt]
86
- - Can now define which records are indexed and which are not via an :if proc. [madpilot - Myles Eftos]
87
- - Lots of tidying up. [parndt - Philip Arndt]
88
- - Rails 3 fixes. [myabc - Alex Coles]
89
-
90
- ===0.6.2 [11th June 2010]
91
- - Now available as a Gem as well as the original plugin. [parndt - Philip Arndt - Thanks for doing most of the hard work.]
92
-
93
- ===0.6.0 [10th June 2010]
94
- - Now supports Rails 3.x.x as well as Rails 2.x.x.
95
- - Added global configuration options.
96
- - Now recommending using with_query scope for searching.
97
- - Deprecated find_with_index and will_paginate_search methods.
98
-
99
- ===0.5.3 [6th June 2010]
100
- - Now supports non-standard table names automatically. [nandalopes - Fernanda Lopes]
101
-
102
- ===0.5.2 [3rd May 2010]
103
- - Fix for Errno::ERANGE error related to certain Math.log calculations. [parndt - Philip Arndt]
104
- - Improved index detection in a shared-directory environment. [bob-p - Thomas Pomfret]
105
-
106
- ===0.5.1 [11 June 2009]
107
- - Fixed Ruby 1.8.6 compatibility.
108
-
109
- ===0.5.0 [24 April 2009]
110
- - Ruby 1.9 and Rails 2.3 compatibility.
111
- - Index location can now be set. Provides Heroku compatibility.
112
- - Better errors on bad options.
113
- - ActiveRecord order argument overrides ranking returned by find_by_index.
114
- - Various test environment improvements
115
- - Various Bugfixes
116
-
117
- ===0.4.6 [10 August 2008]
118
- - Rolled in pagination.
119
-
120
- ===0.4.5 [04 February 2008]
121
- - Fixed a bug where the find_options :limit would be added to the :offset, which caused incorrectly sized collections to be returned.
122
- - Fixed an 'ambiguous column' error when using the :includes find_options key.
123
-
124
- ===0.4.4 [29 November 2007]
125
- - Fixed a bug causing the weighting section of the code to error out.
126
-
127
- ===0.4.3 [27 September 2007]
128
- - Fixed a bug causing records to be deleted from index during record updates.
129
-
130
- ===0.4.2 [27 September 2007]
131
- - Fixed a bug causing identically ranked records to be lost.
132
-
133
- ===0.4.1 [22 September 2007]
134
- - Fixed a bug in the main search method.
135
-
136
- ===0.4.0 [22 September 2007]
137
- - Search results now ranked by relevance.
138
-
139
- ===0.3.3 [20 September 2007]
140
- - Fixed index update bug where deleted atoms were not removed from index.
141
- - Improved performance of quoted queries.
142
- - Improved performance of index updates.
143
- - When building a full index, records are retrieved and indexed in batches to reduce memory consumption.
144
-
145
- ===0.3.2 [19 September 2007]
146
- - Fixed index update bug.
147
-
148
- ===0.3.1 [18 September 2007]
149
- - Added RDoc documentation comments.
150
-
151
- ===0.3.0 [18 September 2007]
152
- - Minor bug fixes.
153
- - min_word_size now works properly, with queries containing small words in
154
- quotes or being preceded by a '+' symbol are now searched on.
155
-
156
- ===0.2.2 [06 September 2007]
157
- - Search now caches query results within a session. Call the search twice in an
158
- action? Only runs once!
159
-
160
- ===0.2.1 [05 September 2007]
161
- - AR find options can now be passed to the search to allow finer control of
162
- returned Model Objects.
163
-
164
- ===0.2.0 [04 September 2007]
165
- - Major performance improvements.
166
- - Index segmentation can now be tuned.
167
-
168
- ===0.1.1 [31 August 2007]
169
- - Added a full set of tests.
170
- - Fixed various set-manipulation based errors.
171
- - Fixed a bug when searching for quoted phrases.
172
-
173
- ===0.1.01 [31 August 2007]
174
- - Fixed a casting bug occurring when adding non-string fields to the index.
175
-
176
- ===0.1 [31 August 2007]
177
- - Initial release.
data/Gemfile.lock DELETED
@@ -1,33 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activemodel (3.2.11)
5
- activesupport (= 3.2.11)
6
- builder (~> 3.0.0)
7
- activerecord (3.2.11)
8
- activemodel (= 3.2.11)
9
- activesupport (= 3.2.11)
10
- arel (~> 3.0.2)
11
- tzinfo (~> 0.3.29)
12
- activesupport (3.2.11)
13
- i18n (~> 0.6)
14
- multi_json (~> 1.0)
15
- arel (3.0.2)
16
- builder (3.0.4)
17
- i18n (0.6.1)
18
- mocha (0.9.12)
19
- multi_json (1.5.0)
20
- rake (10.0.3)
21
- sqlite3 (1.3.6)
22
- tzinfo (0.3.35)
23
- will_paginate (3.0.3)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- activerecord (~> 3.2.9)
30
- mocha (~> 0.9.11)
31
- rake
32
- sqlite3 (~> 1.3.5)
33
- will_paginate (~> 3.0.3)