mongoid-fts 0.4.3 → 0.4.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWY5NzE3YzAzMGQ0MmUzYTA1MzU1NWI3ZWJlZjM3NTY5NjhlMDNlOQ==
4
+ MjNhZWNkYjRiMmYzYWY1MmU4YmI3M2Y5ZDdmMGQ0MThmNWMzMDY5Yw==
5
5
  data.tar.gz: !binary |-
6
- YmUxNzA0YTU5NzljYjBiZmM3ZjMxZTVjMGQwMTI2ZjNlNjI2ODQxYg==
6
+ MjY4ODFlNmNjNzVjMjg3ODliOGI1NjcyOTVmZWEyMGVmNGM0OTlhMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjFlODg3YzQ3ZTU4ZWE4MzAyOWZmYWM2ZjgyN2U4MjI1ZmQwMzZmMWVlNmUz
10
- MzM5YjBjNTdlMWJjMTlkMWU0YzhiM2UyOThkYTc0YjNjOTYzNDFhOGUzYWYx
11
- NTZjNjI1YjQ4MGRhNWZjYzZmOGQzNWYyMGE0ZGY3MWI3NjEyYTI=
9
+ MWNlYTA1Zjg3NjM4ZTQxNTcxNjZmZWVkZjdkMGI5ZDRkNDM4MmY0ZDRmMmI5
10
+ NzhiMDQ4OGU2NjZlODkxNGU2YjgwOTQ1YzM0ZWQxZDU1ZDljM2VhOTZjYjQx
11
+ ZmYxNWNlYjlmODc2ODkzOGU3M2ZlNzQyOTgxYTJjMzcyYmU5Mzc=
12
12
  data.tar.gz: !binary |-
13
- OGY2M2ZiNDE5ZWNmZTk0YTBmNzk4N2EyZDA4ZjJlMzAyNjNlMjNkYmFkOTY1
14
- N2Y5M2M2NjMxNTZhN2EzYmFlMDdmM2I3MDhkZDA5ZTNlZTY2Y2RkOTYyZjQz
15
- ZjhjMjY4YzcyOTFlMWE0ZDVlNTJiYmU1ZDdkMGYyYTI1MmIxYjg=
13
+ Mjg5YTI3ZTY0NTNiNjgwODE5MTE0YTBlZWQwM2YxY2NhNWMwMTIwNmRkOTRh
14
+ YTI1MWM3OTVkNGVkMWQwOGQ0OWQ3YmYxODdkYzI0NmUzZmMwODQ5OTA4OWFi
15
+ ODNlODIwM2YzYjA2ZGYyODc0YzczN2I2OTA0NWY1NDU1MjZjNDE=
@@ -1,7 +1,7 @@
1
1
  module Mongoid
2
2
  module FTS
3
3
  #
4
- const_set(:Version, '0.4.3') unless const_defined?(:Version)
4
+ const_set(:Version, '0.4.4') unless const_defined?(:Version)
5
5
 
6
6
  class << FTS
7
7
  def version
@@ -55,6 +55,8 @@ module Mongoid
55
55
  nil
56
56
  end
57
57
 
58
+ #
59
+ class Error < ::StandardError; end
58
60
 
59
61
  #
60
62
  def FTS.search(*args)
@@ -361,13 +363,30 @@ module Mongoid
361
363
  :fulltext => fulltext
362
364
  }
363
365
 
364
- new(conditions).upsert
365
-
366
- where(conditions).first.tap do |index|
367
- if index
368
- index.update_attributes(attributes)
366
+ begin
367
+ new(conditions).upsert
368
+ rescue Object => e
369
+ warn "#{ e.message } (#{ e.class })"
370
+
371
+ 4.times do
372
+ begin
373
+ break if create(conditions)
374
+ rescue Object => e
375
+ warn "#{ e.message } (#{ e.class })"
376
+ nil
377
+ end
369
378
  end
370
379
  end
380
+
381
+ # FIXME - go BOOM here if none found...
382
+ #
383
+ index = where(conditions).first
384
+
385
+ if index
386
+ index.update_attributes(attributes)
387
+ else
388
+ raise Error.new("failed to create index for #{ conditions.inspect }")
389
+ end
371
390
  end
372
391
 
373
392
  def Index.remove(model)
@@ -451,6 +470,8 @@ module Mongoid
451
470
  after_destroy do |model|
452
471
  FTS::Index.remove(model) rescue nil
453
472
  end
473
+
474
+ has_one(:search_index, :as => :context, :class_name => '::Mongoid::FTS::Index')
454
475
  end
455
476
  end
456
477
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "mongoid-fts"
6
- spec.version = "0.4.3"
6
+ spec.version = "0.4.4"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "mongoid-fts"
9
9
  spec.description = "enable mongodb's new fulltext simply and quickly on your mongoid models, including pagination."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-fts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard