mongoid_fulltext 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -243,6 +243,7 @@ Additional indexing/query options can be used as parameters to `fulltext_search_
243
243
  * When set to a string, the string is evaluated within the document's instance.
244
244
  * When set to a proc, the proc is called, and the document is given to the proc as the first arg.
245
245
  * When set to any other type of object, the document's index will not be updated.
246
+ * `reindex_immediately`: whether models will be reindexed automatically upon saves or updates. Defaults to true. When set to false, the class-level `update_ngram_index` method can be called to perform reindexing.
246
247
 
247
248
  Array filters
248
249
  -------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.5.7
@@ -32,6 +32,7 @@ module Mongoid::FullTextSearch
32
32
  :index_short_prefixes => false,
33
33
  :max_candidate_set_size => 1000,
34
34
  :remove_accents => true,
35
+ :reindex_immediately => true,
35
36
  :stop_words => Hash[['i', 'a', 's', 't', 'me', 'my', 'we', 'he', 'it', 'am', 'is', 'be', 'do', 'an', 'if',
36
37
  'or', 'as', 'of', 'at', 'by', 'to', 'up', 'in', 'on', 'no', 'so', 'our', 'you', 'him',
37
38
  'his', 'she', 'her', 'its', 'who', 'are', 'was', 'has', 'had', 'did', 'the', 'and',
@@ -54,7 +55,7 @@ module Mongoid::FullTextSearch
54
55
  config[:word_separators] = Hash[config[:word_separators].split('').map{ |ch| [ch,ch] }]
55
56
  self.mongoid_fulltext_config[index_name] = config
56
57
 
57
- before_save :update_ngram_index
58
+ before_save(:update_ngram_index) if config[:reindex_immediately]
58
59
  before_destroy :remove_from_ngram_index
59
60
  end
60
61
 
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{mongoid_fulltext}
8
- s.version = "0.5.6"
7
+ s.name = "mongoid_fulltext"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Windsor"]
12
- s.date = %q{2011-12-19}
13
- s.description = %q{Full-text search for the Mongoid ORM, using n-grams extracted from text}
14
- s.email = %q{aaron.windsor@gmail.com}
12
+ s.date = "2012-01-12"
13
+ s.description = "Full-text search for the Mongoid ORM, using n-grams extracted from text"
14
+ s.email = "aaron.windsor@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.md"
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "spec/models/accentless_artwork.rb",
31
31
  "spec/models/advanced_artwork.rb",
32
32
  "spec/models/basic_artwork.rb",
33
+ "spec/models/delayed_artwork.rb",
33
34
  "spec/models/external_artist.rb",
34
35
  "spec/models/external_artwork.rb",
35
36
  "spec/models/external_artwork_no_fields_supplied.rb",
@@ -47,15 +48,16 @@ Gem::Specification.new do |s|
47
48
  "spec/mongoid/fulltext_spec.rb",
48
49
  "spec/spec_helper.rb"
49
50
  ]
50
- s.homepage = %q{http://github.com/aaw/mongoid_fulltext}
51
+ s.homepage = "http://github.com/aaw/mongoid_fulltext"
51
52
  s.licenses = ["MIT"]
52
53
  s.require_paths = ["lib"]
53
- s.rubygems_version = %q{1.6.2}
54
- s.summary = %q{Full-text search for the Mongoid ORM}
54
+ s.rubygems_version = "1.8.10"
55
+ s.summary = "Full-text search for the Mongoid ORM"
55
56
  s.test_files = [
56
57
  "spec/models/accentless_artwork.rb",
57
58
  "spec/models/advanced_artwork.rb",
58
59
  "spec/models/basic_artwork.rb",
60
+ "spec/models/delayed_artwork.rb",
59
61
  "spec/models/external_artist.rb",
60
62
  "spec/models/external_artwork.rb",
61
63
  "spec/models/external_artwork_no_fields_supplied.rb",
@@ -0,0 +1,8 @@
1
+ class DelayedArtwork
2
+ include Mongoid::Document
3
+ include Mongoid::FullTextSearch
4
+
5
+ field :title
6
+ fulltext_search_in :title, :reindex_immediately => false
7
+
8
+ end
@@ -669,5 +669,16 @@ module Mongoid
669
669
  end
670
670
 
671
671
  end
672
+
673
+ context "batched reindexing" do
674
+ let!(:flowers1) { DelayedArtwork.create(:title => 'Flowers 1') }
675
+
676
+ it "should not rebuild index until explicitly invoked" do
677
+ DelayedArtwork.fulltext_search("flowers").length.should == 0
678
+ DelayedArtwork.update_ngram_index
679
+ DelayedArtwork.fulltext_search("flowers").length.should == 1
680
+ end
681
+ end
682
+
672
683
  end
673
684
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_fulltext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-19 00:00:00.000000000 -05:00
13
- default_executable:
12
+ date: 2012-01-12 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: unicode_utils
17
- requirement: &79305610 !ruby/object:Gem::Requirement
16
+ requirement: &2154109500 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 1.0.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *79305610
24
+ version_requirements: *2154109500
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: mongoid
28
- requirement: &79305370 !ruby/object:Gem::Requirement
27
+ requirement: &2154107440 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 2.0.0
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *79305370
35
+ version_requirements: *2154107440
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: bson_ext
39
- requirement: &79305130 !ruby/object:Gem::Requirement
38
+ requirement: &2154105600 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 1.3.0
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *79305130
46
+ version_requirements: *2154105600
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rspec
50
- requirement: &79304890 !ruby/object:Gem::Requirement
49
+ requirement: &2154103900 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: 2.5.0
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *79304890
57
+ version_requirements: *2154103900
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: jeweler
61
- requirement: &79304650 !ruby/object:Gem::Requirement
60
+ requirement: &2154099020 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -66,7 +65,7 @@ dependencies:
66
65
  version: 1.5.2
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *79304650
68
+ version_requirements: *2154099020
70
69
  description: Full-text search for the Mongoid ORM, using n-grams extracted from text
71
70
  email: aaron.windsor@gmail.com
72
71
  executables: []
@@ -88,6 +87,7 @@ files:
88
87
  - spec/models/accentless_artwork.rb
89
88
  - spec/models/advanced_artwork.rb
90
89
  - spec/models/basic_artwork.rb
90
+ - spec/models/delayed_artwork.rb
91
91
  - spec/models/external_artist.rb
92
92
  - spec/models/external_artwork.rb
93
93
  - spec/models/external_artwork_no_fields_supplied.rb
@@ -104,7 +104,6 @@ files:
104
104
  - spec/models/stopwords_artwork.rb
105
105
  - spec/mongoid/fulltext_spec.rb
106
106
  - spec/spec_helper.rb
107
- has_rdoc: true
108
107
  homepage: http://github.com/aaw/mongoid_fulltext
109
108
  licenses:
110
109
  - MIT
@@ -120,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
119
  version: '0'
121
120
  segments:
122
121
  - 0
123
- hash: 465387827
122
+ hash: 2225884234054153231
124
123
  required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  none: false
126
125
  requirements:
@@ -129,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
128
  version: '0'
130
129
  requirements: []
131
130
  rubyforge_project:
132
- rubygems_version: 1.6.2
131
+ rubygems_version: 1.8.10
133
132
  signing_key:
134
133
  specification_version: 3
135
134
  summary: Full-text search for the Mongoid ORM
@@ -137,6 +136,7 @@ test_files:
137
136
  - spec/models/accentless_artwork.rb
138
137
  - spec/models/advanced_artwork.rb
139
138
  - spec/models/basic_artwork.rb
139
+ - spec/models/delayed_artwork.rb
140
140
  - spec/models/external_artist.rb
141
141
  - spec/models/external_artwork.rb
142
142
  - spec/models/external_artwork_no_fields_supplied.rb